`
+ return before?.(info, tokens, index, options, env) || `
`
}
else {
- return options.after?.(info, tokens, index) || '
'
+ return after?.(info, tokens, index, options, env) || '
'
}
}
diff --git a/plugins/plugin-md-power/src/node/container/index.ts b/plugins/plugin-md-power/src/node/container/index.ts
index 999a8b1b..fb9b8af3 100644
--- a/plugins/plugin-md-power/src/node/container/index.ts
+++ b/plugins/plugin-md-power/src/node/container/index.ts
@@ -5,6 +5,7 @@ import { isPlainObject } from '@vuepress/helper'
import { alignPlugin } from './align.js'
import { cardPlugin } from './card.js'
import { codeTabs } from './codeTabs.js'
+import { collapsePlugin } from './collapse.js'
import { demoWrapperPlugin } from './demoWrapper.js'
import { fileTreePlugin } from './fileTree.js'
import { langReplPlugin } from './langRepl.js'
@@ -50,4 +51,7 @@ export async function containerPlugin(
if (options.timeline)
timelinePlugin(md)
+
+ if (options.collapse)
+ collapsePlugin(md)
}
diff --git a/plugins/plugin-md-power/src/node/prepareConfigFile.ts b/plugins/plugin-md-power/src/node/prepareConfigFile.ts
index 38b6a08d..fa8c0987 100644
--- a/plugins/plugin-md-power/src/node/prepareConfigFile.ts
+++ b/plugins/plugin-md-power/src/node/prepareConfigFile.ts
@@ -109,6 +109,13 @@ export async function prepareConfigFile(app: App, options: MarkdownPowerPluginOp
enhances.add(`app.component('VPTimelineItem', VPTimelineItem)`)
}
+ if (options.collapse) {
+ imports.add(`import VPCollapse from '${CLIENT_FOLDER}components/VPCollapse.vue'`)
+ imports.add(`import VPCollapseItem from '${CLIENT_FOLDER}components/VPCollapseItem.vue'`)
+ enhances.add(`app.component('VPCollapse', VPCollapse)`)
+ enhances.add(`app.component('VPCollapseItem', VPCollapseItem)`)
+ }
+
return app.writeTemp(
'md-power/config.js',
`\
diff --git a/plugins/plugin-md-power/src/shared/plugin.ts b/plugins/plugin-md-power/src/shared/plugin.ts
index 4e50073c..ed0cda20 100644
--- a/plugins/plugin-md-power/src/shared/plugin.ts
+++ b/plugins/plugin-md-power/src/shared/plugin.ts
@@ -61,7 +61,9 @@ export interface MarkdownPowerPluginOptions {
*
* ```md
* ::: timeline
- * - title time="Q1" icon="ri:clockwise-line" line="dashed" type="warning" color="red"
+ * - title
+ * time="Q1" icon="ri:clockwise-line" line="dashed" type="warning" color="red"
+ *
* xxx
* :::
* ```
@@ -70,6 +72,25 @@ export interface MarkdownPowerPluginOptions {
*/
timeline?: boolean
+ /**
+ * 是否启用 collapse 折叠面板 语法
+ *
+ * ```md
+ * ::: collapse accordion
+ * - + title
+ *
+ * content
+ *
+ * - - title
+ *
+ * content
+ * :::
+ * ```
+ *
+ * @default false
+ */
+ collapse?: boolean
+
// video embed
/**
* 是否启用 bilibili 视频嵌入
diff --git a/theme/src/node/detector/fields.ts b/theme/src/node/detector/fields.ts
index c246477f..ac33c761 100644
--- a/theme/src/node/detector/fields.ts
+++ b/theme/src/node/detector/fields.ts
@@ -58,6 +58,7 @@ export const MARKDOWN_POWER_FIELDS: (keyof MarkdownPowerPluginOptions)[] = [
'repl',
'replit',
'timeline',
+ 'collapse',
'youtube',
]