From 8e8f03532f470269e8cdda3f3bcfbbae15fbe235 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 10 Nov 2023 23:07:14 +0100 Subject: [PATCH] Migrate docs site to Vercel (#795) Co-authored-by: Tony Sullivan --- .gitignore | 3 +++ docs/astro.config.mjs | 9 +++++++-- docs/public/_headers | 4 ---- docs/public/_redirects | 3 --- docs/vercel.json | 22 ++++++++++++++++++++++ 5 files changed, 32 insertions(+), 9 deletions(-) delete mode 100644 docs/public/_headers delete mode 100644 docs/public/_redirects create mode 100644 docs/vercel.json diff --git a/.gitignore b/.gitignore index 9f880cb7098..e790eb4de4e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ pnpm-debug.log* # Vitest __coverage__/ + +# Vercel output +.vercel \ No newline at end of file diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index 37ecec8bd16..2405fd09de4 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -16,7 +16,13 @@ export const locales = { ru: { label: 'Русский', lang: 'ru' }, }; -const site = 'https://starlight.astro.build/'; +/* https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables */ +const VERCEL_PREVIEW_SITE = + process.env.VERCEL_ENV !== 'production' && + process.env.VERCEL_URL && + `https://${process.env.VERCEL_URL}`; + +const site = VERCEL_PREVIEW_SITE || 'https://starlight.astro.build/'; export default defineConfig({ site, @@ -175,7 +181,6 @@ export default defineConfig({ autogenerate: { directory: 'reference' }, }, ], - lastUpdated: true, }), ], }); diff --git a/docs/public/_headers b/docs/public/_headers deleted file mode 100644 index aaa51ef2a6e..00000000000 --- a/docs/public/_headers +++ /dev/null @@ -1,4 +0,0 @@ -/_astro/* - Cache-Control: public - Cache-Control: max-age=604800 - Cache-Control: immutable diff --git a/docs/public/_redirects b/docs/public/_redirects deleted file mode 100644 index a7aa40820f3..00000000000 --- a/docs/public/_redirects +++ /dev/null @@ -1,3 +0,0 @@ -/ph/* https://astro-houston-ph.pages.dev/ph/:splat 200 -/zh/* /zh-cn/:splat -/:lang/* /:lang/404/ 404 diff --git a/docs/vercel.json b/docs/vercel.json new file mode 100644 index 00000000000..e5259e57302 --- /dev/null +++ b/docs/vercel.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://openapi.vercel.sh/vercel.json", + + "routes": [ + { + "src": "^/_astro/(.*)$", + "headers": { "cache-control": "public, max-age=31536000, immutable" }, + "continue": true + }, + + { "src": "/(ph$|ph/)(.*)", "dest": "https://astro-houston-ph.pages.dev/ph/$2" }, + + { "src": "(.*)/([^./]+)$", "dest": "$1/$2/", "status": 301 }, + { "src": "(.*)/index.html$", "dest": "$1/", "status": 301 }, + + { "handle": "filesystem" }, + + { "src": "/zh/(.*)", "dest": "/zh-cn/$1", "status": 301 }, + + { "src": "/(?[^/]*)/(.*)", "dest": "/$lang/404/", "status": 404 } + ] +}