diff --git a/config/filters.js b/config/filters.js index 47a5b5be..ec6b0ecf 100644 --- a/config/filters.js +++ b/config/filters.js @@ -57,4 +57,16 @@ module.exports = { return data }, + pageNumberOf: (postUrl, collection, pageSize = 10) => { + const index = collection.findIndex((p) => p.data.page.url === postUrl) + if (index === -1) throw new Error(`${postUrl} not found in collection`) + return Math.ceil(collection.length / pageSize) - Math.ceil(index / pageSize) + }, + blogBackLink: (postUrl, collection, pageSize = 10) => { + const index = collection.findIndex((p) => p.data.page.url === postUrl) + if (index === -1) throw new Error(`${postUrl} not found in collection`) + const pageNumber = Math.ceil(collection.length / pageSize) - Math.ceil(index / pageSize) + if (pageNumber === 0) return '/' + return `/${pageNumber}/` + }, } diff --git a/src/_includes/post-tags.liquid b/src/_includes/post-tags.liquid new file mode 100644 index 00000000..d55522d7 --- /dev/null +++ b/src/_includes/post-tags.liquid @@ -0,0 +1,9 @@ +