Skip to content

Commit

Permalink
refactor(post): use pre-defined locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Octobug committed Dec 15, 2023
1 parent 5c1804c commit bd1f54a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 10 deletions.
8 changes: 4 additions & 4 deletions .vitepress/theme/components/PostElements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
{{ moment(post.datetime).format("LL") }}
</span>
<Dot
v-if="post.location"
v-if="post.spot"
:class="$style.dot"
/>
<span
v-if="post.location"
v-if="post.spot"
:class="$style.elementItem"
:tooltip="post.community"
:tooltip="post.location.district"
>
{{ post.location }}
{{ `${post.location.city} ${post.location.spot}` }}
</span>
<Dot
v-if="post.readingTime"
Expand Down
25 changes: 25 additions & 0 deletions .vitepress/theme/locations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const CITY = {
深圳: "深圳",
};

const DISTRICT = {
渔业社区: "宝安区西乡街道渔业社区",
高新区社区: "南山区粤海街道高新区社区",
};

const LOCATIONS = {
财富港: {
city: CITY.深圳,
district: DISTRICT.渔业社区,
spot: "财富港大厦",
},
创维西座: {
city: CITY.深圳,
district: DISTRICT.高新区社区,
spot: "创维半导体设计大厦西座"
}
};

export default function getLocation(spot: string) {
return LOCATIONS[spot] || { spot };
}
2 changes: 2 additions & 0 deletions .vitepress/theme/posts.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createContentLoader, ContentData } from "vitepress";
import readingTime from "reading-time";
import extendedConfig from "../config.theme";
import { withBaseURL } from "../config.utils";
import getLocation from "./locations";

declare const data: ContentData[];
export { data };
Expand All @@ -21,6 +22,7 @@ export default createContentLoader(extendedConfig.mdfilePatterns, {
const rt = readingTime(p.src || "");
p.frontmatter.title = extractTile(p.src || "");
p.frontmatter.datetime = new Date(p.frontmatter.date);
p.frontmatter.location = getLocation(p.frontmatter.spot);
p.frontmatter.readingTime = rt.text;
p.frontmatter.words = rt.words;
p.url = withBaseURL(p.url.replace("/README", ""));
Expand Down
3 changes: 1 addition & 2 deletions posts/an-https-issue-on-adas/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
date: 2019-12-18
location: 深圳 创维半导体设计大厦西座
community: 南山区粤海街道高新区社区
spot: 创维西座
sort: Computer Science
tags:
- Network
Expand Down
3 changes: 1 addition & 2 deletions posts/non-original-content-copyright-issues/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
date: 2023-12-14
location: 深圳 财富港大厦
community: 宝安区西乡街道渔业社区
spot: 财富港
sort: Law
tags:
- Copyright
Expand Down
3 changes: 1 addition & 2 deletions posts/pilot/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
date: 2019-06-02
location: 深圳 财富港大厦
community: 宝安区西乡街道渔业社区
spot: 财富港
sort: Miscellaneous
tags:
- Small Talk
Expand Down

0 comments on commit bd1f54a

Please sign in to comment.