Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ feat(blog): create blog part #284

Merged
merged 7 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,25 +81,25 @@ const pwaConfig: PwaOptions = {
{
src: "pwa-64x64.png",
sizes: "64x64",
type: "image/png"
type: "image/png",
},
{
src: "pwa-192x192.png",
sizes: "192x192",
type: "image/png"
type: "image/png",
},
{
src: "pwa-512x512.png",
sizes: "512x512",
type: "image/png"
type: "image/png",
},
{
src: "maskable-icon-512x512.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable"
}
]
purpose: "maskable",
},
],
},
workbox: {
globPatterns: ["**/*.{css,js,html,svg,webp,ico,txt,woff2}"],
Expand Down Expand Up @@ -161,6 +161,7 @@ const themeConfig: DefaultTheme.Config = {
nav: [
{ text: "主页", link: "/" },
{ text: "崩溃分析工具", link: "/analyzer" },
{ text: "博客", link: "/blog/" },
{
text: "贡献",
activeMatch: "/contribute/*",
Expand Down Expand Up @@ -319,10 +320,11 @@ export default withPwa(
lineNumbers: true,
config: (md) => {
// @ts-expect-error TS2769
md.use(BiDirectionalLinks({
dir: "docs",
baseDir: "/",
}),
md.use(
BiDirectionalLinks({
dir: "docs",
baseDir: "/",
}),
),
// @ts-expect-error TS2769
md.use(InlineLinkPreviewElementTransform)
Expand All @@ -334,8 +336,11 @@ export default withPwa(
},

head: [
['link', { rel: 'icon', href: '/favicon.ico' }],
['link', { rel: 'apple-touch-icon', href: '/apple-touch-icon-180x180.png' }],
["link", { rel: "icon", href: "/favicon.ico" }],
[
"link",
{ rel: "apple-touch-icon", href: "/apple-touch-icon-180x180.png" },
],
[
"script",
{
Expand Down
2 changes: 2 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { h } from "vue"
// Components
import LauncherBadge from "./global-components/LauncherBadge.vue"
import ReloadPrompt from "./components/ReloadPrompt.vue"
import Posts from "./layouts/Posts.vue"

// Plugins
import giscusTalk from "vitepress-plugin-comment-with-giscus"
Expand Down Expand Up @@ -56,6 +57,7 @@ export default {
threshold: 300,
})
ctx.app.component("LauncherBadge", LauncherBadge)
ctx.app.component("Posts", Posts)
vitepressNprogress(ctx)
ctx.app.component("vImageViewer", vImageViewer)
ctx.app.use(NolebaseInlineLinkPreviewPlugin)
Expand Down
14 changes: 14 additions & 0 deletions .vitepress/theme/layouts/Posts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script lang="ts" setup>
import { data as posts } from "../../utils/posts.data"
</script>

<template>
<div v-for="post in posts" :key="post.url">
<a :href="post.url">
{{ post.title }}
</a>
<!-- <div v-html="post.excerpt"></div> -->
</div>
</template>

<style scoped></style>
23 changes: 23 additions & 0 deletions .vitepress/utils/posts.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { createContentLoader } from "vitepress"

interface Post {
title: string
url: string
date: string
excerpt: string | undefined
}
declare const data: Post[]
export { data }

export default createContentLoader("blog/*.md", {
// Options
excerpt: true,
transform(raw): Post[] {
return raw.map(({ url, frontmatter, excerpt }) => ({
title: frontmatter.title,
url,
date: frontmatter.date,
excerpt,
}))
},
})
27 changes: 27 additions & 0 deletions docs/blog/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
sidebar: false
---

# 博客板块

本板块包含了 GlobeMC 团队的一些博客文章,有助于提升读者的 Debug 能力,有兴趣的读者可以关注一下。

---

<Posts />

---

# 贡献提醒

欢迎大家参与到 GlobeMC 团队的博客文章的编写中来,博客文章的排版规范以本文档排版规范为准。

Frontmatter 格式如下:

```markdown
---
sidebar: false
title: 文章标题
date: 2024-06-22 19:11:00
---
```
15 changes: 15 additions & 0 deletions docs/blog/post1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
sidebar: false
title: Post1
date: 2021-01-01T00:00:00Z
---

# Post1

This is the first post.

---

Some text here.

This is the end of the first post.
4 changes: 4 additions & 0 deletions docs/contribute/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ git clone https://github.com/{yourname}/crashmc.com.git

我们会每周进行一次例行 merge,将所有已完成的更改合并到生产环境 `main` branch,因此请不要将您的更改 PR 到 `main` branch,这会增大我们的代码审查和文档部署工作量。

## 其他提醒

如果要提交博客内容,请参考 [博客主页](https://crashmc.com/blog/) 的贡献指南。

## 鸣谢

感谢所有为 CrashMC 贡献内容的玩家和开发者,你们的支持是对 CrashMC 最大的鼓励。
2 changes: 2 additions & 0 deletions docs/contribute/crash-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ contributors: [bingling-sama]

如果您遇到的问题无法在本文档中找到答案,可以点击[这里](https://github.com/GlobeMC/crashmc.com/issues/new/choose)向我们提交您的错误报告,我们将尽快为您解决问题。同时,您所上传的崩溃日志也将作为改进文档的资料使用,感谢您为本文档提供数据。

如果您遇到的问题已经解决,或您已经找到了可行的解决方案,希望您一并填入 Issue 中,感谢您的贡献。

为了方便我们为您检索问题,在上传 `*.log`/`*.txt` 等文本格式文件时,请优先前往 [MCLogs](https://mclo.gs) 上传文件内容并向我们提供网站生成的链接。

:::info 注意
Expand Down