diff --git a/README.md b/README.md index bdbc858..d75ebb3 100644 --- a/README.md +++ b/README.md @@ -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()], } } }) @@ -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.