This commit is contained in:
syuilo 2021-01-10 11:40:13 +09:00
parent 0ff714d11e
commit ec6c93b082
3 changed files with 43 additions and 12 deletions

View File

@ -58,7 +58,7 @@ export default defineComponent({
created() { created() {
os.api('endpoints').then(endpoints => { os.api('endpoints').then(endpoints => {
this.endpoints = endpoints; this.endpoints = endpoints.map(x => x.name);
}); });
}, },

View File

@ -1,15 +1,17 @@
<template> <template>
<div> <div class="smzyuecx">
<main class="_section"> <div class="tags">
<div class="_content"> <button v-for="tag in tags" :key="tag" class="tag _button">
{{ tag }}
</button>
</div>
<ul> <ul>
<li v-for="endpoint in endpoints" :key="endpoint"> <li v-for="endpoint in endpoints" :key="endpoint.name">
<MkA :to="`/api-docs/endpoints/${endpoint}`">{{ endpoint }}</MkA> <MkA :to="`/api-docs/endpoints/${endpoint.name}`">{{ endpoint.name }}</MkA>
</li> </li>
</ul> </ul>
</div> </div>
</main>
</div>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -26,6 +28,7 @@ export default defineComponent({
icon: faQuestionCircle icon: faQuestionCircle
}, },
endpoints: [], endpoints: [],
tags: [],
faQuestionCircle faQuestionCircle
} }
}, },
@ -33,7 +36,32 @@ export default defineComponent({
created() { created() {
os.api('endpoints').then(endpoints => { os.api('endpoints').then(endpoints => {
this.endpoints = endpoints; this.endpoints = endpoints;
const tags = new Set();
for (const endpoint of this.endpoints) {
if (endpoint.tags) {
for (const tag of endpoint.tags) {
tags.add(tag);
}
}
}
this.tags = Array.from(tags);
}); });
}, },
}); });
</script> </script>
<style lang="scss" scoped>
.smzyuecx {
> .tags {
> .tag {
display: inline-block;
border: solid 1px var(--divider);
border-radius: 6px;
padding: 12px 16px;
margin: 8px;
}
}
}
</style>

View File

@ -11,5 +11,8 @@ export const meta = {
}; };
export default define(meta, async () => { export default define(meta, async () => {
return endpoints.map(x => x.name); return endpoints.map(x => ({
name: x.name,
tags: x.meta.tags,
}));
}); });