Small frontmatter getter refactor, more questions

This commit is contained in:
Will Boyd
2025-02-01 15:10:45 -05:00
parent f6197d1d70
commit 3bbf0274ce
5 changed files with 26 additions and 16 deletions
+2 -2
View File
@@ -168,12 +168,12 @@ function populateFrontmatter(posts, config) {
config.frontmatterFields.forEach(field => {
const [key, alias] = field.split(':');
let frontmatterGetter = frontmatter['get' + key.replace(/^./, (match) => match.toUpperCase())];
let frontmatterGetter = frontmatter[key];
if (!frontmatterGetter) {
throw `Could not find a frontmatter getter named "${key}".`;
}
post.frontmatter[alias || key] = frontmatterGetter(post);
post.frontmatter[alias || key] = frontmatterGetter(post, config);
});
});
}