📝: document contributor
更新文档
This commit is contained in:
80
package/document/src/components/LayContributor.vue
Normal file
80
package/document/src/components/LayContributor.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<template>
|
||||
<div class="contributor">
|
||||
<lay-tooltip
|
||||
:content="contributor.login"
|
||||
v-for="contributor in contributors"
|
||||
:key="contributor.id"
|
||||
:is-dark="false"
|
||||
>
|
||||
<a :href="contributor.htmlUrl" target="_blank">
|
||||
<lay-avatar :src="contributor.avatarUrl" radius></lay-avatar>
|
||||
</a>
|
||||
</lay-tooltip>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import axios from "axios";
|
||||
import { Ref, ref } from "vue";
|
||||
|
||||
export interface LayContributor {
|
||||
filePath: string;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<LayContributor>(), {
|
||||
filePath: "",
|
||||
});
|
||||
|
||||
const suffix = ".md";
|
||||
const githubAPI = "https://api.github.com/repos/layui/layui-vue/commits?path=/package/document/src/document/zh-CN/components/";
|
||||
const contributors: Ref<any> = ref([]);
|
||||
|
||||
var compare = function (x: any, y: any) {
|
||||
if (x.commits < y.commits) {
|
||||
return 1;
|
||||
} else if (x.commits > y.commits) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
const fetchContributors = () => {
|
||||
axios.get(githubAPI + props.filePath + suffix).then((result) => {
|
||||
const topic: any[] = [];
|
||||
result.data.forEach((item: any) => {
|
||||
if (item.committer) {
|
||||
const itemdata = {
|
||||
id: item.committer["id"],
|
||||
login: item.committer["login"],
|
||||
avatarUrl: item.committer["avatar_url"],
|
||||
htmlUrl: item.committer["html_url"],
|
||||
commits: 1,
|
||||
};
|
||||
if (topic.some((e) => e.id == itemdata.id)) {
|
||||
topic.forEach((item) => {
|
||||
if (item.id === itemdata.id) {
|
||||
item.commits = item.commits + 1;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
topic.push(itemdata);
|
||||
}
|
||||
}
|
||||
});
|
||||
contributors.value = topic.sort(compare);
|
||||
});
|
||||
};
|
||||
|
||||
fetchContributors();
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.contributor {
|
||||
text-align: left;
|
||||
margin: 30px 20px;
|
||||
}
|
||||
.contributor img {
|
||||
margin: 5px;
|
||||
}
|
||||
</style>
|
||||
@@ -115,5 +115,8 @@ export default {
|
||||
|
||||
:::
|
||||
|
||||
::: contributor animation
|
||||
:::
|
||||
|
||||
::: previousNext animation
|
||||
:::
|
||||
@@ -136,5 +136,8 @@ export default {
|
||||
|
||||
:::
|
||||
|
||||
::: contributor avatar
|
||||
:::
|
||||
|
||||
::: previousNext avatar
|
||||
:::
|
||||
|
||||
@@ -131,5 +131,8 @@ export default {
|
||||
|
||||
:::
|
||||
|
||||
::: contributor backtop
|
||||
:::
|
||||
|
||||
::: previousNext backtop
|
||||
:::
|
||||
@@ -87,7 +87,8 @@ export default {
|
||||
|
||||
:::
|
||||
|
||||
|
||||
::: contributor badge
|
||||
:::
|
||||
|
||||
::: previousNext badge
|
||||
:::
|
||||
@@ -110,7 +110,8 @@ export default {
|
||||
|
||||
:::
|
||||
|
||||
|
||||
::: contributor breadcrumb
|
||||
:::
|
||||
|
||||
::: previousNext breadcrumb
|
||||
:::
|
||||
@@ -369,7 +369,8 @@ export default {
|
||||
|
||||
:::
|
||||
|
||||
|
||||
::: contributor button
|
||||
:::
|
||||
|
||||
::: previousNext button
|
||||
:::
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<li>
|
||||
<h3>1.2.0 <span class="layui-badge-rim">2022-06-21</span></h3>
|
||||
<ul>
|
||||
<li>[新增] dropdown 组件 placement 属性, 设置下拉面板位置</li>
|
||||
<li>[新增] dropdown 组件 placement 属性, 设置下拉面板位置。</li>
|
||||
<li>[新增] dropdown 组件 autoFitPosition 属性, 超出浏览器边界自动调整下拉面板位置, 默认为 true。</li>
|
||||
<li>[新增] dropdown 组件 autoFitWidth 与 autoFitMinWidth 属性, 是否将下拉面板宽度与最小宽度设置为触发器宽度, 默认 false。</li>
|
||||
<li>[新增] dropdown 组件 updateAtScroll 属性, 是否在容器滚动时更新下拉面板的位置,默认 false。</li>
|
||||
@@ -27,7 +27,7 @@
|
||||
<li>[修复] progress 组件 circle 模式夜间主题不兼容的问题。</li>
|
||||
<li>[新增] carousel 组件 过渡动画,默认为滑动。</li>
|
||||
<li>[修复] carousel 组件 autoplay 属性为false时仍自动播放问题。</li>
|
||||
<li>[修复] cascader 按需加载无法正常引入使用。</li>
|
||||
<li>[修复] cascader 组件 按需加载无法正常引入使用。</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -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 };
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
31
package/document/src/plugin/contributor.ts
Normal file
31
package/document/src/plugin/contributor.ts
Normal file
@@ -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 `<lay-contributor file-path='${info}'></lay-contributor>`;
|
||||
} else {
|
||||
return ``;
|
||||
}
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user