nnbb 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +1 -0
- package/.env.local +2 -0
- package/.eslintrc.json +15 -0
- package/.github/stale.yml +16 -0
- package/.github/workflows/codeql-analysis.yml +73 -0
- package/.github/workflows/docker-ghcr.yaml +59 -0
- package/.prettierrc +9 -0
- package/.vscode/launch.json +28 -0
- package/.vscode/settings.json +6 -0
- package/Dockerfile +38 -0
- package/LICENSE +21 -0
- package/README.md +16 -0
- package/blog.config.js +454 -0
- package/components/Ackee.js +83 -0
- package/components/AdBlockDetect.js +40 -0
- package/components/AlgoliaSearchModal.js +250 -0
- package/components/Artalk.js +30 -0
- package/components/Busuanzi.js +26 -0
- package/components/ChatBase.js +19 -0
- package/components/Collapse.tsx +134 -0
- package/components/Comment.js +161 -0
- package/components/CommonHead.tsx +101 -0
- package/components/CommonScript.js +125 -0
- package/components/CusdisComponent.js +35 -0
- package/components/CustomContextMenu.js +221 -0
- package/components/DebugPanel.js +134 -0
- package/components/DisableCopy.js +21 -0
- package/components/Draggable.js +167 -0
- package/components/Equation.js +31 -0
- package/components/ExternalPlugins.js +75 -0
- package/components/ExternalScript.js +29 -0
- package/components/FacebookMessenger.js +255 -0
- package/components/FacebookPage.js +34 -0
- package/components/Fireworks.js +210 -0
- package/components/FlipCard.js +56 -0
- package/components/FlutteringRibbon.js +322 -0
- package/components/FullScreenButton.js +48 -0
- package/components/Giscus.js +33 -0
- package/components/Gitalk.js +42 -0
- package/components/GoogleAdsense.js +111 -0
- package/components/Gtag.js +18 -0
- package/components/HeroIcons.tsx +321 -0
- package/components/KatexReact.js +53 -0
- package/components/LazyImage.js +95 -0
- package/components/Live2D.js +52 -0
- package/components/Loading.js +20 -0
- package/components/Mark.js +28 -0
- package/components/NProgress.ts +8 -0
- package/components/Nest.js +124 -0
- package/components/NotionIcon.js +20 -0
- package/components/NotionPage.tsx +206 -0
- package/components/Player.js +54 -0
- package/components/PrismMac.js +236 -0
- package/components/QrCode.js +34 -0
- package/components/Ribbon.js +98 -0
- package/components/Sakura.js +192 -0
- package/components/Select.js +40 -0
- package/components/ShareBar.js +29 -0
- package/components/ShareButtons.js +403 -0
- package/components/SideBarDrawer.js +50 -0
- package/components/StarrySky.js +130 -0
- package/components/Tabs.js +64 -0
- package/components/ThemeSwitch.js +67 -0
- package/components/Twikoo.js +27 -0
- package/components/TwikooCommentCount.js +22 -0
- package/components/TwikooCommentCounter.js +78 -0
- package/components/TwikooRecentComments.js +11 -0
- package/components/Utterances.js +35 -0
- package/components/VConsole.js +76 -0
- package/components/ValineComponent.js +59 -0
- package/components/ValineCount.js +6 -0
- package/components/ValinePanel.js +3 -0
- package/components/Vercel.tsx +54 -0
- package/components/WWAds.js +18 -0
- package/components/WalineComponent.js +83 -0
- package/components/WebMention.js +173 -0
- package/components/Webwhiz.js +17 -0
- package/components/WordCount.js +73 -0
- package/hooks/useToggleClickOutSide.ts +32 -0
- package/hooks/useWindowSize.ts +30 -0
- package/lib/algolia.js +108 -0
- package/lib/busuanzi.js +99 -0
- package/lib/cache/cacheManager.ts +49 -0
- package/lib/cache/localFileCache.ts +56 -0
- package/lib/cache/memoryMache.ts +20 -0
- package/lib/cache/mongoDbCache.ts +70 -0
- package/lib/cache/types.ts +5 -0
- package/lib/font.js +46 -0
- package/lib/global.tsx +129 -0
- package/lib/gtag.js +17 -0
- package/lib/mailchimp.js +49 -0
- package/lib/memorize.js +0 -0
- package/lib/mhchem.js +1696 -0
- package/lib/notion/getAllCategories.ts +51 -0
- package/lib/notion/getAllPageIds.ts +51 -0
- package/lib/notion/getAllPosts.js +68 -0
- package/lib/notion/getAllTags.ts +43 -0
- package/lib/notion/getNotionData.ts +340 -0
- package/lib/notion/getPageInfoOfPostPage.ts +58 -0
- package/lib/notion/getPageProperties.ts +203 -0
- package/lib/notion/getPageTableOfContents.ts +107 -0
- package/lib/notion/getPostBlocks.ts +147 -0
- package/lib/notion/mapImage.ts +130 -0
- package/lib/notion/types.ts +125 -0
- package/lib/notion.js +2 -0
- package/lib/robots.txt.js +25 -0
- package/lib/rss.js +63 -0
- package/lib/sitemap.xml.js +67 -0
- package/lib/utils.js +212 -0
- package/next-env.d.ts +5 -0
- package/next-i18next.config.js +7 -0
- package/next-sitemap.config.js +11 -0
- package/next.config.js +124 -0
- package/package.json +92 -0
- package/pages/404.tsx +40 -0
- package/pages/[prefix]/[slug].tsx +123 -0
- package/pages/[prefix]/index.tsx +223 -0
- package/pages/_app.js +59 -0
- package/pages/_document.js +42 -0
- package/pages/api/subscribe.js +22 -0
- package/pages/archive/index.tsx +79 -0
- package/pages/category/[category]/index.tsx +87 -0
- package/pages/category/[category]/page/[page].tsx +103 -0
- package/pages/category/index.tsx +43 -0
- package/pages/index.tsx +88 -0
- package/pages/page/[page].tsx +93 -0
- package/pages/search/[keyword]/index.tsx +162 -0
- package/pages/search/[keyword]/page/[page].tsx +166 -0
- package/pages/search/index.tsx +69 -0
- package/pages/sitemap.xml.js +70 -0
- package/pages/tag/[tag]/index.tsx +73 -0
- package/pages/tag/[tag]/page/[page].tsx +87 -0
- package/pages/tag/index.tsx +42 -0
- package/postcss.config.js +6 -0
- package/public/ads.txt +1 -0
- package/public/avatar.png +0 -0
- package/public/avatar.svg +11 -0
- package/public/bg_image.jpg +0 -0
- package/public/css/all.min.css +9 -0
- package/public/css/custom.css +8 -0
- package/public/css/img-shadow.css +5 -0
- package/public/css/prism-mac-style.css +58 -0
- package/public/favicon.ico +0 -0
- package/public/favicon.svg +9 -0
- package/public/js/cusdis.es.js +107 -0
- package/public/js/custom.js +1 -0
- package/public/locales/en/common.json +44 -0
- package/public/locales/en/menu.json +9 -0
- package/public/locales/en/nav.json +11 -0
- package/public/locales/zh-CN/common.json +44 -0
- package/public/locales/zh-CN/menu.json +9 -0
- package/public/locales/zh-CN/nav.json +9 -0
- package/public/webfonts/fa-brands-400.ttf +0 -0
- package/public/webfonts/fa-brands-400.woff2 +0 -0
- package/public/webfonts/fa-regular-400.ttf +0 -0
- package/public/webfonts/fa-regular-400.woff2 +0 -0
- package/public/webfonts/fa-solid-900.ttf +0 -0
- package/public/webfonts/fa-solid-900.woff2 +0 -0
- package/public/webfonts/fa-v4compatibility.ttf +0 -0
- package/public/webfonts/fa-v4compatibility.woff2 +0 -0
- package/styles/animate.css +503 -0
- package/styles/globals.css +183 -0
- package/styles/notion.css +2064 -0
- package/styles/nprogress.css +84 -0
- package/styles/prism-theme.css +119 -0
- package/styles/utility-patterns.css +79 -0
- package/tailwind.config.js +37 -0
- package/theme/index.ts +6 -0
- package/theme/types/@theme-components.d.ts +29 -0
- package/theme/useLayout.ts +41 -0
- package/theme/utils.ts +108 -0
- package/themes/innocent/package.json +7 -0
- package/themes/innocent/theme.config.js +1 -0
- package/themes/nobelium/components/Announcement.tsx +27 -0
- package/themes/nobelium/components/ArticleFooter.tsx +39 -0
- package/themes/nobelium/components/ArticleInfo.tsx +58 -0
- package/themes/nobelium/components/ArticleLock.tsx +86 -0
- package/themes/nobelium/components/BlogArchiveItem.js +41 -0
- package/themes/nobelium/components/BlogListBar.js +39 -0
- package/themes/nobelium/components/BlogListPage.tsx +67 -0
- package/themes/nobelium/components/BlogListScroll.tsx +96 -0
- package/themes/nobelium/components/BlogPost.tsx +33 -0
- package/themes/nobelium/components/DarkModeButton.tsx +50 -0
- package/themes/nobelium/components/ExampleRecentComments.js +35 -0
- package/themes/nobelium/components/Footer.tsx +35 -0
- package/themes/nobelium/components/JumpToTopButton.tsx +39 -0
- package/themes/nobelium/components/LanguageSwitchButton.tsx +58 -0
- package/themes/nobelium/components/MenuItemCollapse.tsx +92 -0
- package/themes/nobelium/components/MenuItemDrop.tsx +83 -0
- package/themes/nobelium/components/Nav/Nav.module.css +50 -0
- package/themes/nobelium/components/Nav/Nav.tsx +187 -0
- package/themes/nobelium/components/RandomPostButton.tsx +31 -0
- package/themes/nobelium/components/SearchButton.tsx +31 -0
- package/themes/nobelium/components/SearchInput.tsx +94 -0
- package/themes/nobelium/components/SearchNavBar.js +19 -0
- package/themes/nobelium/components/SideBar.js +83 -0
- package/themes/nobelium/components/SvgIcon.js +29 -0
- package/themes/nobelium/components/TagItem.js +13 -0
- package/themes/nobelium/components/Tags.tsx +44 -0
- package/themes/nobelium/components/Title.js +19 -0
- package/themes/nobelium/index.tsx +28 -0
- package/themes/nobelium/layout/LayoutBase.tsx +79 -0
- package/themes/nobelium/pages/Archive.tsx +30 -0
- package/themes/nobelium/pages/Category.tsx +43 -0
- package/themes/nobelium/pages/Home.tsx +22 -0
- package/themes/nobelium/pages/PageNotFound.tsx +15 -0
- package/themes/nobelium/pages/Post.tsx +34 -0
- package/themes/nobelium/pages/PostList.tsx +74 -0
- package/themes/nobelium/pages/Search.tsx +65 -0
- package/themes/nobelium/pages/Tag.tsx +42 -0
- package/themes/nobelium/providers/index.tsx +60 -0
- package/themes/nobelium/stores/index.tsx +42 -0
- package/themes/nobelium/theme.config.ts +17 -0
- package/themes/nobelium/types/index.ts +10 -0
- package/tsconfig.json +29 -0
- package/types/index.ts +1 -0
- package/types/page.ts +102 -0
- package/vercel.json +5 -0
@@ -0,0 +1,69 @@
|
|
1
|
+
import { getGlobalData } from '@/lib/notion/getNotionData';
|
2
|
+
import { useRouter } from 'next/router';
|
3
|
+
import BLOG from '@/blog.config';
|
4
|
+
import { useLayout } from '@/theme';
|
5
|
+
import { useTranslation } from 'next-i18next';
|
6
|
+
|
7
|
+
import type { FC } from 'react';
|
8
|
+
import type { PageMeta, SearchIndexProps, ThemeSearchProps } from '@/types';
|
9
|
+
import type { GetStaticProps } from 'next';
|
10
|
+
|
11
|
+
/**
|
12
|
+
* 搜索路由
|
13
|
+
* @param {*} props
|
14
|
+
* @returns
|
15
|
+
*/
|
16
|
+
const SearchIndex: FC<SearchIndexProps> = (props) => {
|
17
|
+
const { posts, siteInfo } = props;
|
18
|
+
const { t } = useTranslation('nav');
|
19
|
+
const router = useRouter();
|
20
|
+
const keyword = router.query.s ? String(router.query.s) : '';
|
21
|
+
|
22
|
+
// 根据页面路径加载不同Layout文件
|
23
|
+
const Layout = useLayout() as FC<ThemeSearchProps>;
|
24
|
+
|
25
|
+
const filteredPosts = keyword
|
26
|
+
? posts.filter((post) => {
|
27
|
+
const tagContent = post?.tags ? post.tags.join(' ') : '';
|
28
|
+
const searchContent =
|
29
|
+
post.title + post.summary + tagContent + post.category;
|
30
|
+
return searchContent.toLowerCase().includes(keyword.toLowerCase());
|
31
|
+
})
|
32
|
+
: [];
|
33
|
+
|
34
|
+
const pageMeta: PageMeta = {
|
35
|
+
title: `${keyword || ''}${keyword ? ' | ' : ''}${t('search')} | ${siteInfo?.title}`,
|
36
|
+
description: siteInfo?.description,
|
37
|
+
image: siteInfo?.pageCover,
|
38
|
+
slug: 'search',
|
39
|
+
type: 'website',
|
40
|
+
};
|
41
|
+
|
42
|
+
return (
|
43
|
+
<Layout
|
44
|
+
{...props}
|
45
|
+
pageMeta={pageMeta}
|
46
|
+
posts={filteredPosts}
|
47
|
+
keyword={keyword}
|
48
|
+
/>
|
49
|
+
);
|
50
|
+
};
|
51
|
+
|
52
|
+
/**
|
53
|
+
* 浏览器前端搜索
|
54
|
+
*/
|
55
|
+
export const getStaticProps: GetStaticProps<SearchIndexProps> = async () => {
|
56
|
+
const { allPages, ...restProps } = await getGlobalData('search-props');
|
57
|
+
const posts = allPages?.filter(
|
58
|
+
(page) => page.type === 'Post' && page.status === 'Published',
|
59
|
+
);
|
60
|
+
return {
|
61
|
+
props: {
|
62
|
+
...restProps,
|
63
|
+
posts,
|
64
|
+
},
|
65
|
+
revalidate: BLOG.NEXT_REVALIDATE_SECOND,
|
66
|
+
};
|
67
|
+
};
|
68
|
+
|
69
|
+
export default SearchIndex;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
// pages/sitemap.xml.js
|
2
|
+
import { getServerSideSitemap } from 'next-sitemap';
|
3
|
+
import { getGlobalData } from '@/lib/notion/getNotionData';
|
4
|
+
import BLOG from '@/blog.config';
|
5
|
+
|
6
|
+
export const getServerSideProps = async (ctx) => {
|
7
|
+
const { allPages } = await getGlobalData('rss');
|
8
|
+
const defaultFields = [
|
9
|
+
{
|
10
|
+
loc: `${BLOG.LINK}`,
|
11
|
+
lastmod: new Date().toISOString().split('T')[0],
|
12
|
+
changefreq: 'daily',
|
13
|
+
priority: '0.7',
|
14
|
+
},
|
15
|
+
{
|
16
|
+
loc: `${BLOG.LINK}/archive`,
|
17
|
+
lastmod: new Date().toISOString().split('T')[0],
|
18
|
+
changefreq: 'daily',
|
19
|
+
priority: '0.7',
|
20
|
+
},
|
21
|
+
{
|
22
|
+
loc: `${BLOG.LINK}/category`,
|
23
|
+
lastmod: new Date().toISOString().split('T')[0],
|
24
|
+
changefreq: 'daily',
|
25
|
+
priority: '0.7',
|
26
|
+
},
|
27
|
+
{
|
28
|
+
loc: `${BLOG.LINK}/feed`,
|
29
|
+
lastmod: new Date().toISOString().split('T')[0],
|
30
|
+
changefreq: 'daily',
|
31
|
+
priority: '0.7',
|
32
|
+
},
|
33
|
+
{
|
34
|
+
loc: `${BLOG.LINK}/search`,
|
35
|
+
lastmod: new Date().toISOString().split('T')[0],
|
36
|
+
changefreq: 'daily',
|
37
|
+
priority: '0.7',
|
38
|
+
},
|
39
|
+
{
|
40
|
+
loc: `${BLOG.LINK}/tag`,
|
41
|
+
lastmod: new Date().toISOString().split('T')[0],
|
42
|
+
changefreq: 'daily',
|
43
|
+
priority: '0.7',
|
44
|
+
},
|
45
|
+
];
|
46
|
+
const postFields = allPages
|
47
|
+
?.filter((p) => p.status === BLOG.NOTION_PROPERTY_NAME.status_publish)
|
48
|
+
?.map((post) => {
|
49
|
+
const slugWithoutLeadingSlash = post?.slug.startsWith('/')
|
50
|
+
? post?.slug?.slice(1)
|
51
|
+
: post.slug;
|
52
|
+
return {
|
53
|
+
loc: `${BLOG.LINK}/${slugWithoutLeadingSlash}`,
|
54
|
+
lastmod: new Date(post?.publishDay).toISOString().split('T')[0],
|
55
|
+
changefreq: 'daily',
|
56
|
+
priority: '0.7',
|
57
|
+
};
|
58
|
+
});
|
59
|
+
const fields = defaultFields.concat(postFields);
|
60
|
+
|
61
|
+
// 缓存
|
62
|
+
ctx.res.setHeader(
|
63
|
+
'Cache-Control',
|
64
|
+
'public, max-age=3600, stale-while-revalidate=59',
|
65
|
+
);
|
66
|
+
|
67
|
+
return getServerSideSitemap(ctx, fields);
|
68
|
+
};
|
69
|
+
|
70
|
+
export default () => {};
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { getGlobalData } from '@/lib/notion/getNotionData';
|
2
|
+
import BLOG from '@/blog.config';
|
3
|
+
import { useLayout } from '@/theme';
|
4
|
+
import { useTranslation } from 'next-i18next';
|
5
|
+
|
6
|
+
import type { FC } from 'react';
|
7
|
+
import type { PageMeta, TagDetailProps, ThemeTagDetailProps } from '@/types';
|
8
|
+
import type { ParsedUrlQuery } from 'querystring';
|
9
|
+
import type { GetStaticProps, GetStaticPaths } from 'next';
|
10
|
+
|
11
|
+
export interface TagIndexParams extends ParsedUrlQuery {
|
12
|
+
tag: string;
|
13
|
+
}
|
14
|
+
|
15
|
+
/**
|
16
|
+
* 标签下的文章列表
|
17
|
+
* @param {*} props
|
18
|
+
* @returns
|
19
|
+
*/
|
20
|
+
const TagIndex: FC<TagDetailProps> = (props) => {
|
21
|
+
const { tag, siteInfo } = props;
|
22
|
+
const { t } = useTranslation('common');
|
23
|
+
|
24
|
+
// 根据页面路径加载不同Layout文件
|
25
|
+
const Layout = useLayout() as FC<ThemeTagDetailProps>;
|
26
|
+
|
27
|
+
const pageMeta: PageMeta = {
|
28
|
+
title: `${tag} | ${t('tags')} | ${siteInfo?.title}`,
|
29
|
+
description: siteInfo?.description,
|
30
|
+
image: siteInfo?.pageCover,
|
31
|
+
slug: 'tag/' + tag,
|
32
|
+
type: 'website',
|
33
|
+
};
|
34
|
+
return <Layout pageMeta={pageMeta} {...props} />;
|
35
|
+
};
|
36
|
+
|
37
|
+
export const getStaticProps: GetStaticProps<
|
38
|
+
TagDetailProps,
|
39
|
+
TagIndexParams
|
40
|
+
> = async (context) => {
|
41
|
+
const { tag } = context.params as TagIndexParams;
|
42
|
+
const { allPages, ...globalProps } = await getGlobalData('tag-props');
|
43
|
+
|
44
|
+
const filteredPosts = allPages
|
45
|
+
?.filter((page) => page.type === 'Post' && page.status === 'Published')
|
46
|
+
.filter((post) => post && post?.tags && post?.tags.includes(tag));
|
47
|
+
|
48
|
+
const posts =
|
49
|
+
BLOG.POST_LIST_STYLE === 'page'
|
50
|
+
? filteredPosts.slice(0, BLOG.POSTS_PER_PAGE)
|
51
|
+
: filteredPosts;
|
52
|
+
|
53
|
+
return {
|
54
|
+
props: {
|
55
|
+
...globalProps,
|
56
|
+
postCount: posts.length,
|
57
|
+
tag,
|
58
|
+
posts,
|
59
|
+
},
|
60
|
+
revalidate: BLOG.NEXT_REVALIDATE_SECOND,
|
61
|
+
};
|
62
|
+
};
|
63
|
+
|
64
|
+
export const getStaticPaths: GetStaticPaths<TagIndexParams> = async () => {
|
65
|
+
const { tagOptions } = await getGlobalData('tag-static-path');
|
66
|
+
|
67
|
+
return {
|
68
|
+
paths: tagOptions.map((tag) => ({ params: { tag: tag.name } })),
|
69
|
+
fallback: true,
|
70
|
+
};
|
71
|
+
};
|
72
|
+
|
73
|
+
export default TagIndex;
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { getGlobalData } from '@/lib/notion/getNotionData';
|
2
|
+
import BLOG from '@/blog.config';
|
3
|
+
import { useLayout } from '@/theme';
|
4
|
+
import { useTranslation } from 'next-i18next';
|
5
|
+
|
6
|
+
import type { FC } from 'react';
|
7
|
+
import type { PageMeta, TagPageProps, ThemeTagPageProps } from '@/types';
|
8
|
+
import type { ParsedUrlQuery } from 'querystring';
|
9
|
+
import type { GetStaticProps, GetStaticPaths } from 'next';
|
10
|
+
|
11
|
+
export interface TagPageParams extends ParsedUrlQuery {
|
12
|
+
tag: string;
|
13
|
+
page: string;
|
14
|
+
}
|
15
|
+
|
16
|
+
const TagPage: FC<TagPageProps> = (props) => {
|
17
|
+
const { tag, siteInfo } = props;
|
18
|
+
const { t } = useTranslation('common');
|
19
|
+
|
20
|
+
// 根据页面路径加载不同Layout文件
|
21
|
+
const Layout = useLayout() as FC<ThemeTagPageProps>;
|
22
|
+
|
23
|
+
const pageMeta: PageMeta = {
|
24
|
+
title: `${tag} | ${t('tags')} | ${siteInfo?.title}`,
|
25
|
+
description: siteInfo?.description,
|
26
|
+
image: siteInfo?.pageCover,
|
27
|
+
slug: 'tag/' + tag,
|
28
|
+
type: 'website',
|
29
|
+
};
|
30
|
+
|
31
|
+
return <Layout pageMeta={pageMeta} {...props} />;
|
32
|
+
};
|
33
|
+
|
34
|
+
export const getStaticProps: GetStaticProps<
|
35
|
+
TagPageProps,
|
36
|
+
TagPageParams
|
37
|
+
> = async (context) => {
|
38
|
+
const { tag, page } = context.params as TagPageParams;
|
39
|
+
const props = await getGlobalData('tag-page-props');
|
40
|
+
|
41
|
+
const pageNumber = parseInt(page, 10);
|
42
|
+
|
43
|
+
const posts = props.allPages
|
44
|
+
?.filter((page) => page.type === 'Post' && page.status === 'Published')
|
45
|
+
.filter((post) => post?.tags?.includes(tag));
|
46
|
+
|
47
|
+
const paginatedPosts = posts.slice(
|
48
|
+
BLOG.POSTS_PER_PAGE * (pageNumber - 1),
|
49
|
+
BLOG.POSTS_PER_PAGE * pageNumber,
|
50
|
+
);
|
51
|
+
|
52
|
+
return {
|
53
|
+
props: {
|
54
|
+
...props,
|
55
|
+
posts: paginatedPosts,
|
56
|
+
postCount: posts.length,
|
57
|
+
tag,
|
58
|
+
page: pageNumber,
|
59
|
+
},
|
60
|
+
revalidate: BLOG.NEXT_REVALIDATE_SECOND,
|
61
|
+
};
|
62
|
+
};
|
63
|
+
|
64
|
+
export const getStaticPaths: GetStaticPaths<TagPageParams> = async () => {
|
65
|
+
const { tagOptions, allPages } = await getGlobalData('tag-page-static-path');
|
66
|
+
const paths: {
|
67
|
+
params: TagPageParams;
|
68
|
+
}[] = [];
|
69
|
+
tagOptions?.forEach((tag) => {
|
70
|
+
const tagPosts = allPages
|
71
|
+
.filter((page) => page.type === 'Post' && page.status === 'Published')
|
72
|
+
.filter((post) => post?.tags?.includes(tag.name)); // 过滤包含标签的文章
|
73
|
+
|
74
|
+
const totalPages = Math.ceil(tagPosts.length / BLOG.POSTS_PER_PAGE);
|
75
|
+
|
76
|
+
// 生成每一页的路径
|
77
|
+
for (let i = 1; i <= totalPages; i++) {
|
78
|
+
paths.push({ params: { tag: tag.name, page: String(i) } });
|
79
|
+
}
|
80
|
+
});
|
81
|
+
return {
|
82
|
+
paths: paths,
|
83
|
+
fallback: true,
|
84
|
+
};
|
85
|
+
};
|
86
|
+
|
87
|
+
export default TagPage;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { getGlobalData } from '@/lib/notion/getNotionData';
|
2
|
+
import BLOG from '@/blog.config';
|
3
|
+
import { useLayout } from '@/theme';
|
4
|
+
import { useTranslation } from 'next-i18next';
|
5
|
+
import { omit } from 'lodash';
|
6
|
+
|
7
|
+
import type { FC } from 'react';
|
8
|
+
import type { PageMeta, TagIndexProps, ThemeTagProps } from '@/types';
|
9
|
+
import type { GetStaticProps } from 'next';
|
10
|
+
|
11
|
+
/**
|
12
|
+
* 标签首页
|
13
|
+
* @param {*} props
|
14
|
+
* @returns
|
15
|
+
*/
|
16
|
+
const TagIndex: FC<TagIndexProps> = (props) => {
|
17
|
+
const { siteInfo } = props;
|
18
|
+
const { t } = useTranslation('common');
|
19
|
+
|
20
|
+
// 根据页面路径加载不同Layout文件
|
21
|
+
const Layout = useLayout() as FC<ThemeTagProps>;
|
22
|
+
|
23
|
+
const pageMeta: PageMeta = {
|
24
|
+
title: `${t('tags')} | ${siteInfo?.title}`,
|
25
|
+
description: siteInfo?.description,
|
26
|
+
image: siteInfo?.pageCover,
|
27
|
+
slug: 'tag',
|
28
|
+
type: 'website',
|
29
|
+
};
|
30
|
+
|
31
|
+
return <Layout {...props} pageMeta={pageMeta} />;
|
32
|
+
};
|
33
|
+
|
34
|
+
export const getStaticProps: GetStaticProps<TagIndexProps> = async () => {
|
35
|
+
const props = await getGlobalData('tag-index-props');
|
36
|
+
return {
|
37
|
+
props: omit(props, 'allPages'),
|
38
|
+
revalidate: BLOG.NEXT_REVALIDATE_SECOND,
|
39
|
+
};
|
40
|
+
};
|
41
|
+
|
42
|
+
export default TagIndex;
|
package/public/ads.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
google.com, pub-2708419466378217, DIRECT, f08c47fec0942fa0
|
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<svg width="200" height="200" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg">
|
2
|
+
<g clip-path="url(#clip0)">
|
3
|
+
<rect width="200" height="200" fill="#111111"/>
|
4
|
+
<path d="M200.563 83.7392H169V144.594H168.092L126.765 83.7392H99.9706V200H131.534V138.918H132.215L174.223 200H200.563V83.7392Z" fill="white"/>
|
5
|
+
</g>
|
6
|
+
<defs>
|
7
|
+
<clipPath id="clip0">
|
8
|
+
<rect width="200" height="200" fill="white"/>
|
9
|
+
</clipPath>
|
10
|
+
</defs>
|
11
|
+
</svg>
|
Binary file
|