Add frontmatter security
This commit is contained in:
parent
8c41ac4f47
commit
e74b186413
10
src/index.ts
10
src/index.ts
|
|
@ -179,6 +179,16 @@ export default function ofm() {
|
||||||
}
|
}
|
||||||
|
|
||||||
tag = slugTag(tag)
|
tag = slugTag(tag)
|
||||||
|
|
||||||
|
if (!file.data)
|
||||||
|
file.data = {};
|
||||||
|
|
||||||
|
if (!file.data.frontmatter)
|
||||||
|
file.data.frontmatter = {};
|
||||||
|
|
||||||
|
if (!file.data.frontmatter.tags)
|
||||||
|
file.data.frontmatter.tags = [];
|
||||||
|
|
||||||
if (file.data.frontmatter && !file.data.frontmatter.tags.includes(tag)) {
|
if (file.data.frontmatter && !file.data.frontmatter.tags.includes(tag)) {
|
||||||
file.data.frontmatter.tags.push(tag)
|
file.data.frontmatter.tags.push(tag)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue