diff --git a/pages/blog/page/[page].js b/pages/blog/page/[page].js index 6c9b7772..cca324c6 100644 --- a/pages/blog/page/[page].js +++ b/pages/blog/page/[page].js @@ -2,7 +2,8 @@ import { PageSEO } from '@/components/SEO' import siteMetadata from '@/data/siteMetadata' import { getAllFilesFrontMatter } from '@/lib/mdx' import ListLayout from '@/layouts/ListLayout' -import { POSTS_PER_PAGE } from '../../blog' + +const POSTS_PER_PAGE = 5 export async function getStaticPaths() { const totalPosts = await getAllFilesFrontMatter('blog') diff --git a/pages/tags/[tag].js b/pages/tags/[tag].js deleted file mode 100644 index d6474fde..00000000 --- a/pages/tags/[tag].js +++ /dev/null @@ -1,55 +0,0 @@ -import { TagSEO } from '@/components/SEO' -import siteMetadata from '@/data/siteMetadata' -import ListLayout from '@/layouts/ListLayout' -import generateRss from '@/lib/generate-rss' -import { getAllFilesFrontMatter } from '@/lib/mdx' -import { getAllTags } from '@/lib/tags' -import kebabCase from '@/lib/utils/kebabCase' -import fs from 'fs' -import path from 'path' - -const root = process.cwd() - -export async function getStaticPaths() { - const tags = await getAllTags('blog') - - return { - paths: Object.keys(tags).map((tag) => ({ - params: { - tag, - }, - })), - fallback: false, - } -} - -export async function getStaticProps({ params }) { - const allPosts = await getAllFilesFrontMatter('blog') - const filteredPosts = allPosts.filter( - (post) => post.draft !== true && post.tags.map((t) => kebabCase(t)).includes(params.tag) - ) - - // rss - if (filteredPosts.length > 0) { - const rss = generateRss(filteredPosts, `tags/${params.tag}/feed.xml`) - const rssPath = path.join(root, 'public', 'tags', params.tag) - fs.mkdirSync(rssPath, { recursive: true }) - fs.writeFileSync(path.join(rssPath, 'feed.xml'), rss) - } - - return { props: { posts: filteredPosts, tag: params.tag } } -} - -export default function Tag({ posts, tag }) { - // Capitalize first letter and convert space to dash - const title = tag[0].toUpperCase() + tag.split(' ').join('-').slice(1) - return ( - <> - - - - ) -}