diff --git a/components/BlogPostCard.js b/components/BlogPostCard.js
index 5d4eb7c8..cb2eff98 100644
--- a/components/BlogPostCard.js
+++ b/components/BlogPostCard.js
@@ -57,7 +57,7 @@ const BlogPostCard = ({ post, showSummary }) => {
/>
}
-
+
{locale.COMMON.ARTICLE_DETAIL}
diff --git a/pages/article/[slug].js b/pages/article/[slug].js
index d07466ae..6ca1254d 100644
--- a/pages/article/[slug].js
+++ b/pages/article/[slug].js
@@ -4,7 +4,7 @@ import Live2D from '@/components/Live2D'
import TocDrawer from '@/components/TocDrawer'
import TocDrawerButton from '@/components/TocDrawerButton'
import BaseLayout from '@/layouts/BaseLayout'
-import { getAllPosts, getPostBlocks } from '@/lib/notion'
+import { getPostBlocks } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
import Custom404 from '@/pages/404'
import { getPageTableOfContents } from 'notion-utils'
@@ -69,12 +69,17 @@ const Slug = ({
}
export async function getStaticPaths () {
- let posts = []
- if (BLOG.isProd) {
- posts = await getAllPosts({ from: 'slug - paths', includePage: false })
+ if (!BLOG.isProd) {
+ return {
+ paths: [],
+ fallback: true
+ }
}
+
+ const from = '[slug-paths'
+ const { allPosts } = await getGlobalNotionData({ from, includePage: false })
return {
- paths: posts.map(row => ({ params: { slug: row.slug } })),
+ paths: allPosts.map(row => ({ params: { slug: row.slug } })),
fallback: true
}
}
diff --git a/pages/tag/[tag].js b/pages/tag/[tag].js
index 60d82fa5..06a8160d 100644
--- a/pages/tag/[tag].js
+++ b/pages/tag/[tag].js
@@ -4,7 +4,6 @@ import StickyBar from '@/components/StickyBar'
import TagList from '@/components/TagList'
import BaseLayout from '@/layouts/BaseLayout'
import { useGlobal } from '@/lib/global'
-import { getAllPosts } from '@/lib/notion'
import { getGlobalNotionData } from '@/lib/notion/getNotionData'
export default function Tag ({ tags, posts, tag, categories, postCount, latestPosts }) {
@@ -56,27 +55,21 @@ export async function getStaticProps ({ params }) {
* @param {*}} allPosts
* @returns
*/
-function getTagNames (allPosts) {
- const tags = allPosts.map(p => p.tags).flat()
-
- const tagObj = {}
+function getTagNames (tags) {
+ const tagNames = []
tags.forEach(tag => {
- if (tag in tagObj) {
- tagObj[tag]++
- } else {
- tagObj[tag] = 1
- }
+ tagNames.push(tag.name)
})
- return tagObj
+ return tagNames
}
export async function getStaticPaths () {
const from = 'tag-static-path'
- const posts = await getAllPosts({ from })
- const tagNames = getTagNames(posts)
+ const { tags } = await getGlobalNotionData({ from, tagsCount: 0 })
+ const tagNames = getTagNames(tags)
return {
- paths: Object.keys(tagNames).map(tag => ({ params: { tag } })),
+ paths: Object.keys(tagNames).map(index => ({ params: { tag: tagNames[index] } })),
fallback: true
}
}