Skip to content

Commit 0ce4d31

Browse files
committed
local.js: Move man paths out of local config file
1 parent 00e12aa commit 0ce4d31

File tree

5 files changed

+33
-26
lines changed

5 files changed

+33
-26
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 man 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/man/*.[[:digit:]].md' ]
22-
export const man_paths = []
23-
2416
// A listing of paths containing plugin files.
2517
// Paths are relative to project base.
2618
//

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ should need to know basically no JavaScript to be able to edit the files.
163163
Various paths used for VitePress static generation can be overridden using
164164
the `dovecot` object in the `themeConfig` VitePress configuration setting.
165165

166+
#### man_includes
167+
168+
A list of additional paths (other than the `include/` directory of the man
169+
folder) where include files can live.
170+
171+
#### man_paths
172+
173+
A listing of paths containing man files.
174+
Paths are relative to project base.
175+
176+
Supports fast-glob: https://github.com/mrmlnc/fast-glob#pattern-syntax
177+
166178
#### watch_paths
167179

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

lib/markdown.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +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-
man: (await manFiles()).flatMap((x) => {
21-
return fg.sync(x).map((y) => {
22-
const str = path.basename(y)
23-
return str.substring(0, str.indexOf('.'))
24-
})
25-
}),
2620
plugins: (await pluginFiles()).flatMap((x) =>
2721
fg.sync(x).map((y) => path.basename(y, '.md'))
2822
),
@@ -219,6 +213,8 @@ function dovecot_markdown(md, opts) {
219213
hash = parts[2] ? parts[2] : false;
220214
env.args = parts[3] ? parts[3] : 1;
221215

216+
initManFiles()
217+
222218
if (!opts.man.includes(env.inner)) {
223219
handle_error('man link missing: ' + env.inner)
224220
return '<a><code>'
@@ -426,6 +422,17 @@ function dovecot_markdown(md, opts) {
426422
opts.dovecotlinks = { ...links, ...opts.linkoverrides }
427423
}
428424

425+
function initManFiles() {
426+
if (!opts.man) {
427+
opts.man = manFiles().flatMap((x) => {
428+
return fg.sync(x).map((y) => {
429+
const str = path.basename(y)
430+
return str.substring(0, str.indexOf('.'))
431+
})
432+
})
433+
}
434+
}
435+
429436
md.inline.ruler.after('emphasis', 'dovecot_brackets', process_brackets)
430437
md.renderer.rules.dovecot_open = dovecot_open
431438
md.renderer.rules.dovecot_body = dovecot_body

lib/utility.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,14 @@ export function addWatchPaths(obj) {
7575
}
7676
}
7777

78-
export async function manFiles() {
79-
/* Check for config override file. */
80-
const lconf = await loadLocalConf()
81-
82-
return lconf?.man_paths ??
83-
[ 'docs/core/man/*.[[:digit:]].md' ]
78+
export function manFiles() {
79+
return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.man_paths
80+
?? [ 'docs/core/man/*.[[:digit:]].md' ]
8481
}
8582

86-
export async function manIncludes() {
87-
const lconf = await loadLocalConf()
88-
return lconf?.man_includes ??
89-
[ 'docs/core/man/include/*.inc' ]
83+
export function manIncludes() {
84+
return globalThis.VITEPRESS_CONFIG.userConfig.themeConfig.dovecot?.man_includes
85+
?? [ 'docs/core/man/include/*.inc' ]
9086
}
9187

9288
export async function pluginFiles() {

util/generate_man.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ const main = async (component, outPath) => {
126126
}
127127

128128
/* Generate list of man files. */
129-
const files = (await manFiles()).flatMap((x) => fg.sync(x))
130-
const includes = (await manIncludes()).flatMap((x) => fg.sync(x))
129+
const files = manFiles().flatMap((x) => fg.sync(x))
130+
const includes = manIncludes().flatMap((x) => fg.sync(x))
131131

132132
/* Get hash of last git commit. */
133133
const gitHash = gitCommitInfo().shortHash

0 commit comments

Comments
 (0)