Skip to content

Commit 2d95c68

Browse files
committed
local.js: Move plugin paths out of local config file
1 parent 3babaac commit 2d95c68

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

.vitepress/local.js.dist

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@ export const data_paths = {
1313
// doveadm: '../data/doveadm.js',
1414
}
1515

16-
// A listing of paths containing plugin files.
17-
// Paths are relative to project base.
18-
//
19-
// Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax
20-
//
21-
// Default: [ 'docs/core/plugins/*.md' ]
22-
export const plugin_paths = []
23-
2416
// Enable additional labels to support in Dovecot-specific markdown
2517
// processing (i.e. [[xyz,...]]).
2618
export const markdown_extend = {

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ Paths are relative to project base.
175175

176176
Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax
177177

178+
#### plugin_paths
179+
180+
A listing of paths containing plugin files.
181+
Paths are relative to project base.
182+
183+
Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax
184+
178185
#### watch_paths
179186

180187
An array of file patterns to watch to refresh data loaders in dev mode.

lib/markdown.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ export async function initDovecotMd(base) {
1717
doveadm: (await loadData('doveadm')).doveadm,
1818
events: (await loadData('events')).events,
1919
linkoverrides: (await loadData('links_overrides')).links_overrides,
20-
plugins: (await pluginFiles()).flatMap((x) =>
21-
fg.sync(x).map((y) => path.basename(y, '.md'))
22-
),
2320
settings: (await loadData('settings')).settings,
2421
updates: (await loadData('updates')).updates
2522
},
@@ -229,6 +226,8 @@ function dovecot_markdown(md, opts) {
229226
env.args = parts[2] ? parts[2] : undefined
230227
const plugin = env.inner.replaceAll('-', '_')
231228

229+
initPluginFiles()
230+
232231
if (!opts.plugins.includes(plugin)) {
233232
handle_error('plugin link missing: ' + env.inner)
234233
return '<a>'
@@ -433,6 +432,14 @@ function dovecot_markdown(md, opts) {
433432
}
434433
}
435434

435+
function initPluginFiles() {
436+
if (!opts.plugins) {
437+
opts.plugins = pluginFiles().flatMap((x) =>
438+
fg.sync(x).map((y) => path.basename(y, '.md'))
439+
)
440+
}
441+
}
442+
436443
md.inline.ruler.after('emphasis', 'dovecot_brackets', process_brackets)
437444
md.renderer.rules.dovecot_open = dovecot_open
438445
md.renderer.rules.dovecot_body = dovecot_body

lib/utility.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,9 @@ export function manIncludes() {
8585
?? [ 'docs/core/man/include/*.inc' ]
8686
}
8787

88-
export async function pluginFiles() {
89-
/* Check for config override file. */
90-
const lconf = await loadLocalConf()
91-
92-
return lconf?.plugin_paths ??
93-
[ 'docs/core/plugins/*.md' ]
88+
export function pluginFiles() {
89+
return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.plugin_paths
90+
?? [ 'docs/core/plugins/*.md' ]
9491
}
9592

9693
export function getExcludes(srcDirs = [ 'docs' ]) {

0 commit comments

Comments
 (0)