From c470fe9c5eb2b2ca2fe78566b3ba9cbc455777bf Mon Sep 17 00:00:00 2001 From: koehr Date: Thu, 7 Dec 2023 10:59:27 +0100 Subject: [PATCH] better page listing --- .vitepress/theme/titles.ts | 2 +- .vitepress/theme/useTerminal.ts | 17 ++++++++++++++--- cv.md | 10 +--------- index.md | 2 +- resume.md | 9 +++++++++ 5 files changed, 26 insertions(+), 14 deletions(-) mode change 100644 => 120000 cv.md create mode 100644 resume.md diff --git a/.vitepress/theme/titles.ts b/.vitepress/theme/titles.ts index a2846b4..1e836c5 100644 --- a/.vitepress/theme/titles.ts +++ b/.vitepress/theme/titles.ts @@ -1,5 +1,5 @@ export default { - welcome: [ + index: [ " ________ __ ", "| | | |.-----.| |.----.-----.--------.-----.", "| | | || -__|| || __| _ | | -__|", diff --git a/.vitepress/theme/useTerminal.ts b/.vitepress/theme/useTerminal.ts index 21c5fff..8f2a9b7 100644 --- a/.vitepress/theme/useTerminal.ts +++ b/.vitepress/theme/useTerminal.ts @@ -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) { diff --git a/cv.md b/cv.md deleted file mode 100644 index b334e13..0000000 --- a/cv.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: 'resume' -content: [ - 'This is my CV', - 'stuff', - 'foo', - 'bar', -] ---- diff --git a/cv.md b/cv.md new file mode 120000 index 0000000..e6c213b --- /dev/null +++ b/cv.md @@ -0,0 +1 @@ +resume.md \ No newline at end of file diff --git a/index.md b/index.md index 044b03d..5c06659 100644 --- a/index.md +++ b/index.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. diff --git a/resume.md b/resume.md new file mode 100644 index 0000000..b334e13 --- /dev/null +++ b/resume.md @@ -0,0 +1,9 @@ +--- +title: 'resume' +content: [ + 'This is my CV', + 'stuff', + 'foo', + 'bar', +] +---