Skip to content

Commit

Permalink
Migrate docs site to Vercel (#795)
Browse files Browse the repository at this point in the history
Co-authored-by: Tony Sullivan <[email protected]>
  • Loading branch information
delucis and Tony Sullivan authored Nov 10, 2023
1 parent f77c6c0 commit 8e8f035
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ pnpm-debug.log*

# Vitest
__coverage__/

# Vercel output
.vercel
9 changes: 7 additions & 2 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -175,7 +181,6 @@ export default defineConfig({
autogenerate: { directory: 'reference' },
},
],
lastUpdated: true,
}),
],
});
4 changes: 0 additions & 4 deletions docs/public/_headers

This file was deleted.

3 changes: 0 additions & 3 deletions docs/public/_redirects

This file was deleted.

22 changes: 22 additions & 0 deletions docs/vercel.json
Original file line number Diff line number Diff line change
@@ -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 }
]
}

0 comments on commit 8e8f035

Please sign in to comment.