@@ -3,7 +3,7 @@ import fg from 'fast-glob'
33import deflistPlugin from 'markdown-it-deflist'
44import path from 'path'
55import { 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
88let md_conf = null
99export 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
0 commit comments