2c4cc28e1f
(cherry picked from commit 0d9fc72bee009c591400055725680a6a0f5a9c83)
38 lines
996 B
Plaintext
38 lines
996 B
Plaintext
---
|
|
|
|
import {getSortedPosts} from "../../../utils/content-utils";
|
|
import MainGridLayout from "../../../layouts/MainGridLayout.astro";
|
|
import ArchivePanel from "../../../components/ArchivePanel.astro";
|
|
import {i18n} from "../../../i18n/translation";
|
|
import I18nKey from "../../../i18n/i18nKey";
|
|
|
|
|
|
export async function getStaticPaths() {
|
|
let posts = await getSortedPosts()
|
|
|
|
const allCategories = posts.reduce((acc, post) => {
|
|
if (!Array.isArray(post.data.categories))
|
|
return acc;
|
|
post.data.categories.forEach(category => acc.add(category));
|
|
return acc;
|
|
}, new Set());
|
|
|
|
const allCategoriesArray = Array.from(allCategories);
|
|
|
|
return allCategoriesArray.map(category => {
|
|
return {
|
|
params: {
|
|
category: category
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
const { category } = Astro.params;
|
|
|
|
---
|
|
|
|
<MainGridLayout title={i18n(I18nKey.archive)}>
|
|
<ArchivePanel categories={[category]}></ArchivePanel>
|
|
</MainGridLayout>
|