wip(org): Work on new site
This commit is contained in:
parent
fa42e8e142
commit
623e28c675
7 changed files with 100 additions and 8 deletions
|
@ -9,6 +9,18 @@ import remarkFrontmatterExtractor from 'remark-extract-frontmatter'
|
|||
import { readSync } from 'to-vfile'
|
||||
import yaml from 'js-yaml'
|
||||
|
||||
/*
|
||||
* There's an issue in crowdin where it changes the frontmatter marker:
|
||||
* ---
|
||||
* into this:
|
||||
* - - -
|
||||
* which breaks stuff. So this method takes the input and replaces all
|
||||
* - - - with ---
|
||||
*/
|
||||
const fixCrowdinBugs = md => {
|
||||
md.value = md.value.split("- - -\n").join("---\n")
|
||||
return md
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper method to get a list of MDX files in a folder.
|
||||
|
@ -62,12 +74,11 @@ const mdxMetaInfo = async file => {
|
|||
let result
|
||||
try {
|
||||
result = await unified()
|
||||
//.use(remarkMdx)
|
||||
.use(remarkParser)
|
||||
.use(remarkCompiler)
|
||||
.use(remarkFrontmatter)
|
||||
.use(remarkFrontmatterExtractor, { yaml: yaml.load })
|
||||
.process(readSync(file))
|
||||
.process(fixCrowdinBugs(readSync(file, { encoding: 'utf-8' })))
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err)
|
||||
|
@ -112,8 +123,13 @@ export const prebuildMdx = async(site) => {
|
|||
: meta.data.title
|
||||
}
|
||||
} else {
|
||||
console.log(`[${lang}] Failed to extract meta info from: ${slug}`)
|
||||
if (meta.messages.length > 0) console.log(meta.messages)
|
||||
if (pages.en[slug]) {
|
||||
console.log(`⚠️l Falling back to EN metadata for ${slug}`)
|
||||
pages[lang][slug] = pages.en[slug]
|
||||
} else {
|
||||
console.log(`❌ [${lang}] Failed to extract meta info from: ${slug}`)
|
||||
if (meta.messages.length > 0) console.log(meta.messages)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,6 +80,7 @@ export const prebuildStrapi = async(site) => {
|
|||
posts[lang][type] = await getPosts(type, site, lang)
|
||||
// Extract list of authors
|
||||
for (const [slug, post] of Object.entries(posts[lang][type])) {
|
||||
if (!post.author?.slug) console.log(post)
|
||||
authors[type][post.author.slug] = post.author
|
||||
posts[lang][type][slug].author = post.author.slug
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue