Skip to content

Commit

Permalink
fix(plugin-md-power): incorrect rendering heading from demo in `out…
Browse files Browse the repository at this point in the history
…line`, close #423 (#431)

* fix(plugin-md-power): incorrect rendering heading from `demo` in `outline`, close #423

* chore: tweak
  • Loading branch information
pengzhanbo authored Jan 21, 2025
1 parent f81c011 commit 4a39d39
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/plugin-md-power/src/node/demo/supports/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function compileScript(source: string, type: 'ts' | 'js'): Promise<
const transform = await compiler.script()
const res = await transform(source, {
target: 'es2018',
platform: 'browser',
format: 'cjs',
loader: type === 'ts' ? 'ts' : 'js',
sourcemap: false,
Expand Down
2 changes: 1 addition & 1 deletion theme/src/client/composables/outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function useHeaders(): Ref<MenuItem[]> {

export function getHeaders(range?: ThemeOutline): MenuItem[] {
const headers = Array.from(
document.querySelectorAll('.vp-doc :where(h1,h2,h3,h4,h5,h6)'),
document.querySelectorAll('.vp-doc :where(h1,h2,h3,h4,h5,h6):not(.vp-demo-wrapper :where(h1,h2,h3,h4,h5,h6))'),
)
.filter(el => el.id && el.hasChildNodes())
.map((el) => {
Expand Down

0 comments on commit 4a39d39

Please sign in to comment.