fix(andreknie.de): normalize SEO metadata and document structure
This commit is contained in:
@@ -25,7 +25,7 @@ function readContentDir(subdir) {
|
||||
return {
|
||||
...data,
|
||||
slug,
|
||||
body: marked(content),
|
||||
body: renderMarkdownContent(content),
|
||||
_source: `${subdir}/${filename}`
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,18 @@ function readContentDir(subdir) {
|
||||
.filter(Boolean)
|
||||
}
|
||||
|
||||
export function renderMarkdownContent(content) {
|
||||
const tokens = marked.lexer(content)
|
||||
const firstContentToken = tokens.findIndex(token => token.type !== 'space')
|
||||
const firstToken = tokens[firstContentToken]
|
||||
|
||||
if (firstToken?.type === 'heading' && firstToken.depth === 1) {
|
||||
tokens.splice(firstContentToken, 1)
|
||||
}
|
||||
|
||||
return marked.parser(tokens)
|
||||
}
|
||||
|
||||
function readMetaFile(filename) {
|
||||
const filepath = join(CONTENT_DIR, 'meta', filename)
|
||||
if (!existsSync(filepath)) return null
|
||||
|
||||
Reference in New Issue
Block a user