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,14 +1,16 @@
<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">
<ul> {{ tag }}
<li v-for="endpoint in endpoints" :key="endpoint"> </button>
<MkA :to="`/api-docs/endpoints/${endpoint}`">{{ endpoint }}</MkA> </div>
</li>
</ul> <ul>
</div> <li v-for="endpoint in endpoints" :key="endpoint.name">
</main> <MkA :to="`/api-docs/endpoints/${endpoint.name}`">{{ endpoint.name }}</MkA>
</li>
</ul>
</div> </div>
</template> </template>
@ -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,
}));
}); });