changed offres + added reference to HP

This commit is contained in:
Nico 2023-06-03 22:27:00 +02:00
parent 4ec6b01162
commit 4d184782fc
25 changed files with 1014 additions and 837 deletions

View file

@ -1,26 +1,34 @@
---
import { astroI18n } from "astro-i18n";
astroI18n.init(Astro);
import { createStaticPaths } from "astro-i18n";
import { getCollection } from "astro:content";
import EditorialContent from "../../components/EditorialContent.astro";
import EditorialContent from "../../components/EditorialContent.astro";
import BaseLayout from "../../layouts/BaseLayout.astro";
export async function getStaticPaths() {
export const getStaticPaths = createStaticPaths(async ({ langCode }) => {
const articles = await getCollection("articles", ({ data }) => {
return data.lang === astroI18n.langCode;
return data.lang === langCode;
});
return articles.map((article) => ({
params: { slug: article.slug },
props: { article },
}));
}
}, import.meta.url);
// export async function getStaticPaths() {
// const articles = await getCollection("articles", ({ data }) => {
// return data.lang === astroI18n.langCode;
// });
// return articles.map((article) => ({
// params: { slug: article.slug },
// props: { article },
// }));
// }
const { article } = Astro.props;
---
<BaseLayout pageTitle={article.data.title}>
{article.data.lang}
<EditorialContent content={article} />
</BaseLayout>

View file

@ -1,9 +0,0 @@
---
import Page from "../../articles/[...slug].astro"
export { getStaticPaths } from "../../articles/[...slug].astro"
const { props } = Astro
---
<Page {...props} />

View file

@ -0,0 +1,15 @@
---
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} />

View file

@ -1,6 +1,5 @@
---
import Page from "../../articles/index.astro"
const { props } = Astro
---

View file

@ -1,6 +1,5 @@
---
import Page from "../index.astro"
const { props } = Astro
---

View file

@ -1,6 +1,5 @@
---
import Page from "../plan-du-site.astro"
const { props } = Astro
---

View file

@ -1,7 +1,13 @@
---
import Page from "../../fragments/[slug].astro"
import { getStaticPaths as proxyGetStaticPaths } from "../../fragments/[slug].astro"
import { extractRouteLangCode } from "astro-i18n"
export { getStaticPaths } from "../../fragments/[slug].astro"
/* @ts-ignore */
export const getStaticPaths = (props) => proxyGetStaticPaths({
...props,
langCode: extractRouteLangCode(import.meta.url),
})
const { props } = Astro
---

View file

@ -1,6 +1,5 @@
---
import Page from "../../fragments/index.astro"
const { props } = Astro
---

View file

@ -1,6 +1,5 @@
---
import Page from "../../veille/index.astro"
const { props } = Astro
---

View file

@ -1,6 +1,5 @@
---
import Page from "../../references/index.astro"
const { props } = Astro
---

View file

@ -1,21 +1,30 @@
---
import { l, t, astroI18n } from "astro-i18n";
astroI18n.init(Astro);
import { createStaticPaths } from "astro-i18n";
import { getCollection } from "astro:content";
import EditorialContent from "../../components/EditorialContent.astro";
import BaseLayout from "../../layouts/BaseLayout.astro";
export async function getStaticPaths() {
export const getStaticPaths = createStaticPaths(async ({ langCode }) => {
const snippets = await getCollection("fragments", ({ data }) => {
return data.lang === astroI18n.langCode;
return data.lang === langCode;
});
return snippets.map((snippet) => ({
params: { slug: snippet.slug },
props: { snippet },
}));
}
}, import.meta.url);
// export async function getStaticPaths() {
// const snippets = await getCollection("fragments", ({ data }) => {
// return data.lang === astroI18n.langCode;
// });
// return snippets.map((snippet) => ({
// params: { slug: snippet.slug },
// props: { snippet },
// }));
// }
const { snippet } = Astro.props;
---

View file

@ -3,10 +3,13 @@
import { l, t, astroI18n } from "astro-i18n";
astroI18n.init(Astro);
import { getEntry } from "astro:content";
// import stuff
import BaseLayout from "../layouts/BaseLayout.astro";
import QuickAccessCard from "../components/QuickAccessCard.astro";
import ListCards from "../components/ListCards.astro";
import CardEditorial from "../components/CardEditorial.astro";
const pageTitle = t("accueil");
@ -35,6 +38,9 @@ const localizedSnippets = await getCollection("fragments", ({ data }) => {
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;
});
---
<BaseLayout pageTitle={pageTitle}>
@ -44,11 +50,14 @@ const sortedSnippets = localizedSnippets.sort(
<h2 class="intro__subtitle">{t("index.subtitle")}</h2>
<ul class="quick-access__list" role="list">
{
localizedSections.map((section) => (
<li>
<QuickAccessCard item={section.frontmatter} />
</li>
))
localizedSections.map(
(section) =>
section.frontmatter.id && (
<li>
<QuickAccessCard item={section.frontmatter} />
</li>
)
)
}
</ul>
</section>
@ -60,6 +69,16 @@ const sortedSnippets = localizedSnippets.sort(
<div class="section__container">
<div class="flow section__content">
<section.Content />
{section.frontmatter.reference && (
<div class="section__reference">
<ListCards
list={localizedReferences.filter((ref) => {
return ref.slug === section.frontmatter.reference;
})}
routeName={t("references.slug")}
/>
</div>
)}
</div>
<div class="section__image">
<img
@ -149,6 +168,7 @@ const sortedSnippets = localizedSnippets.sort(
/* SECTIONS */
.section {
--region-space: var(--space-l-3xl);
container-name: section;
container-type: inline-size;
}
@ -156,7 +176,7 @@ const sortedSnippets = localizedSnippets.sort(
display: flex;
flex-direction: column;
align-items: center;
gap: var(--space-m-l);
gap: var(--space-m-xl);
}
.section :global(h2) {
@ -177,20 +197,33 @@ const sortedSnippets = localizedSnippets.sort(
@container section (min-width: 50rem) {
.section__container {
position: relative;
flex-direction: row;
align-items: flex-start;
}
.section__image {
order: 1;
position: sticky;
top: 20px;
top: var(--space-3xl);
flex-grow: 1;
flex-basis: 18rem;
}
.section__content {
order: 2;
flex-basis: 0;
min-inline-size: 40ch;
min-inline-size: 32ch;
font-size: var(--size-1);
}
.section__content :global(h2) {
font-size: var(--size-5);
line-height: 1.2;
}
.section__reference {
margin-block-start: 50vh;
padding-block-end: var(--space-3xl);
}
.section__reference :global(.card a) {
font-size: var(--size-0);
}
}
</style>