update to v5 + remove unmaintained i18n lib
This commit is contained in:
parent
59687fbade
commit
99ef7634e3
19 changed files with 38 additions and 103 deletions
|
@ -13,7 +13,7 @@ export const getStaticPaths = createStaticPaths(
|
|||
return data.lang === langCode;
|
||||
});
|
||||
return articles.map((article) => ({
|
||||
params: { slug: article.data.permalink },
|
||||
params: { id: article.data.permalink },
|
||||
props: { article },
|
||||
}));
|
||||
},
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
import Page from "../../articles/[slug].astro"
|
||||
import { getStaticPaths as proxyGetStaticPaths } from "../../articles/[slug].astro"
|
||||
import { extractRouteLangCode } from "astro-i18n"
|
||||
|
||||
/* @ts-ignore */
|
||||
export const getStaticPaths = (props) => proxyGetStaticPaths({
|
||||
...props,
|
||||
langCode: extractRouteLangCode(import.meta.url),
|
||||
})
|
||||
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
import Page from "../../articles/index.astro"
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
import Page from "../index.astro"
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
import Page from "../plan-du-site.astro"
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -1,15 +0,0 @@
|
|||
---
|
||||
import Page from "../../fragments/[slug].astro"
|
||||
import { getStaticPaths as proxyGetStaticPaths } from "../../fragments/[slug].astro"
|
||||
import { extractRouteLangCode } from "astro-i18n"
|
||||
|
||||
/* @ts-ignore */
|
||||
export const getStaticPaths = (props) => proxyGetStaticPaths({
|
||||
...props,
|
||||
langCode: extractRouteLangCode(import.meta.url),
|
||||
})
|
||||
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
import Page from "../../fragments/index.astro"
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
import Page from "../../veille/index.astro"
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -1,6 +0,0 @@
|
|||
---
|
||||
import Page from "../../references/index.astro"
|
||||
const { props } = Astro
|
||||
---
|
||||
|
||||
<Page {...props} />
|
|
@ -13,7 +13,7 @@ export const getStaticPaths = createStaticPaths(
|
|||
return data.lang === langCode;
|
||||
});
|
||||
return snippets.map((snippet) => ({
|
||||
params: { slug: snippet.data.permalink },
|
||||
params: { id: snippet.data.permalink },
|
||||
props: { snippet },
|
||||
}));
|
||||
},
|
|
@ -1,7 +1,8 @@
|
|||
---
|
||||
// init i18n
|
||||
import { l, t, astroI18n } from "astro-i18n";
|
||||
astroI18n.init(Astro);
|
||||
import { getLocale } from "astro-i18n-aut";
|
||||
|
||||
const locale = getLocale(Astro.url);
|
||||
|
||||
// import stuff
|
||||
import BaseLayout from "../layouts/BaseLayout.astro";
|
||||
|
@ -11,17 +12,19 @@ import ListCards from "../components/ListCards.astro";
|
|||
const pageTitle = t("accueil");
|
||||
|
||||
// get all HP sections
|
||||
const allSections = await Astro.glob("../data/HP/**/*.md");
|
||||
const allSections = Object.values(
|
||||
import.meta.glob("../data/HP/**/*.md", { eager: true })
|
||||
);
|
||||
// only keep the right locale version
|
||||
const localizedSections = allSections.filter((section) => {
|
||||
return section.frontmatter.lang === astroI18n.langCode;
|
||||
return section.frontmatter.lang === locale;
|
||||
});
|
||||
|
||||
// New astro content collections
|
||||
import { getCollection } from "astro:content";
|
||||
// Only return posts with correct lang in the frontmatter
|
||||
const localizedArticles = await getCollection("articles", ({ data }) => {
|
||||
return data.lang === astroI18n.langCode && !data.draft;
|
||||
return data.lang === locale && !data.draft;
|
||||
});
|
||||
// sort articles by descending publication date
|
||||
const sortedArticles = localizedArticles.sort(
|
||||
|
@ -29,14 +32,14 @@ const sortedArticles = localizedArticles.sort(
|
|||
);
|
||||
// Only return snippets with correct lang in the frontmatter
|
||||
const localizedSnippets = await getCollection("fragments", ({ data }) => {
|
||||
return data.lang === astroI18n.langCode && !data.draft;
|
||||
return data.lang === locale && !data.draft;
|
||||
});
|
||||
// sort articles by descending publication date
|
||||
const sortedSnippets = localizedSnippets.sort(
|
||||
(a, b) => b.data.createdAt - a.data.createdAt
|
||||
);
|
||||
const localizedReferences = await getCollection("references", ({ data }) => {
|
||||
return data.lang === astroI18n.langCode && !data.draft;
|
||||
return data.lang === locale && !data.draft;
|
||||
});
|
||||
---
|
||||
|
||||
|
|
|
@ -8,7 +8,9 @@ import BaseLayout from "../../layouts/BaseLayout.astro";
|
|||
import MetaDate from "../../components/MetaDate.astro";
|
||||
|
||||
// get all content
|
||||
const allSections = await Astro.glob("../../data/veille/**/*.md");
|
||||
const allSections = Object.values(
|
||||
import.meta.glob("../../data/veille/**/*.md", { eager: true })
|
||||
);
|
||||
// only keep the right locale version
|
||||
const localizedSections = allSections.filter((section) => {
|
||||
return section.frontmatter.lang === astroI18n.langCode;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue