chore: sync with v0.3.4

This commit is contained in:
Timothy Lin
2021-05-29 17:52:13 +08:00
11 changed files with 194 additions and 143 deletions

View File

@ -42,8 +42,8 @@ export function dateSortDesc(a, b) {
}
export async function getFileBySlug(type, slug) {
const mdxPath = path.join(root, 'data', type, `${slug.join('/')}.mdx`)
const mdPath = path.join(root, 'data', type, `${slug.join('/')}.md`)
const mdxPath = path.join(root, 'data', type, `${slug}.mdx`)
const mdPath = path.join(root, 'data', type, `${slug}.md`)
const source = fs.existsSync(mdxPath)
? fs.readFileSync(mdxPath, 'utf8')
: fs.readFileSync(mdPath, 'utf8')
@ -80,7 +80,6 @@ export async function getFileBySlug(type, slug) {
return {
mdxSource,
frontMatter: {
wordCount: content.split(/\s+/gu).length,
readingTime: readingTime(content),
slug: slug || null,
fileName: fs.existsSync(mdxPath) ? `${slug}.mdx` : `${slug}.md`,