diff --git a/astro.config.mjs b/astro.config.mjs index 551b684..2f4dc6c 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -71,6 +71,14 @@ export default defineConfig({ rehypePlugins: [responsiveTablesRehypePlugin], }, + i18n: { + defaultLocale: 'fr', + locales: ['fr', 'en'], + routing: { + prefixDefaultLocale: true, + }, + }, + vite: { resolve: { alias: { diff --git a/src/pages/blog/[...page].astro b/src/pages/[locale]/blog/[...page].astro similarity index 57% rename from src/pages/blog/[...page].astro rename to src/pages/[locale]/blog/[...page].astro index b8797a6..bc1f221 100644 --- a/src/pages/blog/[...page].astro +++ b/src/pages/[locale]/blog/[...page].astro @@ -8,28 +8,30 @@ import Pagination from '~/components/blog/Pagination.astro'; import dataProvider from '~/config/dataProvider'; -export const getStaticPaths = (async ({ paginate }) => { +export const getStaticPaths = async ({ paginate }) => { + const allLocales = ['fr', 'en']; const { data } = await dataProvider.getList('BlogPost'); - return paginate(data, { - pageSize: 8, + return allLocales.flatMap((locale) => { + const dataByLocale = data.filter((post) => locale === 'fr'); + return paginate(dataByLocale, { + params: { locale }, + pageSize: 8, + }); }); -}) satisfies GetStaticPaths; +}; /*satisfies GetStaticPaths*/ -type Props = InferGetStaticPropsType; +// type Props = InferGetStaticPropsType; -const { page } = Astro.props as Props; +const { page } = Astro.props; /*as Props*/ const metadata = { title: 'The Blog', }; - ---
- + Le Blog de l'AV diff --git a/src/pages/blog/[...slug].astro b/src/pages/[locale]/blog/[...slug].astro similarity index 58% rename from src/pages/blog/[...slug].astro rename to src/pages/[locale]/blog/[...slug].astro index 88f2d47..1b2a740 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/[locale]/blog/[...slug].astro @@ -2,25 +2,24 @@ import Layout from '~/layouts/PageLayout.astro'; import SinglePost from '~/components/blog/SinglePost.astro'; import ToBlogLink from '~/components/blog/ToBlogLink.astro'; -import dataProvider from '../../config/dataProvider'; +import dataProvider from '~/config/dataProvider'; export const prerender = true; export async function getStaticPaths() { - const { data: posts } = await dataProvider.getList('BlogPost'); - return posts.map((post) => ({ - params: { slug: post.id }, - props: post, - })); + const { data: posts } = await dataProvider.getList('BlogPost'); + return posts.map((post) => ({ + params: { slug: post.id }, + props: post, + })); } const post = Astro.props; const metadata = { - title: post['pair:label'], - description: post['pair:comment'] -} - + title: post['pair:label'], + description: post['pair:comment'], +}; --- diff --git a/src/pages/pricing.astro b/src/pages/[locale]/pricing.astro similarity index 97% rename from src/pages/pricing.astro rename to src/pages/[locale]/pricing.astro index 0e7fb1a..cd42386 100644 --- a/src/pages/pricing.astro +++ b/src/pages/[locale]/pricing.astro @@ -7,9 +7,15 @@ import Steps from '~/components/widgets/Steps.astro'; import Features3 from '~/components/widgets/Features3.astro'; import CallToAction from '~/components/widgets/CallToAction.astro'; +export async function getStaticPaths() { + return [{ params: { locale: 'en' } }, { params: { locale: 'fr' } }]; +} + const metadata = { title: 'Pricing', }; + +const { locale } = Astro.params; ---