forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpages-with-liquid-titles.js
More file actions
executable file
·31 lines (24 loc) · 884 Bytes
/
pages-with-liquid-titles.js
File metadata and controls
executable file
·31 lines (24 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/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()