diff --git a/package/document/package.json b/package/document/package.json index 860d2ae7..c252905d 100644 --- a/package/document/package.json +++ b/package/document/package.json @@ -14,7 +14,8 @@ "vue-i18n": "^9.1.10", "@vueuse/core": "^8.7.3", "pinia": "^2.0.14", - "pinia-plugin-persist": "^1.0.0" + "pinia-plugin-persist": "^1.0.0", + "axios": "^0.27.2" }, "devDependencies": { "@types/markdown-it": "^12.2.3", diff --git a/package/document/src/components/LayContributor.vue b/package/document/src/components/LayContributor.vue new file mode 100644 index 00000000..ee039e43 --- /dev/null +++ b/package/document/src/components/LayContributor.vue @@ -0,0 +1,80 @@ + + + + + diff --git a/package/document/src/document/zh-CN/components/animation.md b/package/document/src/document/zh-CN/components/animation.md index a83f1e5f..3f514852 100644 --- a/package/document/src/document/zh-CN/components/animation.md +++ b/package/document/src/document/zh-CN/components/animation.md @@ -115,5 +115,8 @@ export default { ::: +::: contributor animation +::: + ::: previousNext animation ::: \ No newline at end of file diff --git a/package/document/src/document/zh-CN/components/avatar.md b/package/document/src/document/zh-CN/components/avatar.md index 35252a4b..eb6a9e49 100644 --- a/package/document/src/document/zh-CN/components/avatar.md +++ b/package/document/src/document/zh-CN/components/avatar.md @@ -136,5 +136,8 @@ export default { ::: +::: contributor avatar +::: + ::: previousNext avatar ::: diff --git a/package/document/src/document/zh-CN/components/backtop.md b/package/document/src/document/zh-CN/components/backtop.md index 9186e9ea..1f3cfc51 100644 --- a/package/document/src/document/zh-CN/components/backtop.md +++ b/package/document/src/document/zh-CN/components/backtop.md @@ -131,5 +131,8 @@ export default { ::: +::: contributor backtop +::: + ::: previousNext backtop ::: \ No newline at end of file diff --git a/package/document/src/document/zh-CN/components/badge.md b/package/document/src/document/zh-CN/components/badge.md index 322d8d98..efefd67e 100644 --- a/package/document/src/document/zh-CN/components/badge.md +++ b/package/document/src/document/zh-CN/components/badge.md @@ -87,7 +87,8 @@ export default { ::: - +::: contributor badge +::: ::: previousNext badge ::: \ No newline at end of file diff --git a/package/document/src/document/zh-CN/components/breadcrumb.md b/package/document/src/document/zh-CN/components/breadcrumb.md index a84db196..f97415e9 100644 --- a/package/document/src/document/zh-CN/components/breadcrumb.md +++ b/package/document/src/document/zh-CN/components/breadcrumb.md @@ -110,7 +110,8 @@ export default { ::: - +::: contributor breadcrumb +::: ::: previousNext breadcrumb ::: \ No newline at end of file diff --git a/package/document/src/document/zh-CN/components/button.md b/package/document/src/document/zh-CN/components/button.md index 68dc7b20..6ba6cea1 100644 --- a/package/document/src/document/zh-CN/components/button.md +++ b/package/document/src/document/zh-CN/components/button.md @@ -369,7 +369,8 @@ export default { ::: - +::: contributor button +::: ::: previousNext button ::: diff --git a/package/document/src/document/zh-CN/guide/changelog.md b/package/document/src/document/zh-CN/guide/changelog.md index 332489af..b0be322a 100644 --- a/package/document/src/document/zh-CN/guide/changelog.md +++ b/package/document/src/document/zh-CN/guide/changelog.md @@ -16,7 +16,7 @@
  • 1.2.0 2022-06-21

  • diff --git a/package/document/src/main.ts b/package/document/src/main.ts index 902aa710..f979edaf 100644 --- a/package/document/src/main.ts +++ b/package/document/src/main.ts @@ -8,6 +8,7 @@ import LayCode from "./components/LayCode.vue"; import LaySearch from "./components/LaySearch.vue"; import LayTableBox from "./components/LayTableBox.vue"; import LayAnchor from "./components/LayAnchor.vue"; +import LayContributor from "./components/LayContributor.vue"; import "./assets/css/index.css"; export function createApp(): { @@ -24,7 +25,8 @@ export function createApp(): { .component("LayCode", LayCode) .component("LaySearch", LaySearch) .component("LayTableBox", LayTableBox) - .component("LayAnchor", LayAnchor); + .component("LayAnchor", LayAnchor) + .component("LayContributor", LayContributor); return { app, router }; } diff --git a/package/document/src/plugin/common-plugins.ts b/package/document/src/plugin/common-plugins.ts index 5ceb222d..65973d41 100644 --- a/package/document/src/plugin/common-plugins.ts +++ b/package/document/src/plugin/common-plugins.ts @@ -11,6 +11,7 @@ import createTable from "./create-table"; import createAnchor from "./create-anchor"; import preWrapper from "./pre-wrapper"; import previousNext from "./previous-next"; +import contributor from "./contributor"; const plugins = [ vue({ @@ -32,7 +33,8 @@ const plugins = [ .use(...createTitle("title", "")) .use(...createDescribe("describe", "")) .use(...createAnchor("anchor", "")) - .use(...previousNext("previousNext", "")); + .use(...previousNext("previousNext", "")) + .use(...contributor("contributor","")); }, }), ] as any; diff --git a/package/document/src/plugin/contributor.ts b/package/document/src/plugin/contributor.ts new file mode 100644 index 00000000..cce61ea1 --- /dev/null +++ b/package/document/src/plugin/contributor.ts @@ -0,0 +1,31 @@ +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]; + const info = token.info.trim().slice(klass.length).trim(); + if (token.nesting === 1) { + return ``; + } else { + return ``; + } + }, + }, + ]; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6cf842c3..8b58f8c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -99,6 +99,7 @@ importers: '@types/markdown-it-container': ^2.0.4 '@types/prettier': ^2.4.4 '@vueuse/core': ^8.7.3 + axios: ^0.27.2 escape-html: ^1.0.3 markdown-it-container: ^3.0.0 pinia: ^2.0.14 @@ -113,6 +114,7 @@ importers: vue-router: ^4.0.15 dependencies: '@vueuse/core': 8.7.3_vue@3.2.37 + axios: 0.27.2 pinia: 2.0.14_typescript@4.6.3+vue@3.2.37 pinia-plugin-persist: 1.0.0_pinia@2.0.14+vue@3.2.37 vue-i18n: 9.1.10_vue@3.2.37 @@ -2078,6 +2080,19 @@ packages: resolution: {integrity: sha512-p4DO/JXwjs8klJyJL8Q2oM4ks5fUTze/h5k10oPPKMiLe1fj3G1QMzPHNmN1Py4ycOk7WlO2DcGXv1qiESJCZA==} dev: false + /asynckit/0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + dev: false + + /axios/0.27.2: + resolution: {integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==} + dependencies: + follow-redirects: 1.15.1 + form-data: 4.0.0 + transitivePeerDependencies: + - debug + dev: false + /babel-plugin-dynamic-import-node/2.3.3: resolution: {integrity: sha512-jZVI+s9Zg3IqA/kdi0i6UDCybUI3aSBLnglhYbSSjKlV7yF1F/5LWv8MakQmvYpnbJDS6fcBL2KzHSxNCMtWSQ==} dependencies: @@ -2246,6 +2261,13 @@ packages: resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} dev: true + /combined-stream/1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + dependencies: + delayed-stream: 1.0.0 + dev: false + /commitizen/4.2.4: resolution: {integrity: sha512-LlZChbDzg3Ir3O2S7jSo/cgWp5/QwylQVr59K4xayVq8S4/RdKzSyJkghAiZZHfhh5t4pxunUoyeg0ml1q/7aw==} engines: {node: '>= 10'} @@ -2491,6 +2513,11 @@ packages: object-keys: 1.1.1 dev: true + /delayed-stream/1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + dev: false + /detect-file/1.0.0: resolution: {integrity: sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=} engines: {node: '>=0.10.0'} @@ -3110,6 +3137,25 @@ packages: resolution: {integrity: sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==} dev: true + /follow-redirects/1.15.1: + resolution: {integrity: sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==} + engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true + dev: false + + /form-data/4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + dev: false + /fs-extra/10.0.1: resolution: {integrity: sha512-NbdoVMZso2Lsrn/QwLXOy6rm0ufY2zEOKCDzJR/0kBsb0E6qed0P3iYK+Ath3BfvXEeu4JhEtXLgILx5psUfag==} engines: {node: '>=12'} @@ -3734,6 +3780,18 @@ packages: picomatch: 2.3.1 dev: true + /mime-db/1.52.0: + resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} + engines: {node: '>= 0.6'} + dev: false + + /mime-types/2.1.35: + resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} + engines: {node: '>= 0.6'} + dependencies: + mime-db: 1.52.0 + dev: false + /mime/1.6.0: resolution: {integrity: sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==} engines: {node: '>=4'}