feat(docs):1.md目录组件 2.由于body变窄,修改md table初始宽度

This commit is contained in:
sight
2021-12-30 00:44:43 +08:00
parent 9d4f26d664
commit ee4c5ebb0c
54 changed files with 371 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ import createBlock from './create-block'
import createDescribe from './create-describe'
import createTable from './create-table'
import createComment from './create-comment'
import createAnchor from './create-anchor'
import preWrapper from './pre-wrapper'
const plugins = [
@@ -31,6 +32,7 @@ const plugins = [
.use(...createTitle('title', ''))
.use(...createDescribe('describe', ''))
.use(...createComment('comment', ''))
.use(...createAnchor('anchor', ''))
},
}),
] as any

View File

@@ -0,0 +1,38 @@
import container from "markdown-it-container";
import type Token from "markdown-it/lib/token";
type ContainerArgs = [
typeof container,
string,
{
render(tokens: Token[], idx: number): string;
}
];
export default function createContainer(
klass: string,
defaultTitle: string
): ContainerArgs {
return [
container,
klass,
{
render(tokens, idx) {
const token = tokens[idx];
if (token.nesting === 1) {
const anchors = [];
for (const token of tokens) {
if (token.nesting === 1 && token.info.includes("title")) {
const info = token.info.trim().slice(klass.length).trim();
anchors.push(info);
}
}
// 此处仅支持 string | number | boolean 类型
return `<lay-aside-anchor anchors="${anchors}" :currIndex="-1" :show="true">`;
} else {
return "</lay-aside-anchor>\n";
}
},
},
];
}

View File

@@ -17,11 +17,11 @@ export default function createContainer(
container,
klass,
{
render(tokens, idx) {
render(tokens, idx) {
const token = tokens[idx]
const info = token.info.trim().slice(klass.length).trim()
if (token.nesting === 1) {
return `<lay-field title="${
return `<lay-field id="${info || defaultTitle}" title="${
info || defaultTitle
}" style="margin-top:20px;margin-bottom: 20px;">`
} else {