Skip to content

Commit

Permalink
feat: Update sitemap generation configuration
Browse files Browse the repository at this point in the history
The commit adds the sitemap plugin and updates the `vite.config.ts` file to include the necessary configuration for generating a sitemap. It also mentions the usage of the `honox` plugin and the `pages` plugin for Cloudflare Pages deployment.
  • Loading branch information
kbkn3 committed Aug 31, 2024
1 parent f44e245 commit 05cde39
Showing 1 changed file with 72 additions and 6 deletions.
78 changes: 72 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -505,18 +505,18 @@ export default defineConfig(({ mode }) => {
output: {
entryFileNames: 'static/client.js',
chunkFileNames: 'static/assets/[name]-[hash].js',
assetFileNames: 'static/assets/[name].[ext]'
}
assetFileNames: 'static/assets/[name].[ext]',
},
},
emptyOutDir: false
}
emptyOutDir: false,
},
}
} else {
return {
ssr: {
external: ['react', 'react-dom']
external: ['react', 'react-dom'],
},
plugins: [honox(), pages()]
plugins: [honox(), pages()],
}
}
})
Expand Down Expand Up @@ -815,6 +815,72 @@ export default defineConfig({
})
```
### Generate Sitemap
To generate a sitemap, use the `sitemap` plugin provided by HonoX.
Update your `vite.config.ts` as follows:
```ts
import honox from 'honox/vite'
import adapter from '@hono/vite-dev-server/cloudflare'
import { defineConfig } from 'vite'
import sitemap from 'honox/vite/sitemap'

export default defineConfig({
plugins: [
honox({
devServer: {
adapter,
},
}),
sitemap({
hostname: 'https://example.com',
exclude: ['/404', 'error'],
priority: { '/': '1.0', '/about': '0.8', '/posts/*': '0.6' },
frequency: { '/': 'daily', '/about': 'monthly', '/posts/*': 'weekly' },
}),
],
})
```
For deployment to Cloudflare Pages, you can use the following configuration:
Register the IS_PROD = true environment variable in the Cloudflare Pages settings:
1. Navigate to the Cloudflare Workers & Pages Dashboard.
1. Go to [Settings] -> [Environment Variables] -> [Production]
1. Add `IS_PROD` with the value `true`.
Update your `vite.config.ts`:
```ts
import pages from '@hono/vite-cloudflare-pages'
import honox from 'honox/vite'
import adapter from '@hono/vite-dev-server/cloudflare'
import { defineConfig } from 'vite'
import sitemap from 'honox/vite/sitemap'

export default defineConfig({
plugins: [
honox({
devServer: {
adapter,
},
}),
pages(),
sitemap({
hostname: process.env.IS_PROD
? 'https://your-project-name.pages.dev/'
: process.env.CF_PAGES_URL,
}),
],
})
```
Note: `CF_PAGES_URL` is an environment variable that Cloudflare Pages automatically sets.
For more information, see [Environment Variables](https://developers.cloudflare.com/pages/configuration/build-configuration/#environment-variables).
## Deployment
Since a HonoX instance is essentially a Hono instance, it can be deployed on any platform that Hono supports.
Expand Down

0 comments on commit 05cde39

Please sign in to comment.