added possiblity of having root pages in _content
This commit is contained in:
parent
c972daa4cf
commit
886c27d7e4
14
.eleventy.js
14
.eleventy.js
|
@ -36,7 +36,7 @@ module.exports = (config) => {
|
|||
|
||||
// add collection for pages
|
||||
config.addCollection('categories', (collection) => {
|
||||
// let categories = collection.getFilteredByGlob('**')
|
||||
|
||||
let categories = fs.readdirSync('_content')
|
||||
categories = categories.filter(c => !c.match(/\.[^/.]{1,4}$/i))
|
||||
|
||||
|
@ -64,7 +64,17 @@ module.exports = (config) => {
|
|||
_cat[cat] = sorted.concat(unsorted)
|
||||
})
|
||||
|
||||
return _cat
|
||||
let _p = collection.getFilteredByGlob('_content/*.md')
|
||||
let pages = {}
|
||||
// _cat = { ..._cat, ...pages }
|
||||
|
||||
_p.forEach(p => {
|
||||
if (p.data.title != 'index') {
|
||||
pages[p.data.title] = p
|
||||
}
|
||||
})
|
||||
|
||||
return { ..._cat, ...pages }
|
||||
})
|
||||
|
||||
// custom filters
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
const fs = require('fs/promises')
|
||||
const eleventyPackage = require('@11ty/eleventy/package.json')
|
||||
|
||||
module.exports = async () => {
|
||||
|
|
|
@ -28,6 +28,8 @@ class NavPrimary extends HTMLElement {
|
|||
const category = n.attributes.getNamedItem('category')
|
||||
const link = n.attributes.getNamedItem('link')
|
||||
|
||||
console.log(link)
|
||||
|
||||
if (link) {
|
||||
history.pushState({}, '', link.value)
|
||||
location.pathname = link.value
|
||||
|
|
|
@ -1,18 +1,23 @@
|
|||
<nav id="primary">
|
||||
<nav-link link="/" data-name="<~"><~</nav-link>
|
||||
<div class="pagelinks">
|
||||
<nav-link webc:for="c in categories" :category="c" :data-name="c"></nav-link>
|
||||
<template webc:for="(c,v) in categories" webc:nokeep>
|
||||
<nav-link webc:if="v.page" :link="v.page.url" :data-name="v.data.title"></nav-link>
|
||||
<nav-link webc:else :category="c" :data-name="c"></nav-link>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<button class="audioToggle"></button>
|
||||
</nav>
|
||||
|
||||
<nav id="sub" slot="subnav">
|
||||
<ul webc:for="(c, pages) in categories" :data-name="c">
|
||||
<li webc:for="p of pages">
|
||||
<a :href="p.url" @text="p.data.title || p.fileSlug"></a>
|
||||
</li>
|
||||
</ul>
|
||||
<template webc:for="(c, v) in categories" webc:nokeep>
|
||||
<ul webc:if="v.length > 0" :data-name="c">
|
||||
<li webc:for="p of v">
|
||||
<a :href="p.url" @text="p.data.title || p.fileSlug"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</template>
|
||||
</nav>
|
||||
|
||||
<section id="menuItem" style="">
|
||||
|
|
Loading…
Reference in New Issue