1
0
mirror of synced 2025-12-21 10:57:10 -05:00
Files
docs/script/pages-with-liquid-titles.js
James M. Greene fb30a0766f Unravel pages (the array + map object) (#16708)
* Revise the 'pages' module to export two methods: 'loadPages' and 'loadPageMap'

Update all existing references to use 'loadPages' for now

* Remove explicit Promise resolutions on loadPage* methods

* Condense reduction method into its now-singular usage spot

* Opt for for-of instead of forEach

* Make require of pages in warm-server more explicit

* Be more explicit about find-page using a pageMap

* Be more explicit about find-page-in-version using a pageMap

* Be more explicit about site-tree using a pageMap

* Extract the map creation from loadPageMap

* Be more explicit about using a pageMap

* Update redirects precompile to take two arguments: pageList, pageMap

* Rename internal loadPages method to loadPageList

* Clarify pageMap is what is stored in context.pages

* Use loadPageMap in tests and stuff
2020-12-03 22:31:10 +00:00

32 lines
884 B
JavaScript
Executable File

#!/usr/bin/env node
// [start-readme]
//
// This is a temporary script to visualize which pages have liquid
// (and conditionals) in their `title` frontmatter
//
// [end-readme]
const { loadPages } = require('../lib/pages')
const patterns = require('../lib/patterns')
async function main () {
const pages = await loadPages()
const liquidPages = pages
.filter(page => page.title && patterns.hasLiquid.test(page.title))
.map(({ relativePath, title }) => {
return { relativePath, title }
})
console.log(`\n\n${liquidPages.length} pages with liquid titles`)
console.log(JSON.stringify(liquidPages, null, 2))
const conditionalPages = liquidPages
.filter(page => page.title.includes('{% if'))
console.log(`\n\n\n\n${conditionalPages.length} pages with conditionals in their titles`)
console.log(JSON.stringify(conditionalPages, null, 2))
}
main()