added sorting to pages

This commit is contained in:
mx 2021-07-19 19:55:59 +02:00
parent df648d0007
commit d1f4e6fef5
4 changed files with 44 additions and 25 deletions

View File

@ -2,7 +2,25 @@ module.exports = (config) => {
// add collection for pages
config.addCollection('pages', (collection) => {
return collection.getFilteredByGlob("**/*.md");
let sorted = []
let unsorted = []
const pages = collection.getFilteredByGlob('**/*.md')
for (let page of pages) {
if (page.data.sort) {
if (sorted[page.data.sort]) {
sorted.splice(page.data.sort)
} else {
sorted[page.data.sort] = page
}
} else {
unsorted.push(page)
}
}
return sorted.concat(unsorted)
})
// custom filters

View File

@ -5,6 +5,7 @@ imgFeat: /work/images/container2mvmnts/DSC_7873.jpg
gallery:
- /work/images/container2mvmnts/DSC_7864.jpg
- /work/images/container2mvmnts/DSC_7865.jpg
sort: 2
---
<iframe width="560" height="315" style="width:100%; height: 20%;" sandbox="allow-same-origin allow-scripts allow-popups" src="https://p.eertu.be/videos/embed/8f786cb3-68f0-4f30-a144-77cc6dd82cad?warningTitle=0" frameborder="0" allowfullscreen></iframe>

View File

@ -2,7 +2,7 @@
title: stone throw
layout: page.njk
imgFeat: /work/images/stoneThrow/scanPage.png
gallery:
sort: 1
---
# stone throw