import { SearchPlugin } from "vitepress-plugin-search"; import { defineConfig } from "vitepress"; import wordCounting from "word-counting"; import vueJsx from '@vitejs/plugin-vue-jsx' const fs = require("fs"); const path = require("path"); const util = require('node:util'); const exec = util.promisify(require('node:child_process').exec); const filePath = path.resolve("./Garden/logseq/config.edn"); const data = fs.readFileSync(filePath).toString(); let favorites = []; for (const match of data.matchAll(/:favorites \["([^\]]+)"\]/g)) { favorites = match[1].split("\" \"").map(page => ({ text: page, link: `/garden/${page.toLowerCase().replaceAll(' ', '-')}` })); } module.exports = { lang: "en-US", title: 'The Paper Pilot', description: 'The Paper Pilot\'s Digital Garden', // Solves content sometimes not updating correctly when navigating between links, // but at the cost of local search, the "on this page" section, etc. // mpa: true, appearance: false, vite: { ssr: { noExternal: [ '@nolebase/vitepress-plugin-highlight-targeted-heading' ] }, plugins: [vueJsx()] }, sitemap: { hostname: 'https://thepaperpilot.org' }, head: [ ['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }], ['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Itim&family=Roboto+Mono:ital,wght@0,400;0,600;1,400&display=block' }], ['link', { rel: 'manifest', href: '/site.webmanifest' }], ['link', { rel: 'alternate', type: "text/mf2+html", href: '/changelog' }], ['link', { rel: 'alternate', type: "application/rss+xml", title: 'Changelog', href: '/changelog/rss' }], ['link', { rel: 'alternate', type: "application/atom+xml", title: 'Changelog', href: '/changelog/atom' }], ['link', { rel: 'alternate', type: "application/json+xml", title: 'Changelog', href: '/changelog/json' }], ['meta', { name: 'og:description', content: 'The Paper Pilot\'s Digital Garden' }] ], lastUpdated: false, cleanUrls: 'with-subfolders', async transformHtml(code, id, context) { if (context.page.startsWith("garden") && fs.existsSync("site/" + context.page)) { const wc = wordCounting(code, { isHtml: true }).wordsCount; const pageStart = code.indexOf(""); const firstCommit = (await exec(`git log -n 1 --diff-filter=A --format="" site/${context.page}`)).stdout; const lastCommit = (await exec(`git log -n 1 --diff-filter=M --format="" site/${context.page}`)).stdout; const header = code.slice(0, pageStart < 0 ? 0 : pageStart + 5).replace('

${wc} words, ~${Math.round(wc / 183)} minute read. Planted ${firstCommit}.${lastCommit ? ` Last tended to ${lastCommit}.` : ''}


` + code.slice(pageStart + 5).replace('', '
'); code = code.replaceAll(/]*<\/img>|]*>(?!<\/img)/g, text => `
${text}
`); } return code; }, themeConfig: { search: { provider: 'local', options: { _render(src, env, md) { const html = md.render(src, env); if (env.frontmatter?.search === false) return ''; if (env.relativePath.startsWith('public')) return ''; if (env.relativePath.startsWith('guide-to-incrementals')) return ''; return html; } } }, outline: 'deep', nav: [ { text: "Profectus", link: "https://moddingtree.com" }, { text: "Incremental Social", link: "https://incremental.social" } ], socialLinks: [ { icon: { svg: `Forgejo` }, link: "https://code.incremental.social/thepaperpilot" }, { icon: { svg: `Matrix` }, link: "https://matrix.to/#/@thepaperpilot:incremental.social" }, { icon: { svg: `Fediverse` }, link: "https://incremental.social/u/thepaperpilot" } ], sidebar: [ { text: "Recommended Pages", items: favorites }, { text: "/now", link: "/now" }, { text: "Changelog", link: "/changelog" } ] } }