better page listing

This commit is contained in:
koehr 2023-12-07 10:59:27 +01:00 committed by Norman Köhring
parent 17d5fd25e5
commit c470fe9c5e
5 changed files with 26 additions and 14 deletions

View file

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

View file

@ -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) {

9
cv.md
View file

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

1
cv.md Symbolic link
View file

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

View file

@ -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.

9
resume.md Normal file
View file

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