Fix frontmatter indexing error when a tag is a number (#830)
* Fix indexing error by always treating frontmatter tags as strings * Only try escaping html in actual stringspull/832/head
parent
e7eba107c6
commit
331d526f52
|
@ -115,8 +115,18 @@ export async function extractFrontmatter(
|
|||
return undefined;
|
||||
});
|
||||
|
||||
// Strip # from tags
|
||||
data.tags = [...new Set([...tags.map((t) => t.replace(/^#/, ""))])];
|
||||
try {
|
||||
data.tags = [
|
||||
...new Set([...tags.map((t) => {
|
||||
// Always treat tags as strings
|
||||
const tagAsString = String(t);
|
||||
// Strip # from tags
|
||||
return tagAsString.replace(/^#/, "");
|
||||
})]),
|
||||
];
|
||||
} catch (e) {
|
||||
console.error("Error while processing tags", e);
|
||||
}
|
||||
|
||||
// console.log("Extracted tags", data.tags);
|
||||
// Expand property names (e.g. "foo.bar" => { foo: { bar: true } })
|
||||
|
|
|
@ -7,6 +7,10 @@ export type Tag = {
|
|||
} | string;
|
||||
|
||||
function htmlEscape(s: string): string {
|
||||
if (typeof s !== "string") {
|
||||
return s;
|
||||
}
|
||||
|
||||
s = s.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
|
|
Loading…
Reference in New Issue