Merge pull request #112 from lonekorean/new-frontmatter-getters

New frontmatter getters
This commit is contained in:
Will Boyd
2024-02-26 14:35:11 -05:00
committed by GitHub
6 changed files with 20 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
// get author, without decoding
// WordPress doesn't allow funky characters in usernames anyway
module.exports = (post) => {
return post.data.creator[0];
}
+1 -1
View File
@@ -10,5 +10,5 @@ module.exports = (post) => {
.filter(category => category.$.domain === 'category')
.map(({ $: attributes }) => decodeURIComponent(attributes.nicename));
return categories.filter(category => !settings.filter_categories.includes(category));
return categories.filter(category => !settings.filter_categories.includes(category));
};
+4
View File
@@ -0,0 +1,4 @@
// get excerpt, not decoded, newlines collapsed
module.exports = (post) => {
return post.data.encoded[1].replace(/[\r\n]+/gm, ' ');
};
+4
View File
@@ -0,0 +1,4 @@
// get ID
module.exports = (post) => {
return post.data.post_id[0];
}
+1 -1
View File
@@ -8,5 +8,5 @@ module.exports = (post) => {
.filter(category => category.$.domain === 'post_tag')
.map(({ $: attributes }) => decodeURIComponent(attributes.nicename));
return categories;
return categories;
};
+5
View File
@@ -0,0 +1,5 @@
// get type, often this will always be "post"
// but can also be "page" or other custom types
module.exports = (post) => {
return post.data.post_type[0];
}