summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Swithinbank2023-11-10 23:07:14 +0100
committerGitHub2023-11-10 23:07:14 +0100
commit8e8f03532f470269e8cdda3f3bcfbbae15fbe235 (patch)
tree4026a058eca8595fa931ee1f07c2f179f2d0b1a9
parentf77c6c0d6c1ac07c3c98d2b247d4c28f9d971003 (diff)
downloadIT.starlight-8e8f03532f470269e8cdda3f3bcfbbae15fbe235.tar.gz
IT.starlight-8e8f03532f470269e8cdda3f3bcfbbae15fbe235.tar.bz2
IT.starlight-8e8f03532f470269e8cdda3f3bcfbbae15fbe235.zip
Migrate docs site to Vercel (#795)
Co-authored-by: Tony Sullivan <tony.f.sullivan@outlook.com>
-rw-r--r--.gitignore3
-rw-r--r--docs/astro.config.mjs9
-rw-r--r--docs/public/_headers4
-rw-r--r--docs/public/_redirects3
-rw-r--r--docs/vercel.json22
5 files changed, 32 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore
index 9f880cb7..e790eb4d 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 37ecec8b..2405fd09 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 aaa51ef2..00000000
--- 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 a7aa4082..00000000
--- 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 00000000..e5259e57
--- /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": "/(?<lang>[^/]*)/(.*)", "dest": "/$lang/404/", "status": 404 }
+ ]
+}