mirror of
https://codeberg.org/HPCesia/AstralHalo.git
synced 2025-04-08 17:34:27 +08:00
feat: untagged archive
This commit is contained in:
parent
593566ad72
commit
1564426c1d
@ -14,7 +14,7 @@ enum I18nKey {
|
||||
|
||||
untitled = 'untitled',
|
||||
uncategorized = 'uncategorized',
|
||||
noTags = 'noTags',
|
||||
untagged = 'untagged',
|
||||
|
||||
wordCount = 'wordCount',
|
||||
wordsCount = 'wordsCount',
|
||||
|
@ -17,7 +17,7 @@ export const en: Translation = {
|
||||
|
||||
[Key.untitled]: 'Untitled',
|
||||
[Key.uncategorized]: 'Uncategorized',
|
||||
[Key.noTags]: 'No Tags',
|
||||
[Key.untagged]: 'No Tags',
|
||||
|
||||
[Key.wordCount]: 'word',
|
||||
[Key.wordsCount]: 'words',
|
||||
|
@ -17,7 +17,7 @@ export const zh_CN: Translation = {
|
||||
|
||||
[Key.untitled]: '无标题',
|
||||
[Key.uncategorized]: '未分类',
|
||||
[Key.noTags]: '无标签',
|
||||
[Key.untagged]: '无标签',
|
||||
|
||||
[Key.wordCount]: '字',
|
||||
[Key.wordsCount]: '字',
|
||||
|
@ -17,7 +17,7 @@ export const zh_TW: Translation = {
|
||||
|
||||
[Key.untitled]: '無標題',
|
||||
[Key.uncategorized]: '未分類',
|
||||
[Key.noTags]: '無標籤',
|
||||
[Key.untagged]: '無標籤',
|
||||
|
||||
[Key.wordCount]: '字',
|
||||
[Key.wordsCount]: '字',
|
||||
|
@ -4,21 +4,28 @@ import PostPage from '@components/PostPage.astro';
|
||||
import { siteConfig } from '@/config';
|
||||
import GridLayout from '@layouts/GridLayout.astro';
|
||||
import ProfileCard from '@components/widgets/ProfileCard.astro';
|
||||
import I18nKey from '@i18n/I18nKey';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getSortedPosts();
|
||||
const tags = [...new Set(posts.map((post) => post.data.tags).flat())];
|
||||
const tags = [
|
||||
...new Set(
|
||||
posts
|
||||
.map((post) => (post.data.tags.length > 0 ? post.data.tags : [I18nKey.untagged]))
|
||||
.flat()
|
||||
),
|
||||
];
|
||||
return tags
|
||||
.map((tag) => {
|
||||
const tagPosts = posts.filter((post) => post.data.tags.includes(tag));
|
||||
const tagPosts =
|
||||
tag === I18nKey.untagged
|
||||
? posts.filter((post) => post.data.tags.length === 0)
|
||||
: posts.filter((post) => post.data.tags.includes(tag));
|
||||
const pageNum = Math.ceil(tagPosts.length / siteConfig.postsPerPage);
|
||||
tag = tag.replaceAll(/[\\/]/g, '-');
|
||||
return Array.from({ length: pageNum }, (_, i) => ({
|
||||
params: { tag: tag, page: (i + 1).toString() },
|
||||
props: {
|
||||
posts: tagPosts.slice(i * siteConfig.postsPerPage, (i + 1) * siteConfig.postsPerPage),
|
||||
currentPage: i + 1,
|
||||
},
|
||||
props: { posts: tagPosts, currentPage: i + 1 },
|
||||
}));
|
||||
})
|
||||
.flat();
|
||||
|
Loading…
Reference in New Issue
Block a user