upstream #1
@ -42,8 +42,8 @@ export function dateSortDesc(a, b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getFileBySlug(type, slug) {
|
export async function getFileBySlug(type, slug) {
|
||||||
const mdxPath = path.join(root, 'data', type, `${slug.join('/')}.mdx`)
|
const mdxPath = path.join(root, 'data', type, `${slug}.mdx`)
|
||||||
const mdPath = path.join(root, 'data', type, `${slug.join('/')}.md`)
|
const mdPath = path.join(root, 'data', type, `${slug}.md`)
|
||||||
const source = fs.existsSync(mdxPath)
|
const source = fs.existsSync(mdxPath)
|
||||||
? fs.readFileSync(mdxPath, 'utf8')
|
? fs.readFileSync(mdxPath, 'utf8')
|
||||||
: fs.readFileSync(mdPath, 'utf8')
|
: fs.readFileSync(mdPath, 'utf8')
|
||||||
|
@ -23,7 +23,7 @@ export async function getStaticProps({ params }) {
|
|||||||
const postIndex = allPosts.findIndex((post) => formatSlug(post.slug) === params.slug.join('/'))
|
const postIndex = allPosts.findIndex((post) => formatSlug(post.slug) === params.slug.join('/'))
|
||||||
const prev = allPosts[postIndex + 1] || null
|
const prev = allPosts[postIndex + 1] || null
|
||||||
const next = allPosts[postIndex - 1] || null
|
const next = allPosts[postIndex - 1] || null
|
||||||
const post = await getFileBySlug('blog', params.slug)
|
const post = await getFileBySlug('blog', params.slug.join('/'))
|
||||||
|
|
||||||
// rss
|
// rss
|
||||||
const rss = generateRss(allPosts)
|
const rss = generateRss(allPosts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user