From f9a52002d1e356c4026612b83e51c0d34a04e691 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 23 Oct 2024 15:18:11 -0600 Subject: [PATCH 1/6] local.js: Move watch paths out of local config file --- .vitepress/local.js.dist | 9 --------- README.md | 13 +++++++++++++ lib/data/doveadm.data.js | 7 +++---- lib/data/event_categories.data.js | 7 +++---- lib/data/event_reasons.data.js | 7 +++---- lib/data/events.data.js | 7 +++---- lib/data/lua.data.js | 7 +++---- lib/data/settings.data.js | 7 +++---- lib/utility.js | 13 +++++++------ 9 files changed, 38 insertions(+), 39 deletions(-) diff --git a/.vitepress/local.js.dist b/.vitepress/local.js.dist index a43e56659..d2c668a37 100644 --- a/.vitepress/local.js.dist +++ b/.vitepress/local.js.dist @@ -13,15 +13,6 @@ export const data_paths = { // doveadm: '../data/doveadm.js', } -// A listing of files to watch to refresh data loaders in dev mode. -// See: https://vitepress.dev/guide/data-loading#data-from-local-files -// Paths are relative to project base. -// -// Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax -// -// Default: [ 'docs/**/*.md', 'docs/**/*.inc', 'data/**/*' ] -export const watch_paths = [] - // A listing of paths containing man files. // Paths are relative to project base. // diff --git a/README.md b/README.md index 18a6b4c34..03007a10a 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,19 @@ The data files live in the base `/data` directory. Each file attempts to be self-documenting, but they are all essentially large JSON objects. Developers should need to know basically no JavaScript to be able to edit the files. +### VitePress Path Overrides + +Various paths used for VitePress static generation can be overridden using +the `dovecot` object in the `themeConfig` VitePress configuration setting. + +#### watch_paths + +An array of file patterns to watch to refresh data loaders in dev mode. +See: https://vitepress.dev/guide/data-loading#data-from-local-files +Paths are relative to project base. + +Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax + ### Dovecot Markdown Extensions Markdown has been extended to allow various Dovecot-specific tasks to be diff --git a/lib/data/doveadm.data.js b/lib/data/doveadm.data.js index c76fd5e93..1c54c7e47 100644 --- a/lib/data/doveadm.data.js +++ b/lib/data/doveadm.data.js @@ -1,6 +1,6 @@ import { doveadm_arg_types, doveadm_flag_types, getDoveadmCmdLine } from '../doveadm.js' import { getVitepressMd } from '../markdown.js' -import { loadData, normalizeArrayData, watchFiles } from '../utility.js' +import { addWatchPaths, loadData, normalizeArrayData } from '../utility.js' import slugify from '@sindresorhus/slugify' const doveadm_userargs = { @@ -147,11 +147,10 @@ async function normalizeDoveadm(doveadm) { } } -export default { - watch: await watchFiles(), +export default addWatchPaths({ async load() { return await normalizeDoveadm( structuredClone((await loadData('doveadm')).doveadm) ) } -} +}) diff --git a/lib/data/event_categories.data.js b/lib/data/event_categories.data.js index 4e009ab4f..37edcb12a 100644 --- a/lib/data/event_categories.data.js +++ b/lib/data/event_categories.data.js @@ -1,5 +1,5 @@ import { getVitepressMd } from '../markdown.js' -import { loadData, watchFiles } from '../utility.js' +import { addWatchPaths, loadData } from '../utility.js' async function normalizeEventCategories(categories) { const md = await getVitepressMd() @@ -11,11 +11,10 @@ async function normalizeEventCategories(categories) { return categories } -export default { - watch: await watchFiles(), +export default addWatchPaths({ async load() { return await normalizeEventCategories( structuredClone((await loadData('event_categories')).categories) ) } -} +}) diff --git a/lib/data/event_reasons.data.js b/lib/data/event_reasons.data.js index 9ddd930ac..5f3cdb11f 100644 --- a/lib/data/event_reasons.data.js +++ b/lib/data/event_reasons.data.js @@ -1,5 +1,5 @@ import { getVitepressMd } from '../markdown.js' -import { loadData, watchFiles } from '../utility.js' +import { addWatchPaths, loadData } from '../utility.js' async function normalizeEventReasons(reasons) { const md = await getVitepressMd() @@ -11,11 +11,10 @@ async function normalizeEventReasons(reasons) { return reasons } -export default { - watch: await watchFiles(), +export default addWatchPaths({ async load() { return await normalizeEventReasons( structuredClone((await loadData('event_reasons')).reasons) ) } -} +}) diff --git a/lib/data/events.data.js b/lib/data/events.data.js index 82696b976..e3446f255 100644 --- a/lib/data/events.data.js +++ b/lib/data/events.data.js @@ -1,4 +1,4 @@ -import { loadData, normalizeArrayData, watchFiles } from '../utility.js' +import { addWatchPaths, loadData, normalizeArrayData } from '../utility.js' import { getVitepressMd } from '../markdown.js' /* Take the events list and normalize entries and process inheritance. */ @@ -124,8 +124,7 @@ async function normalizeEvents(events, global_inherits, inherits) { return events } -export default { - watch: await watchFiles(), +export default addWatchPaths({ async load() { const data = await loadData('events') return await normalizeEvents( @@ -134,4 +133,4 @@ export default { structuredClone(data.inherits) ) } -} +}) diff --git a/lib/data/lua.data.js b/lib/data/lua.data.js index 9490c5c87..363982f5f 100644 --- a/lib/data/lua.data.js +++ b/lib/data/lua.data.js @@ -1,5 +1,5 @@ import { getVitepressMd } from '../markdown.js' -import { loadData, watchFiles } from '../utility.js' +import { addWatchPaths, loadData } from '../utility.js' async function normalizeLuaConstants(lua) { const md = await getVitepressMd() @@ -62,8 +62,7 @@ async function normalizeLuaVariables(lua) { return out } -export default { - watch: await watchFiles(), +export default addWatchPaths({ async load() { const data = await(loadData('lua')) @@ -73,4 +72,4 @@ export default { variables: await normalizeLuaVariables(data.lua_variables) } } -} +}) diff --git a/lib/data/settings.data.js b/lib/data/settings.data.js index 9311ee2a4..7df26c155 100644 --- a/lib/data/settings.data.js +++ b/lib/data/settings.data.js @@ -1,4 +1,4 @@ -import { loadData, normalizeArrayData, watchFiles } from '../utility.js' +import { addWatchPaths, loadData, normalizeArrayData } from '../utility.js' import { getVitepressMd } from '../markdown.js' async function normalizeSettings(settings) { @@ -69,11 +69,10 @@ async function normalizeSettings(settings) { return data } -export default { - watch: await watchFiles(), +export default addWatchPaths({ async load() { return await normalizeSettings( structuredClone((await loadData('settings')).settings) ) } -} +}) diff --git a/lib/utility.js b/lib/utility.js index dbb5d10cf..29c2e4dd0 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -66,12 +66,13 @@ export async function loadData(id) { } } -export async function watchFiles() { - /* Check for config override file. */ - const lconf = await loadLocalConf() - - return lconf?.watch_paths ?? - [ 'docs/**/*.md', 'docs/**/*.inc', 'data/**/*' ] +export function addWatchPaths(obj) { + return { + ...obj, + ...{ + watch: globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.watch_paths ?? [ 'docs/**/*.md', 'docs/**/*.inc', 'data/**/*' ] + } + } } export async function manFiles() { From dbcee66d45da3d4e1635e2f056396d00bcbf0e7e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 23 Oct 2024 15:30:58 -0600 Subject: [PATCH 2/6] local.js: Move man paths out of local config file --- .vitepress/local.js.dist | 8 -------- README.md | 12 ++++++++++++ lib/markdown.js | 19 +++++++++++++------ lib/utility.js | 16 ++++++---------- util/generate_man.js | 4 ++-- 5 files changed, 33 insertions(+), 26 deletions(-) diff --git a/.vitepress/local.js.dist b/.vitepress/local.js.dist index d2c668a37..c5274b0a2 100644 --- a/.vitepress/local.js.dist +++ b/.vitepress/local.js.dist @@ -13,14 +13,6 @@ export const data_paths = { // doveadm: '../data/doveadm.js', } -// A listing of paths containing man files. -// Paths are relative to project base. -// -// Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax -// -// Default: [ 'docs/core/man/*.[[:digit:]].md' ] -export const man_paths = [] - // A listing of paths containing plugin files. // Paths are relative to project base. // diff --git a/README.md b/README.md index 03007a10a..bd78e4b51 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,18 @@ should need to know basically no JavaScript to be able to edit the files. Various paths used for VitePress static generation can be overridden using the `dovecot` object in the `themeConfig` VitePress configuration setting. +#### man_includes + +A list of additional paths (other than the `include/` directory of the man +folder) where include files can live. + +#### man_paths + +A listing of paths containing man files. +Paths are relative to project base. + +Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax + #### watch_paths An array of file patterns to watch to refresh data loaders in dev mode. diff --git a/lib/markdown.js b/lib/markdown.js index 9949e0ea1..27928674b 100644 --- a/lib/markdown.js +++ b/lib/markdown.js @@ -17,12 +17,6 @@ export async function initDovecotMd(base) { doveadm: (await loadData('doveadm')).doveadm, events: (await loadData('events')).events, linkoverrides: (await loadData('links_overrides')).links_overrides, - man: (await manFiles()).flatMap((x) => { - return fg.sync(x).map((y) => { - const str = path.basename(y) - return str.substring(0, str.indexOf('.')) - }) - }), plugins: (await pluginFiles()).flatMap((x) => fg.sync(x).map((y) => path.basename(y, '.md')) ), @@ -219,6 +213,8 @@ function dovecot_markdown(md, opts) { hash = parts[2] ? parts[2] : false; env.args = parts[3] ? parts[3] : 1; + initManFiles() + if (!opts.man.includes(env.inner)) { handle_error('man link missing: ' + env.inner) return '' @@ -426,6 +422,17 @@ function dovecot_markdown(md, opts) { opts.dovecotlinks = { ...links, ...opts.linkoverrides } } + function initManFiles() { + if (!opts.man) { + opts.man = manFiles().flatMap((x) => { + return fg.sync(x).map((y) => { + const str = path.basename(y) + return str.substring(0, str.indexOf('.')) + }) + }) + } + } + md.inline.ruler.after('emphasis', 'dovecot_brackets', process_brackets) md.renderer.rules.dovecot_open = dovecot_open md.renderer.rules.dovecot_body = dovecot_body diff --git a/lib/utility.js b/lib/utility.js index 29c2e4dd0..776abe056 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -75,18 +75,14 @@ export function addWatchPaths(obj) { } } -export async function manFiles() { - /* Check for config override file. */ - const lconf = await loadLocalConf() - - return lconf?.man_paths ?? - [ 'docs/core/man/*.[[:digit:]].md' ] +export function manFiles() { + return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.man_paths + ?? [ 'docs/core/man/*.[[:digit:]].md' ] } -export async function manIncludes() { - const lconf = await loadLocalConf() - return lconf?.man_includes ?? - [ 'docs/core/man/include/*.inc' ] +export function manIncludes() { + return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.man_includes + ?? [ 'docs/core/man/include/*.inc' ] } export async function pluginFiles() { diff --git a/util/generate_man.js b/util/generate_man.js index a9e566775..d93fb270d 100755 --- a/util/generate_man.js +++ b/util/generate_man.js @@ -126,8 +126,8 @@ const main = async (component, outPath) => { } /* Generate list of man files. */ - const files = (await manFiles()).flatMap((x) => fg.sync(x)) - const includes = (await manIncludes()).flatMap((x) => fg.sync(x)) + const files = manFiles().flatMap((x) => fg.sync(x)) + const includes = manIncludes().flatMap((x) => fg.sync(x)) /* Get hash of last git commit. */ const gitHash = gitCommitInfo().shortHash From 926fd4d78803f9cf26e555394c0e79bc2def131f Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 23 Oct 2024 15:36:22 -0600 Subject: [PATCH 3/6] local.js: Move plugin paths out of local config file --- .vitepress/local.js.dist | 8 -------- README.md | 7 +++++++ lib/markdown.js | 13 ++++++++++--- lib/utility.js | 9 +++------ 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.vitepress/local.js.dist b/.vitepress/local.js.dist index c5274b0a2..8c0cd0316 100644 --- a/.vitepress/local.js.dist +++ b/.vitepress/local.js.dist @@ -13,14 +13,6 @@ export const data_paths = { // doveadm: '../data/doveadm.js', } -// A listing of paths containing plugin files. -// Paths are relative to project base. -// -// Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax -// -// Default: [ 'docs/core/plugins/*.md' ] -export const plugin_paths = [] - // Enable additional labels to support in Dovecot-specific markdown // processing (i.e. [[xyz,...]]). export const markdown_extend = { diff --git a/README.md b/README.md index bd78e4b51..cbdabca49 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,13 @@ Paths are relative to project base. Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax +#### plugin_paths + +A listing of paths containing plugin files. +Paths are relative to project base. + +Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax + #### watch_paths An array of file patterns to watch to refresh data loaders in dev mode. diff --git a/lib/markdown.js b/lib/markdown.js index 27928674b..ab6150872 100644 --- a/lib/markdown.js +++ b/lib/markdown.js @@ -17,9 +17,6 @@ export async function initDovecotMd(base) { doveadm: (await loadData('doveadm')).doveadm, events: (await loadData('events')).events, linkoverrides: (await loadData('links_overrides')).links_overrides, - plugins: (await pluginFiles()).flatMap((x) => - fg.sync(x).map((y) => path.basename(y, '.md')) - ), settings: (await loadData('settings')).settings, updates: (await loadData('updates')).updates }, @@ -229,6 +226,8 @@ function dovecot_markdown(md, opts) { env.args = parts[2] ? parts[2] : undefined const plugin = env.inner.replaceAll('-', '_') + initPluginFiles() + if (!opts.plugins.includes(plugin)) { handle_error('plugin link missing: ' + env.inner) return '' @@ -433,6 +432,14 @@ function dovecot_markdown(md, opts) { } } + function initPluginFiles() { + if (!opts.plugins) { + opts.plugins = pluginFiles().flatMap((x) => + fg.sync(x).map((y) => path.basename(y, '.md')) + ) + } + } + md.inline.ruler.after('emphasis', 'dovecot_brackets', process_brackets) md.renderer.rules.dovecot_open = dovecot_open md.renderer.rules.dovecot_body = dovecot_body diff --git a/lib/utility.js b/lib/utility.js index 776abe056..1c5e1c2ef 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -85,12 +85,9 @@ export function manIncludes() { ?? [ 'docs/core/man/include/*.inc' ] } -export async function pluginFiles() { - /* Check for config override file. */ - const lconf = await loadLocalConf() - - return lconf?.plugin_paths ?? - [ 'docs/core/plugins/*.md' ] +export function pluginFiles() { + return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.plugin_paths + ?? [ 'docs/core/plugins/*.md' ] } export function getExcludes(srcDirs = [ 'docs' ]) { From 7d8286824d7b22b923d296b4b046ff57a389386e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 23 Oct 2024 16:16:38 -0600 Subject: [PATCH 4/6] local.js: Move markdown_extend out of local config file --- .vitepress/local.js.dist | 19 ------------------- README.md | 23 +++++++++++++++++++++++ lib/markdown.js | 23 ++++++++++++++--------- lib/utility.js | 12 +++--------- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/.vitepress/local.js.dist b/.vitepress/local.js.dist index 8c0cd0316..7dc117c70 100644 --- a/.vitepress/local.js.dist +++ b/.vitepress/local.js.dist @@ -12,22 +12,3 @@ export const data_paths = { // doveadm: '../data/doveadm.js', } - -// Enable additional labels to support in Dovecot-specific markdown -// processing (i.e. [[xyz,...]]). -export const markdown_extend = { - - // Init function. Return value is configuration options to add to markdown - // object. - // init: () => { return {} }, - - // Opening tag function. Returns opening tag. - // open: (mode, parts, opts, env) => { return '' }, - - // Body function. Returns body text. - // body: (mode, env) => { return '' }, - - // Close tag function. Returns closing tag. - // close: (mode, env) => { return '' }, - -} diff --git a/README.md b/README.md index cbdabca49..b67d77d70 100644 --- a/README.md +++ b/README.md @@ -175,6 +175,29 @@ Paths are relative to project base. Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax +#### markdown_extend + +An object containing callbacks that enable additional labels to support in +Dovecot-specific markdown processing (i.e. [[xyz,...]]). + +##### open + +Opening tag function. Returns opening tag. + +Example: `open: (mode, parts, opts, env) => { return '' }` + +##### body + +Body function. Returns body text. + +Example: `body: (mode, env) => { return '' }` + +##### close + +Close tag function. Returns closing tag. + +Example: `close: (mode, env) => { return '' }` + #### plugin_paths A listing of paths containing plugin files. diff --git a/lib/markdown.js b/lib/markdown.js index ab6150872..2d891d2bf 100644 --- a/lib/markdown.js +++ b/lib/markdown.js @@ -12,15 +12,12 @@ export async function initDovecotMd(base) { } md_conf = { - ...{ - base: base, - doveadm: (await loadData('doveadm')).doveadm, - events: (await loadData('events')).events, - linkoverrides: (await loadData('links_overrides')).links_overrides, - settings: (await loadData('settings')).settings, - updates: (await loadData('updates')).updates - }, - ...(await markdownExtension()) + base: base, + doveadm: (await loadData('doveadm')).doveadm, + events: (await loadData('events')).events, + linkoverrides: (await loadData('links_overrides')).links_overrides, + settings: (await loadData('settings')).settings, + updates: (await loadData('updates')).updates } } @@ -291,6 +288,8 @@ function dovecot_markdown(md, opts) { opts.base) + '">' default: + initMarkdownExtend() + return handle_default(mode, opts.markdown?.open?.(mode, parts, opts, env)) } @@ -432,6 +431,12 @@ function dovecot_markdown(md, opts) { } } + function initMarkdownExtend() { + if (!opts.markdown) { + opts.markdown = markdownExtension() + } + } + function initPluginFiles() { if (!opts.plugins) { opts.plugins = pluginFiles().flatMap((x) => diff --git a/lib/utility.js b/lib/utility.js index 1c5e1c2ef..63f40d6f2 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -41,15 +41,9 @@ async function loadLocalConf() { return local_conf } -export async function markdownExtension() { - const lconf = await loadLocalConf() - - return { - ...{ - markdown: lconf.markdown_extend ?? {}, - }, - ...(lconf.markdown_extend?.init?.() ?? {}) - } +export function markdownExtension() { + return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.markdown_extend + ?? {} } export async function loadData(id) { From ce6034f651af8971054b19ba79cada5228af2296 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 23 Oct 2024 16:34:13 -0600 Subject: [PATCH 5/6] local.js: Move data_paths out of local config file --- .vitepress/config.js | 9 ++------- .vitepress/local.js.dist | 14 -------------- README.md | 10 ++++++++++ lib/markdown.js | 29 ++++++++++------------------- lib/utility.js | 4 +--- 5 files changed, 23 insertions(+), 43 deletions(-) delete mode 100644 .vitepress/local.js.dist diff --git a/.vitepress/config.js b/.vitepress/config.js index b9f6082e0..9cc890d87 100644 --- a/.vitepress/config.js +++ b/.vitepress/config.js @@ -2,16 +2,11 @@ import gitCommitInfo from 'git-commit-info' import { defineConfig } from 'vitepress' import { pagefindPlugin } from 'vitepress-plugin-pagefind' import { generateSidebar } from 'vitepress-sidebar' -import { dovecotMdExtend, initDovecotMd } from '../lib/markdown.js' +import { dovecotMdExtend } from '../lib/markdown.js' import { getExcludes } from '../lib/utility.js' const base = '/2.4' -// Need to bootstrap configuration for Dovecot markdown driver (specifically, -// loading all data files to allow existence checking), or else the markdown -// processing will begin before Dovecot link markup is enabled -await initDovecotMd(base) - export default defineConfig({ title: "Dovecot CE", description: "Dovecot CE Documentation", @@ -107,7 +102,7 @@ export default defineConfig({ }, markdown: { - config: (md) => dovecotMdExtend(md), + config: async (md) => await dovecotMdExtend(md), image: { lazyLoading: true, }, diff --git a/.vitepress/local.js.dist b/.vitepress/local.js.dist deleted file mode 100644 index 7dc117c70..000000000 --- a/.vitepress/local.js.dist +++ /dev/null @@ -1,14 +0,0 @@ -/* This file allows configuration overrides of various core settings. */ - -// Allows custom mapping of data sources. -// It is used by the VitePress data loaders to determine what data to -// load for export. -// -// By default, all data files are loaded from "../data" directory -// (paths are relative to "/lib"). -// -// Keys are data identifiers, Values are location RELATIVE TO -// * "/lib" DIRECTORY. -export const data_paths = { - // doveadm: '../data/doveadm.js', -} diff --git a/README.md b/README.md index b67d77d70..28f3aba27 100644 --- a/README.md +++ b/README.md @@ -163,6 +163,16 @@ should need to know basically no JavaScript to be able to edit the files. Various paths used for VitePress static generation can be overridden using the `dovecot` object in the `themeConfig` VitePress configuration setting. +#### data_paths + +Allows custom mapping of data sources. + +It is used by the VitePress data loaders to determine what data to +load for export. + +Keys are data identifiers, Values are location RELATIVE TO `/lib` +DIRECTORY. + #### man_includes A list of additional paths (other than the `include/` directory of the man diff --git a/lib/markdown.js b/lib/markdown.js index 2d891d2bf..60feacbee 100644 --- a/lib/markdown.js +++ b/lib/markdown.js @@ -6,22 +6,7 @@ import { createMarkdownRenderer } from 'vitepress' import { frontmatterIter, loadData, manFiles, markdownExtension, pluginFiles, resolveURL } from './utility.js' let md_conf = null -export async function initDovecotMd(base) { - if (md_conf !== null) { - return - } - - md_conf = { - base: base, - doveadm: (await loadData('doveadm')).doveadm, - events: (await loadData('events')).events, - linkoverrides: (await loadData('links_overrides')).links_overrides, - settings: (await loadData('settings')).settings, - updates: (await loadData('updates')).updates - } -} - -export function dovecotMdExtend(md) { +export async function dovecotMdExtend(md) { md.use(containerPlugin, 'todo', { render: function(tokens, idx) { if (tokens[idx].nesting === 1) { @@ -34,7 +19,14 @@ export function dovecotMdExtend(md) { md.use(deflistPlugin) if (md_conf === null) { - throw new Error('Must call initDovecotMd() before calling this function!') + md_conf = { + base: globalThis.VITEPRESS_CONFIG.site.base, + doveadm: (await loadData('doveadm')).doveadm, + events: (await loadData('events')).events, + linkoverrides: (await loadData('links_overrides')).links_overrides, + settings: (await loadData('settings')).settings, + updates: (await loadData('updates')).updates + } } md.use(dovecot_markdown, md_conf) @@ -46,8 +38,7 @@ export async function getVitepressMd() { if (vitepress_md === null) { const config = globalThis.VITEPRESS_CONFIG - await initDovecotMd(config.site.base) - vitepress_md = dovecotMdExtend(await createMarkdownRenderer( + vitepress_md = await dovecotMdExtend(await createMarkdownRenderer( config.srcDir, config.markdown, config.site.base, diff --git a/lib/utility.js b/lib/utility.js index 63f40d6f2..a8b698960 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -47,9 +47,7 @@ export function markdownExtension() { } export async function loadData(id) { - /* Check for config override file. */ - const lconf = await loadLocalConf() - const path = lconf?.data_paths?.[id] ?? + const path = globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.data_paths?.[id] ?? ('../data/' + id + '.js') try { From 46c8bf6e7dbb8132d526c75ec68da221d7bd9d5e Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 23 Oct 2024 16:46:51 -0600 Subject: [PATCH 6/6] utility.js: Remove no longer used local configuration path code --- lib/utility.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/utility.js b/lib/utility.js index a8b698960..e6587952a 100644 --- a/lib/utility.js +++ b/lib/utility.js @@ -9,8 +9,6 @@ import { fileURLToPath } from 'url' const __filename = fileURLToPath(import.meta.url); const __dirname = dirname(__filename); -const local_conf_path = __dirname + '/../.vitepress/local.js' - export function normalizeArrayData(data, keys) { for (const [k, v] of Object.entries(data)) { if (v) { @@ -28,19 +26,6 @@ export function normalizeArrayData(data, keys) { return data } -let local_conf = null -async function loadLocalConf() { - if (local_conf === null) { - if (fs.existsSync(local_conf_path)) { - local_conf = await import(local_conf_path) - } else { - local_conf = false - } - } - - return local_conf -} - export function markdownExtension() { return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.markdown_extend ?? {}