better page listing

Norman Köhring 5 months ago
parent bf66ea6275
commit c5bc7cd4d8

@ -1,5 +1,5 @@
export default {
welcome: [
index: [
" ________ __ ",
"| | | |.-----.| |.----.-----.--------.-----.",
"| | | || -__|| || __| _ | | -__|",

@ -113,10 +113,21 @@ export default function useTerminal(inputEl: HTMLTextAreaElement, commands: Simp
setFooter(userCommand.uris)
}
const specialPages = ['README', 'not_found']
const knownPages = []
function fillKnownPages() {
pages.forEach(p => {
const title = p.frontmatter.title
if (!title?.length || specialPages.includes(title)) return
if (knownPages.includes(title)) return // no duplicates, please
knownPages.push(title)
})
}
function listPages() {
const specialPages = ['README', 'not_found']
const pageTitles = pages.map(p => p.frontmatter.title).filter(t => t?.length && !specialPages.includes(t))
addLine(`Following pages are available:\n\n${pageTitles.join('\n')}\n\nUse the go command to switch pages.`)
if (knownPages.length === 0) fillKnownPages()
addLine(`Following pages are available:\n\n${knownPages.join('\n')}\n\nUse the go command to switch pages.`)
}
async function openPage(page: string) {

@ -1,9 +0,0 @@
---
title: 'resume'
content: [
'This is my CV',
'stuff',
'foo',
'bar',
]
---

@ -0,0 +1 @@
resume.md

@ -1,5 +1,5 @@
---
title: 'welcome'
title: 'index'
---
This is the homepage of Norman Köhring,
a programmer, OpenSource enthusiast and hacker based in Berlin, Germany.

@ -0,0 +1,9 @@
---
title: 'resume'
content: [
'This is my CV',
'stuff',
'foo',
'bar',
]
---
Loading…
Cancel
Save