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

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

* chore: tweak
This commit is contained in:
pengzhanbo 2025-01-21 11:59:50 +08:00 committed by GitHub
parent f81c011e6a
commit 4a39d39331
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -26,6 +26,7 @@ export async function compileScript(source: string, type: 'ts' | 'js'): Promise<
const transform = await compiler.script() const transform = await compiler.script()
const res = await transform(source, { const res = await transform(source, {
target: 'es2018', target: 'es2018',
platform: 'browser',
format: 'cjs', format: 'cjs',
loader: type === 'ts' ? 'ts' : 'js', loader: type === 'ts' ? 'ts' : 'js',
sourcemap: false, sourcemap: false,

View File

@ -72,7 +72,7 @@ export function useHeaders(): Ref<MenuItem[]> {
export function getHeaders(range?: ThemeOutline): MenuItem[] { export function getHeaders(range?: ThemeOutline): MenuItem[] {
const headers = Array.from( 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()) .filter(el => el.id && el.hasChildNodes())
.map((el) => { .map((el) => {