diff --git a/src/frontmatter/author.js b/src/frontmatter/author.js new file mode 100644 index 0000000..e6a9c4f --- /dev/null +++ b/src/frontmatter/author.js @@ -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]; +} diff --git a/src/frontmatter/categories.js b/src/frontmatter/categories.js index 4408ba6..0328e0f 100644 --- a/src/frontmatter/categories.js +++ b/src/frontmatter/categories.js @@ -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)); }; diff --git a/src/frontmatter/excerpt.js b/src/frontmatter/excerpt.js new file mode 100644 index 0000000..bc6310d --- /dev/null +++ b/src/frontmatter/excerpt.js @@ -0,0 +1,4 @@ +// get excerpt, not decoded, newlines collapsed +module.exports = (post) => { + return post.data.encoded[1].replace(/[\r\n]+/gm, ' '); +}; diff --git a/src/frontmatter/id.js b/src/frontmatter/id.js new file mode 100644 index 0000000..5403fc0 --- /dev/null +++ b/src/frontmatter/id.js @@ -0,0 +1,4 @@ +// get ID +module.exports = (post) => { + return post.data.post_id[0]; +} diff --git a/src/frontmatter/tags.js b/src/frontmatter/tags.js index 2781145..0b53fd8 100644 --- a/src/frontmatter/tags.js +++ b/src/frontmatter/tags.js @@ -8,5 +8,5 @@ module.exports = (post) => { .filter(category => category.$.domain === 'post_tag') .map(({ $: attributes }) => decodeURIComponent(attributes.nicename)); - return categories; + return categories; }; diff --git a/src/frontmatter/type.js b/src/frontmatter/type.js new file mode 100644 index 0000000..25bfab4 --- /dev/null +++ b/src/frontmatter/type.js @@ -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]; +}