feat: remove support for nested categories

This commit is contained in:
saicaca
2023-12-14 13:43:06 +08:00
parent f7efa010a2
commit f9a78b3e3b
9 changed files with 50 additions and 99 deletions

View File

@@ -1,6 +1,5 @@
---
import {getSortedPosts} from "../../../utils/content-utils";
import {getCategoryList, getSortedPosts} from "../../../utils/content-utils";
import MainGridLayout from "../../../layouts/MainGridLayout.astro";
import ArchivePanel from "../../../components/ArchivePanel.astro";
import {i18n} from "../../../i18n/translation";
@@ -8,21 +7,11 @@ 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 => {
const categories = await getCategoryList();
return categories.map(category => {
return {
params: {
category: category
category: category.name
}
}
});

View File

@@ -22,7 +22,6 @@ const {page} = Astro.props;
entry={entry}
title={entry.data.title}
tags={entry.data.tags}
categories={entry.data.categories}
category={entry.data.category}
published={entry.data.published}
url={getPostUrlBySlug(entry.slug)}

View File

@@ -64,7 +64,7 @@ const { remarkPluginFrontmatter } = await entry.render();
class="mb-5"
published={entry.data.published}
tags={entry.data.tags}
categories={entry.data.categories}
category={entry.data.category}
></PostMetadata>
<!-- always show cover as long as it has one -->