diff --git a/packages/adapters/astro/package.json b/packages/adapters/astro/package.json index af72fbfb..167d15d6 100644 --- a/packages/adapters/astro/package.json +++ b/packages/adapters/astro/package.json @@ -32,6 +32,7 @@ ], "dependencies": { "@withmoons/config": "*", + "@withmoons/explorer": "*", "astro": "2.10.1" }, "peerDependencies": { diff --git a/packages/adapters/astro/src/index.ts b/packages/adapters/astro/src/index.ts index 72579243..907c54dd 100644 --- a/packages/adapters/astro/src/index.ts +++ b/packages/adapters/astro/src/index.ts @@ -1,6 +1,7 @@ import type { AstroIntegration } from 'astro' import { getConfig } from '@withmoons/config' +export { getStaticPaths } from './pages' export { integrationsPreset } from './preset' type MoonsOptions = { diff --git a/packages/adapters/astro/src/pages.ts b/packages/adapters/astro/src/pages.ts new file mode 100644 index 00000000..7789dff3 --- /dev/null +++ b/packages/adapters/astro/src/pages.ts @@ -0,0 +1,8 @@ +import { getAllPagesExceptHome } from '@withmoons/explorer' + +export async function getStaticPaths() { + return (await getAllPagesExceptHome()).map((page) => ({ + params: { path: page.path.slice(1) }, + props: { page }, + })) +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 079bffd8..4b19157b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ importers: '@withmoons/config': specifier: '*' version: link:../../config + '@withmoons/explorer': + specifier: '*' + version: link:../../moons astro: specifier: 2.10.1 version: 2.10.1(@types/node@20.4.7)