doc: update doc layout

v2.3
tangjinzhou 2021-09-23 17:09:55 +08:00
parent bd05fda435
commit 62c0732d8d
2 changed files with 11 additions and 6 deletions

View File

@ -142,9 +142,14 @@ export default defineComponent({
const docHtml = computed(() =>
props.jsfiddle && props.jsfiddle.docHtml
? (
props.jsfiddle.docHtml
.replace('<h2 id="zh-CN">zh-CN</h2>', '')
.split('<h2 id="en-US">en-US</h2>')[globalConfig.isZhCN.value ? 0 : 1] || ''
props.jsfiddle.docHtml.replace(
`<h2 id="zh-CN">zh-CN <a class="header-anchor" href="#zh-CN">
<span aria-hidden="true" class="anchor">#</span>
</a></h2>`,
'',
).split(`<h2 id="en-US">en-US <a class="header-anchor" href="#en-US">
<span aria-hidden="true" class="anchor">#</span>
</a></h2>`)[globalConfig.isZhCN.value ? 0 : 1] || ''
).trim()
: '',
);

View File

@ -34,15 +34,15 @@ export default defineComponent({
return props?.pageData?.html || '';
});
const description = computed(() => {
return docHtml.value.split('<h2 id="API">API</h2>')[0];
return docHtml.value.split('<h2 id="API">API <a class="header-anchor" href="#API">')[0];
});
const api = computed(() => {
return `
<h2 id="API"><span>API</span><a href="#API" class="anchor">#</a></h2>
${docHtml.value.split('<h2 id="API">API</h2>')[1]}
${docHtml.value.split('<h2 id="API">API <a class="header-anchor" href="#API">')[1]}
`;
});
return { frontmatter, description, api, route, showAd };
return { frontmatter, description, api, route, showAd, docHtml };
},
});
</script>