Skip to content

Commit

Permalink
feat(post): better posts dir structure with images
Browse files Browse the repository at this point in the history
  • Loading branch information
Octobug committed Nov 17, 2023
1 parent a556af7 commit 0805ba9
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 17 deletions.
26 changes: 13 additions & 13 deletions .vitepress/config.theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ export default {
},
},
nav: [
{
text: "POSTS",
link: "/pages/posts",
},
// {
// text: "POSTS",
// link: "/pages/posts",
// },
// {
// text: "VISIONS",
// link: "/pages/visions",
// },
{
text: "TAGS",
link: "/pages/tags",
},
{
text: "SORTS",
link: "/pages/sorts",
},
// {
// text: "TAGS",
// link: "/pages/tags",
// },
// {
// text: "SORTS",
// link: "/pages/sorts",
// },
{
text: "REPO",
link: "https://github.com/Octobug/blog",
Expand Down Expand Up @@ -80,5 +80,5 @@ export default {
location: "Shenzhen, China",
timezone: "Asia/Shanghai",
pageSize: 13,
mdfilePatterns: ["posts/*.md"]
mdfilePatterns: ["posts/**/*.md"]
} satisfies ThemeConfig;
3 changes: 3 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export default defineConfigWithTheme<ThemeConfig>({
},
],
],
rewrites: {
":postsdir/:title/README.md": ":postsdir/:title.md",
},
srcExclude: [
"./.github/",
"./README.md",
Expand Down
5 changes: 4 additions & 1 deletion .vitepress/theme/components/PostHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
>
{{ post.location }}
</span>
<Dot :class="$style.dot" />
<Dot
v-if="post.readingTime"
:class="$style.dot"
/>
<span :class="$style.elementItem">
{{ post.readingTime }}
</span>
Expand Down
1 change: 1 addition & 0 deletions .vitepress/theme/posts.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default createContentLoader(extendedConfig.mdfilePatterns, {
return rawData.map(p => {
p.frontmatter.datetime = new Date(p.frontmatter.date);
p.frontmatter.readingTime = readingTime(p.src || "").text;
p.url = p.url.replace("/README", "");
return p;
}).sort((a, b) => {
return b.frontmatter.datetime - a.frontmatter.datetime;
Expand Down
18 changes: 16 additions & 2 deletions .vitepress/theme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@
* Custom CSS
* -------------------------------------------------------------------------- */

:root {
:root {
/* Custom vars */
--ct-c-shadow: #d7d7d7;

/* Profile */
--ct-avatar-border: #ffffff;
--ct-avatar-large: 10rem;
Expand All @@ -156,5 +158,17 @@ header a.title {
}

footer a {
color: var(--vp-c-neutral);
color: var(--vp-c-text-1);
}

/* CSS for a Post */
.main img {
border-radius: 0.5rem;
box-shadow: 0 0.5rem 0.8rem var(--ct-c-shadow);
margin-bottom: 2rem;
}

.dark .main img {
border: 0.1rem solid var(--vp-c-neutral);
box-shadow: none;
}
9 changes: 8 additions & 1 deletion posts/pilot.md → posts/pilot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ tags:
- Small Talk
---

![Pilot Whale](./pilot-whale.jpg)

为了让这篇成为博客的第一篇文章,我写了个假日期。这个日期是我从珠海搬到深圳的日子,算是一个新的开始。

## 旧博客
Expand Down Expand Up @@ -45,14 +47,19 @@ tags:

::: details Pilot?

“Pilot”经常被用作剧集第一集的名字 [[1],[2]],中文可以译为“试播集”。
- "Pilot" 经常被用作剧集第一集的名字 [[1],[2]],中文可以译为“试播集”。
- 题图中的鲸鱼是领航鲸 (Pilot Whale) [[3]],图片来源 [[4]]

:::

## References

1. [Television pilot [Wikipedia]][1]
2. [List of television episodes titled Pilot [Wikipedia]][2]
3. [Pilot whale [Wikipedia]][3]
4. [Days Like Today Are Why I Want to Live Forever! [SDM adventures]][4]

[1]: <https://en.wikipedia.org/wiki/Television_pilot>
[2]: <https://en.wikipedia.org/wiki/List_of_television_episodes_titled_Pilot>
[3]: <https://en.wikipedia.org/wiki/Pilot_whale>
[4]: <https://sdmdiving.com/wildlife-travel-blog/tag/pilot+whale+diving>
Binary file added posts/pilot/pilot-whale.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0805ba9

Please sign in to comment.