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