feat: initial commit

(cherry picked from commit 44c4d7b9521fe449e61edc614446195861932f8c)
This commit is contained in:
saicaca
2023-09-26 14:27:38 +08:00
parent 02b0a65314
commit 124843848f
58 changed files with 13083 additions and 0 deletions
@@ -0,0 +1,35 @@
---
import {getSortedPosts} from "../../../utils/content-utils";
import MainGridLayout from "../../../layouts/MainGridLayout.astro";
import ArchivePanel from "../../../components/ArchivePanel.astro";
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>
<ArchivePanel categories={[category]}></ArchivePanel>
</MainGridLayout>
+10
View File
@@ -0,0 +1,10 @@
---
import { getCollection, getEntry } from "astro:content";
import MainGridLayout from "../../layouts/MainGridLayout.astro";
import ArchivePanel from "../../components/ArchivePanel.astro";
---
<MainGridLayout>
<ArchivePanel></ArchivePanel>
</MainGridLayout>
+34
View File
@@ -0,0 +1,34 @@
---
import {getSortedPosts} from "../../../utils/content-utils";
import MainGridLayout from "../../../layouts/MainGridLayout.astro";
import ArchivePanel from "../../../components/ArchivePanel.astro";
export async function getStaticPaths() {
let posts = await getSortedPosts()
const allTags = posts.reduce((acc, post) => {
post.data.tags.forEach(tag => acc.add(tag));
return acc;
}, new Set());
const allTagsArray = Array.from(allTags);
return allTagsArray.map(tag => {
return {
params: {
tag: tag
}
}
});
}
const { tag } = Astro.params;
---
<MainGridLayout>
<ArchivePanel tags={[tag]}></ArchivePanel>
</MainGridLayout>