Skip to content

Commit ac03309

Browse files
committed
Add tags links
1 parent 72cb2f5 commit ac03309

File tree

6 files changed

+65
-5
lines changed

6 files changed

+65
-5
lines changed

content/posts/a-post-with-a-cover.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: A post with a cover image
33
date: 2019-01-07
44
published: true
5-
tags: ['Markdown']
5+
tags: ['Markdown', 'Cover Image']
66
series: false
77
cover_image: ./images/alexandr-podvalny-220262-unsplash.jpg
88
canonical_url: false

content/posts/markdown-test-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Markdown test files
33
date: 2019-02-06
44
published: true
5-
tags: ['Markdown']
5+
tags: ['Markdown','Test files']
66
canonical_url: false
77
description: "Markdown is intended to be as easy-to-read and easy-to-write as is feasible. Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions."
88
---

src/components/PostCard.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,23 @@
66
<div class="post-card__content">
77
<h2 class="post-card__title" v-html="post.title" />
88
<p class="post-card__description" v-html="post.description" />
9+
910
<PostMeta class="post-card__meta" :post="post" />
11+
<PostTags class="post-card__tags" :post="post" />
12+
1013
<g-link class="post-card__link" :to="post.path">Link</g-link>
1114
</div>
1215
</div>
1316
</template>
1417

1518
<script>
1619
import PostMeta from '~/components/PostMeta'
20+
import PostTags from '~/components/PostTags'
21+
1722
export default {
1823
components: {
19-
PostMeta
24+
PostMeta,
25+
PostTags
2026
},
2127
props: ['post'],
2228
}
@@ -53,6 +59,11 @@ export default {
5359
box-shadow: 1px 10px 30px 0 rgba(0,0,0,.1);
5460
}
5561
62+
&__tags {
63+
z-index: 1;
64+
position: relative;
65+
}
66+
5667
&__link {
5768
position: absolute;
5869
top: 0;

src/components/PostTags.vue

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<template>
2+
<div class="post-tags">
3+
<g-link class="post-tags__link" v-for="tag in post.tags" :key="tag.id" :to="tag.path">
4+
<span>#</span> {{ tag.title }}
5+
</g-link>
6+
</div>
7+
</template>
8+
9+
<script>
10+
export default {
11+
props: ['post']
12+
}
13+
</script>
14+
15+
<style lang="scss">
16+
.post-tags {
17+
margin: 1em 0 0;
18+
19+
&__link {
20+
margin-right: 1em;
21+
font-size: .8rem;
22+
color: currentColor;
23+
text-decoration: none;
24+
background-color: var(--bg-color);
25+
padding: .5em;
26+
border-radius: var(--radius);
27+
}
28+
}
29+
</style>

src/pages/Index.vue

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,20 @@ query {
2727
id
2828
title
2929
path
30+
tags {
31+
id
32+
title
33+
path
34+
}
3035
date (format: "D. MMMM YYYY")
3136
timeToRead
3237
description
3338
coverImage (width: 770, height: 380, blur: 10)
39+
...on Post {
40+
id
41+
title
42+
path
43+
}
3444
}
3545
}
3646
}

src/templates/Post.vue

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@
66
</h1>
77

88
<PostMeta :post="$page.post" />
9+
910
</div>
1011

1112
<div class="post content-box">
1213
<div class="post__header">
1314
<g-image v-if="$page.post.coverImage" :src="$page.post.coverImage" />
1415
</div>
16+
1517
<div class="post__content" v-html="$page.post.content" />
18+
1619
<div class="post__footer">
17-
<!-- Add anything here -->
20+
<PostTags :post="$page.post" />
1821
</div>
1922
</div>
2023

@@ -28,12 +31,14 @@
2831

2932
<script>
3033
import PostMeta from '~/components/PostMeta'
34+
import PostTags from '~/components/PostTags'
3135
import Author from '~/components/Author.vue'
3236
3337
export default {
3438
components: {
3539
Author,
36-
PostMeta
40+
PostMeta,
41+
PostTags
3742
}
3843
}
3944
</script>
@@ -45,6 +50,11 @@ query Post ($path: String!) {
4550
path
4651
date (format: "D. MMMM YYYY")
4752
timeToRead
53+
tags {
54+
id
55+
title
56+
path
57+
}
4858
description
4959
content
5060
coverImage (width: 860, blur: 10)

0 commit comments

Comments
 (0)