-
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.
fix(post): stop using frontmatter title
- Loading branch information
Showing
10 changed files
with
106 additions
and
98 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,63 @@ | ||
<template> | ||
<div :class="$style.elementList"> | ||
<span :class="$style.elementItem"> | ||
{{ moment(post.date).format("LL") }} | ||
</span> | ||
<Dot | ||
v-if="post.location" | ||
:class="$style.dot" | ||
/> | ||
<span | ||
v-if="post.location" | ||
:class="$style.elementItem" | ||
> | ||
{{ post.location }} | ||
</span> | ||
<Dot | ||
v-if="post.readingTime" | ||
:class="$style.dot" | ||
/> | ||
<span :class="$style.elementItem"> | ||
{{ post.readingTime }} | ||
</span> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import moment from "moment-timezone"; | ||
import { useData, onContentUpdated } from "vitepress"; | ||
import { ref } from "vue"; | ||
import { data as allPosts } from "../posts.data"; | ||
import { findPost } from "../utils"; | ||
import Dot from "./Dot.vue"; | ||
const { frontmatter, page } = useData(); | ||
let post = ref(getPostData()); | ||
function getPostData() { | ||
return findPost(allPosts, page.value).frontmatter || frontmatter.value; | ||
} | ||
onContentUpdated(() => { | ||
post.value = getPostData(); | ||
}); | ||
</script> | ||
|
||
<style module scoped> | ||
.elementList { | ||
border-top: 1px dashed var(--vp-c-divider); | ||
padding-top: 0.5rem; | ||
margin-top: 3rem; | ||
margin-bottom: -5rem; | ||
font-size: 0.88rem; | ||
} | ||
.elementItem { | ||
color: var(--vp-c-text-3); | ||
} | ||
.dot { | ||
color: var(--vp-c-text-2); | ||
margin: 0.5rem; | ||
} | ||
</style> |
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
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,9 @@ | ||
import { ContentData, PageData } from "vitepress"; | ||
|
||
export function findPostIndex(postList: ContentData[], page: PageData) { | ||
return postList.findIndex(p => p.frontmatter.title === page.title) || 0; | ||
} | ||
|
||
export function findPost(postList: ContentData[], page: PageData) { | ||
return postList[findPostIndex(postList, 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