refactor: tags page
This commit is contained in:
parent
3852e0ec03
commit
11562d1701
24
components/templates/tags/Hero.vue
Normal file
24
components/templates/tags/Hero.vue
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<template>
|
||||||
|
<section class="hero is-info">
|
||||||
|
<div class="hero-body">
|
||||||
|
<h1 class="title is-3 has-text-centered">
|
||||||
|
{{ title }}
|
||||||
|
</h1>
|
||||||
|
<p class="subtitle has-text-centered">
|
||||||
|
{{ subTitle }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
import { Vue, Component, Prop } from 'nuxt-property-decorator'
|
||||||
|
|
||||||
|
@Component
|
||||||
|
export default class Hero extends Vue {
|
||||||
|
@Prop({ type: String })
|
||||||
|
title!: string
|
||||||
|
|
||||||
|
@Prop({ type: String })
|
||||||
|
subTitle!: string;
|
||||||
|
}
|
||||||
|
</script>
|
25
components/templates/tags/ListTags.vue
Normal file
25
components/templates/tags/ListTags.vue
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<template>
|
||||||
|
<section class="section">
|
||||||
|
<div class="container">
|
||||||
|
<ul class="columns">
|
||||||
|
<li v-for="tag in tags" :key="tag" class="column">
|
||||||
|
<nuxt-link
|
||||||
|
:to="{ name: 'tags-tag', params: { tag: tag.toLowerCase() } }"
|
||||||
|
class="text-4xl hover:underline"
|
||||||
|
>
|
||||||
|
{{ tag }}
|
||||||
|
</nuxt-link>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
import { Vue, Component, Prop } from 'nuxt-property-decorator'
|
||||||
|
|
||||||
|
@Component
|
||||||
|
export default class ListTags extends Vue {
|
||||||
|
@Prop({ type: Array })
|
||||||
|
tags!: string[]
|
||||||
|
}
|
||||||
|
</script>
|
@ -1,6 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<article class="container content">
|
<article class="container content">
|
||||||
<nuxt-content :document="blogDetail" />
|
<div class="columns">
|
||||||
|
<div class="column">
|
||||||
|
<nuxt-content :document="blogDetail" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</article>
|
</article>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -10,7 +14,7 @@ import global from '@/utils/global'
|
|||||||
import getSiteMeta from '@/utils/getSiteMeta'
|
import getSiteMeta from '@/utils/getSiteMeta'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'ArticlePage',
|
name: 'BlogPage',
|
||||||
async asyncData ({ $content, params }) {
|
async asyncData ({ $content, params }) {
|
||||||
const findedBlog = await $content('blog', { deep: true })
|
const findedBlog = await $content('blog', { deep: true })
|
||||||
.where({ slug: params.slug })
|
.where({ slug: params.slug })
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<section class="section">
|
<section class="section">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-10 is-offset-1">
|
<div class="column">
|
||||||
<FeaturedBlog :first-blog="allArticles[0]" />
|
<FeaturedBlog :first-blog="allArticles[0]" />
|
||||||
<hr>
|
<hr>
|
||||||
<ListBlog :list-blogs="paginatedArticles" />
|
<ListBlog :list-blogs="paginatedArticles" />
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
<template>
|
<template>
|
||||||
<section class="tags-page-wrapper">
|
<div class="container">
|
||||||
<div class="tags-page__header">
|
<section class="section tags-page-wrapper">
|
||||||
<h2>
|
<div class="tags-page__header">
|
||||||
Tag: {{ $route.params.tag }}
|
<h2>
|
||||||
</h2>
|
Tag: {{ $route.params.tag }}
|
||||||
</div>
|
</h2>
|
||||||
<div class="tags-page__content-wrapper">
|
</div>
|
||||||
<ListBlog :list-blogs="blogsByTag" />
|
<div class="tags-page__content-wrapper">
|
||||||
</div>
|
<ListBlog :list-blogs="blogsByTag" />
|
||||||
</section>
|
</div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -1,29 +1,24 @@
|
|||||||
<template>
|
<template>
|
||||||
<section>
|
<div class="container">
|
||||||
<div class="container">
|
<HeroSection
|
||||||
<h1 class="title is-3 mt-3 mb-3 is-flex is-justify-content-center is-align-items-center">
|
title="Tags"
|
||||||
All Tags
|
sub-title="All tags in eHandy"
|
||||||
</h1>
|
/>
|
||||||
<ul class="columns">
|
<ListTags :tags="tags" />
|
||||||
<li v-for="tag in tags" :key="tag" class="column">
|
</div>
|
||||||
<nuxt-link
|
|
||||||
:to="{ name: 'tags-tag', params: { tag: tag.toLowerCase() } }"
|
|
||||||
class="text-4xl hover:underline"
|
|
||||||
>
|
|
||||||
{{ tag }}
|
|
||||||
</nuxt-link>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</section>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { IContentDocument } from '@nuxt/content/types/content'
|
import { IContentDocument } from '@nuxt/content/types/content'
|
||||||
import { Vue, Component } from 'nuxt-property-decorator'
|
import { Vue, Component } from 'nuxt-property-decorator'
|
||||||
|
import Hero from '@/components/templates/tags/Hero.vue'
|
||||||
|
import ListTags from '@/components/templates/tags/ListTags.vue'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
name: 'TagListPage',
|
components: {
|
||||||
|
HeroSection: Hero,
|
||||||
|
ListTags
|
||||||
|
},
|
||||||
async asyncData ({ $content }) {
|
async asyncData ({ $content }) {
|
||||||
function onlyUnique (value: string, index: number, self: string[]) {
|
function onlyUnique (value: string, index: number, self: string[]) {
|
||||||
return self.indexOf(value) === index
|
return self.indexOf(value) === index
|
||||||
|
Loading…
x
Reference in New Issue
Block a user