-
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.
- Loading branch information
Showing
15 changed files
with
174 additions
and
67 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
--- | ||
category: 服务器 | ||
tags: | ||
- demo | ||
--- | ||
|
||
# demo | ||
|
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
--- | ||
category: 服务器 | ||
tags: | ||
- demo | ||
--- | ||
# demo | ||
|
||
|
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,3 @@ | ||
--- | ||
layout: tags | ||
--- |
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
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
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,96 @@ | ||
<script lang="ts" setup> | ||
import { useUrlSearchParams } from '@vueuse/core'; | ||
import { computed, ref } from 'vue'; | ||
import { useArticleData } from '../hooks/useArticleData'; | ||
import { handleTagsData } from '../utils/client/tags'; | ||
const { articleData } = useArticleData(); | ||
const tagsData = computed(() => { | ||
return handleTagsData(articleData.value); | ||
}); | ||
const params = useUrlSearchParams(); | ||
const selectTag = ref(params.tag); | ||
function toggleTag(tag: string) { | ||
selectTag.value = tag; | ||
params.tag = tag; | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="VSPage"> | ||
<div class="VSContent"> | ||
<div class="tags-wrapper"> | ||
<span | ||
v-for="(tag) in tagsData" | ||
:key="tag.name" | ||
class="tag" | ||
@click="() => toggleTag(tag.name)" | ||
> | ||
{{ tag.name }} <strong>({{ tag.count }})</strong> | ||
</span> | ||
</div> | ||
<div class="tag-header"> | ||
{{ selectTag }} | ||
</div> | ||
</div> | ||
</div> | ||
<!-- <a | ||
v-for="(article, index) in selectTag ? data[selectTag] : []" | ||
:key="index" | ||
:href="withBase(article.path)" | ||
class="posts" | ||
> | ||
<div class="post-container"> | ||
<div class="post-dot" /> | ||
{{ article.title }} | ||
</div> | ||
<div class="date">{{ article.date }}</div> | ||
</a> --> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
.tags-wrapper { | ||
margin-top: 14px; | ||
display: flex; | ||
flex-wrap: wrap; | ||
} | ||
.tag { | ||
display: inline-block; | ||
padding: 4px 16px; | ||
margin: 6px 8px; | ||
font-size: 0.875rem; | ||
line-height: 25px; | ||
background-color: var(--vp-c-bg-alt); | ||
transition: 0.4s; | ||
border-radius: 2px; | ||
color: var(--vp-c-text-1); | ||
cursor: pointer; | ||
border: 1px #00000000 solid; | ||
} | ||
.tag:hover { | ||
border: 1px var(--vp-c-text-3) solid; | ||
} | ||
.tag strong { | ||
color: var(--vp-c-text-2); | ||
} | ||
.tag-header { | ||
font-size: 1.5rem; | ||
font-weight: 500; | ||
margin: 1rem 0; | ||
text-align: left; | ||
} | ||
@media screen and (max-width: 768px) { | ||
.tag-header { | ||
font-size: 1.5rem; | ||
} | ||
.date { | ||
font-size: 0.75rem; | ||
} | ||
} | ||
</style> |
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 @@ | ||
export const NOT_ARTICLE_LAYOUTS = ['blog', 'tags', 'categorys', 'projects', 'home', 'page']; |
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
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,23 @@ | ||
import type { ArticlesData } from '../../datas/articles.data'; | ||
|
||
export function handleTagsData(data: ArticlesData[]) { | ||
const tagsMap = new Map<string, number>(); | ||
data.forEach(item => { | ||
item?.tags?.forEach(tag => { | ||
if (!tagsMap.has(tag)) { | ||
tagsMap.set(tag, 1); | ||
} | ||
else { | ||
tagsMap.set(tag, (tagsMap.get(tag) || 0) + 1); | ||
} | ||
}); | ||
}); | ||
|
||
const tagsData = Array.from(tagsMap, ([key, value]) => { | ||
return { | ||
name: key, | ||
count: value | ||
}; | ||
}); | ||
return tagsData; | ||
} |