diff --git a/.env b/.env new file mode 100644 index 0000000..5fc0cd3 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +SITE_ORIGIN=http://localhost:4444 \ No newline at end of file diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 48aa527..6c84231 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -9,8 +9,9 @@ on: types: [created] env: - SITE_URL: https://selenite-geos.github.io - SITE_BASE: '/docs' + SITE_ORIGIN: https://selenite-geos.github.io + BASE_PATH: '/docs' + jobs: build: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 6240da8..7e88ae6 100644 --- a/.gitignore +++ b/.gitignore @@ -14,7 +14,7 @@ pnpm-debug.log* # environment variables -.env +# .env .env.production # macOS-specific files diff --git a/README.md b/README.md index 8b9d6e8..ca4e07d 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,11 @@ # Selenite Docs -## Configuration - [![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build) -``` -npm create astro@latest -- --template starlight -``` - -[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics) -[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics) -[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/withastro/starlight&create_from_path=examples/basics) -[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs) -> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun! +## Configuration +The build of the documentation can be configured using environment variables. The following variables are available: +- `SITE_ORIGIN`: The origin of the site, used for generating the sitemap. If not set, the sitemap will not be generated. +- `BASE_PATH`: The base path of the site. All routes will be prefixed with this path. ## 🚀 Project Structure diff --git a/astro.config.mjs b/astro.config.mjs index 8a27d63..1843c37 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -2,17 +2,18 @@ import { defineConfig } from 'astro/config'; import starlight from '@astrojs/starlight'; import { loadEnv } from 'vite'; -const { SITE_URL = 'http://localhost:4444', SITE_BASE = '' } = loadEnv(process.env.NODE_ENV, process.cwd(), ""); -console.log('SITE_URL', SITE_URL); -if (SITE_BASE !== '') - console.log('SITE_BASE', SITE_BASE); -else - console.log('No site base.') +const { SITE_ORIGIN, BASE_PATH = "/" } = loadEnv(process.env.NODE_ENV, process.cwd(), ""); +if (SITE_ORIGIN) +console.log('SITE_ORIGIN', SITE_ORIGIN); +else +console.warn('SITE_ORIGIN is not specified. A sitemap will not be generated.'); +console.log('BASE_PATH', BASE_PATH); + // https://astro.build/config export default defineConfig({ - site: SITE_URL, - base: SITE_BASE, + site: SITE_ORIGIN, + base: BASE_PATH, trailingSlash: 'never', integrations: [ starlight({ @@ -44,10 +45,10 @@ export default defineConfig({ }, { label: 'Developper', - autogenerate: { directory: 'developper' }, + autogenerate: { directory: 'developper' }, translations: { fr: 'Développeur', - }, + }, }, { label: 'Reference',