Skip to content

Commit ff282dc

Browse files
committed
local.js: Move plugin paths out of local config file
1 parent 6fbe1b6 commit ff282dc

File tree

5 files changed

+21
-20
lines changed

5 files changed

+21
-20
lines changed

.vitepress/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ export default defineConfig({
113113
man_paths: [
114114
'docs/core/man/*.[[:digit:]].md'
115115
],
116+
plugin_paths: [
117+
'docs/core/plugins/*.md'
118+
],
116119
watch_paths: [
117120
'docs/**/*.md',
118121
'docs/**/*.inc',

.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
@@ -176,6 +176,13 @@ Paths are relative to project base.
176176

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

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

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

lib/markdown.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fg from 'fast-glob'
33
import deflistPlugin from 'markdown-it-deflist'
44
import path from 'path'
55
import { createMarkdownRenderer } from 'vitepress'
6-
import { dovecotSetting, frontmatterIter, loadData, markdownExtension, pluginFiles, resolveURL } from './utility.js'
6+
import { dovecotSetting, frontmatterIter, loadData, markdownExtension, resolveURL } from './utility.js'
77

88
let md_conf = null
99
export async function initDovecotMd(base) {
@@ -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 = dovecotSetting('plugin_paths').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: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,6 @@ export function addWatchPaths(obj) {
8080
return { ...obj, ...{ watch: dovecotSetting('watch_paths') } }
8181
}
8282

83-
export async function pluginFiles() {
84-
/* Check for config override file. */
85-
const lconf = await loadLocalConf()
86-
87-
return lconf?.plugin_paths ??
88-
[ 'docs/core/plugins/*.md' ]
89-
}
90-
9183
export function getExcludes(srcDirs = [ 'docs' ]) {
9284
const excludes = []
9385

0 commit comments

Comments
 (0)