-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(website): 🌱 Add tags page with counts
- Loading branch information
1 parent
4ca4a07
commit ba35e5e
Showing
4 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<!-- .vuepress/components/TagList.vue --> | ||
<template lang="html"> | ||
<div> | ||
<h1> | ||
Tags <Badge type="error" :text="tagcount"/> | ||
</h1> | ||
|
||
<span v-for="tag in Object.keys(tags)"> | ||
<h2 :id="tag"> | ||
<router-link | ||
:to="{ path: `/tags.html/#${tag}`}" | ||
class="header-anchor" | ||
aria-hidden="true" | ||
> | ||
# | ||
</router-link> | ||
<Badge vertical="middle" type="tip" :text="tag"/> | ||
<Badge type="error" :text="tags[tag].length"/> | ||
<!-- <Badge type="warning" :text="tags[tag].length"/> --> | ||
</h2> | ||
|
||
<ul class="w3-ul w3-hoverable"> | ||
<li v-for="page in tags[tag]"> | ||
<router-link :to="{ path: page.path}"> | ||
{{page.title}} | ||
</router-link> | ||
</li> | ||
</ul> | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
// data () { | ||
// return { | ||
// dtags: this.tags[tag] | ||
// } | ||
// }, | ||
computed: { | ||
tags() { | ||
let tags = {} | ||
for (let page of this.$site.pages) { | ||
for (let index in page.frontmatter.tags) { | ||
const tag = page.frontmatter.tags[index] | ||
if (tag in tags) { | ||
tags[tag].push(page) | ||
} else { | ||
tags[tag] = [page] | ||
} | ||
} | ||
} | ||
return tags | ||
}, | ||
tagcount () { | ||
return Object.keys(this.tags).length; | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<TagList /> |