Skip to content

Commit

Permalink
feat: v3 迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoMouz committed Jun 2, 2024
1 parent beec66a commit 88bf2df
Show file tree
Hide file tree
Showing 50 changed files with 3,610 additions and 276 deletions.
60 changes: 60 additions & 0 deletions docs/.vitepress/components/HomePage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<script setup lang="ts">
import { VPTeamMembers } from "vitepress/theme";
import { computed } from "vue";
import { useTranslate } from "../i18n/composable";
import { iconMap } from "./icons";

const t = useTranslate();

const members = computed(() => [
{
avatar: "https://github.com/tt702.png",
name: "TT702",
title: t("Author"),
links: [
{ icon: "github", link: "https://github.com/TT702" },
{
icon: { svg: iconMap.bilibili },
link: "https://space.bilibili.com/515094",
},
],
},
{
avatar: "https://github.com/imfanhua.png",
name: "Fanhua",
title: t("Team member"),
links: [
{ icon: "github", link: "https://github.com/imfanhua" },
{
icon: { svg: iconMap.bilibili },
link: "https://space.bilibili.com/352711",
},
],
},
{
avatar: "https://github.com/ZhaiSoul.png",
name: "ZhaiSoul",
title: t("Team member"),
links: [{ icon: "github", link: "https://github.com/ZhaiSoul" }],
},
]);
</script>

<template>
<div flex="~ col wrap" mt8 items-center>
<h2 text="center gray xl" mt-11 mb-4 pb-2>
{{ t("BakaXL 开发自") }}
</h2>
<VPTeamMembers size="small" :members="members" />
<!-- <img src="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.wide.svg" />

<h2 text="center lg" my-5 font-bold>
💕
{{ t("Thanks to all the contributors!") }}
</h2>

<a href="https://github.com/vue-macros/vue-macros/graphs/contributors">
<img src="https://contrib.rocks/image?repo=vue-macros/vue-macros" />
</a> -->
</div>
</template>
5 changes: 5 additions & 0 deletions docs/.vitepress/components/NavigationCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script setup lang="ts"></script>
<template>

</template>
<style scoped></style>
64 changes: 64 additions & 0 deletions docs/.vitepress/components/StatusBadge.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<script setup lang="ts">
import { useTranslate } from "../i18n/composable";
import WarnTip from "./WarnTip.vue";

defineProps<{
status: "抢先体验" | "过时文档" | "封存文档";
}>();

const t = useTranslate();
</script>

<template>
<div mt2 flex="~ gap2 wrap">
<small>
{{ `${t("文档目前处在特殊状态")}: ` }}
<Badge v-if="status === '抢先体验'" type="tip" :text="t(status)" />
<Badge
v-else-if="status === '过时文档'"
type="warning"
:text="t(status)"
/>

<Badge
v-else-if="status === '封存文档'"
type="danger"
:text="t(status)"
/>
</small>

<WarnTip v-if="status === '抢先体验'">
{{ t("本文档内功能处于早期阶段") }}
</WarnTip>
<WarnTip v-if="status === '过时文档'">
{{ t("本文档部分内容已不再可靠,请等待更新") }}
</WarnTip>
<WarnTip v-if="status === '封存文档'">
{{ t("本文档已被封存,仅供参考使用,文档所述均已失效或不可保证") }}
</WarnTip>
</div>
</template>

<style scoped>
.pre {
font-size: 0.9em;
background-color: #92de756c;
padding: 0.2em 0.4em;
border-radius: 0.5rem;
color: #b1f748;
}
.old {
font-size: 0.9em;
background-color: #fde0476c;
padding: 0.2em 0.4em;
border-radius: 0.5rem;
color: #fde047;
}
.ach {
font-size: 0.9em;
background-color: #fd59476c;
padding: 0.2em 0.4em;
border-radius: 0.5rem;
color: #fd4747;
}
</style>
5 changes: 5 additions & 0 deletions docs/.vitepress/components/WarnTip.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<span border rounded p-1 text-xs text-yellow-600 dark:text-yellow>
⚠️ <slot />
</span>
</template>
16 changes: 16 additions & 0 deletions docs/.vitepress/components/icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export const iconMap = {
bilibili: ` <svg
width="800px"
height="800px"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M18.223 3.086a1.25 1.25 0 0 1 0 1.768L17.08 5.996h1.17A3.75 3.75 0 0 1 22 9.747v7.5a3.75 3.75 0 0 1-3.75 3.75H5.75A3.75 3.75 0 0 1 2 17.247v-7.5a3.75 3.75 0 0 1 3.75-3.75h1.166L5.775 4.855a1.25 1.25 0 1 1 1.767-1.768l2.652 2.652c.079.079.145.165.198.257h3.213c.053-.092.12-.18.199-.258l2.651-2.652a1.25 1.25 0 0 1 1.768 0zm.027 5.42H5.75a1.25 1.25 0 0 0-1.247 1.157l-.003.094v7.5c0 .659.51 1.199 1.157 1.246l.093.004h12.5a1.25 1.25 0 0 0 1.247-1.157l.003-.093v-7.5c0-.69-.56-1.25-1.25-1.25zm-10 2.5c.69 0 1.25.56 1.25 1.25v1.25a1.25 1.25 0 1 1-2.5 0v-1.25c0-.69.56-1.25 1.25-1.25zm7.5 0c.69 0 1.25.56 1.25 1.25v1.25a1.25 1.25 0 1 1-2.5 0v-1.25c0-.69.56-1.25 1.25-1.25z"
/>
</g>
</svg>`,

};
109 changes: 56 additions & 53 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -1,66 +1,69 @@
import { defineConfig } from "vitepress";
import { getLocaleConfig } from "./configs";
import Unocss from "unocss/vite";

import {
GitChangelog,
GitChangelogMarkdownSection,
} from "@nolebase/vitepress-plugin-git-changelog/vite";

// https://vitepress.dev/reference/site-config
export default defineConfig({
assetsDir: "assets",
head: [["link", { rel: "icon", type: "image/png", href: "/logo.png" }]],
rewrites: {},
locales: {
root: {
label: "简体中文",
title: "BakaXL 帮助中心",
description: "下一代 BakaXL 用户帮助文档中心",
lang: "zh-CN",
themeConfig: {
logo: "/logo.png",
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: "主页", link: "/" },
{ text: "开始使用 BakaXL", link: "/start-use-bakaxl" },
],

sidebar: [
{
text: "案例",
items: [{ text: "Examples", link: "/examples" }],
},
],

socialLinks: [
{
icon: "github",
link: "https://github.com/BakaXL-Support/BakaXL-Next-docs",
root: getLocaleConfig("cn"),
en: getLocaleConfig("en"),
},
themeConfig: {
outline: [1, 4],
search: {
provider: "local",
options: {
locales: {
root: {
translations: {
button: {
buttonText: "搜索文档",
buttonAriaLabel: "搜索文档",
},
modal: {
noResultsText: "无法找到相关结果",
resetButtonTitle: "清除查询条件",
footer: {
selectText: "选择",
navigateText: "切换",
closeText: "关闭",
},
},
},
},
],
},
},
},
en: {
label: "English",
lang: "en-US",
link: "/en/",
title: "BakaXL Help Center",
description: "The next generation of BakaXL user help documentation.",
themeConfig: {
logo: "/logo.png",
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: "Home", link: "/" },
{ text: "Start", link: "/start-use-bakaxl" },
],

sidebar: [
{
text: "Examples",
items: [{ text: "Examples", link: "/examples" }],
},
],

socialLinks: [
{
icon: "github",
link: "https://github.com/BakaXL-Support/BakaXL-Next-docs",
},
],
},
},
vite: {
optimizeDeps: {
include: [
// @rive-app/canvas is a CJS/UMD module, so it needs to be included here
// for Vite to properly bundle it.
"@nolebase/vitepress-plugin-enhanced-readabilities > @nolebase/ui > @rive-app/canvas",
],
exclude: ["@nolebase/vitepress-plugin-enhanced-readabilities/client"],
},
ssr: {
noExternal: [
"@nolebase/vitepress-plugin-enhanced-readabilities",
"@nolebase/vitepress-plugin-highlight-targeted-heading",
],
},
plugins: [
GitChangelog({
repoURL: () => "https://github.com/BakaXL-Support/BakaXL-Next-docs",
}),
GitChangelogMarkdownSection(),
Unocss(),
],
},
});
1 change: 1 addition & 0 deletions docs/.vitepress/configs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./locale";
107 changes: 107 additions & 0 deletions docs/.vitepress/configs/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { createTranslate } from "../i18n/utils";
import type { DefaultTheme, HeadConfig, LocaleConfig } from "vitepress";

export const getLocaleConfig = (lang: string) => {
const t = createTranslate(lang);
const siteLink = "https://next.help.bakaxl.com";
const repoLink = "https://github.com/BakaXL-Support/BakaXL-Next-docs";
const urlPrefix = lang && lang !== "cn" ? `/${lang}` : "";
const title = t("BakaXL 文档中心");
const description = t(
"提供 BakaXL 启动器在使用时疑难解答服务,同时也提供了一些其他的技术文档"
);

const head: HeadConfig[] = [
["meta", { property: "og:title", content: title }],
["meta", { property: "og:description", content: description }],
["meta", { property: "og:image", content: `${siteLink}/og.png` }],
["meta", { property: "og:type", content: "website" }],
["meta", { property: "og:url", content: siteLink }],
["meta", { property: "twitter:card", content: "summary_large_image" }],
["meta", { property: "twitter:image", content: `${siteLink}/og.png` }],
["link", { rel: "icon", type: "image/svg+xml", href: "/favicon.svg" }],
["meta", { name: "theme-color", content: "#914796" }],
];

const nav: DefaultTheme.NavItem[] = [
{ text: `🏠${t("主页")}`, link: urlPrefix + "/" },
{ text: `🍟${t("食用指南")}`, link: urlPrefix + "/v3/" },
{ text: `❓${t("遇到问题?")}`, link: urlPrefix + "/v3/faq" },
{
text: `📚${t("v3 相关文档")}`,
items: [
{
text: `🤔${t("游戏常见问题")}`,
link: urlPrefix + "/v3/minecraft-faq",
},
{
text: `😷${t("游戏版本隔离")}`,
link: urlPrefix + "/v3/minecraft-version-seperation",
},
{
text: `📦${t("制作游戏整合包")}`,
link: urlPrefix + "/v3/modpack-tutorial",
},
{
text: `❌${t("编写规则")}`,
link: urlPrefix + "/v3/write-rule",
},
],
},
{
text: `🦽${t("v3(稳定版)")}`,
items: [
{ text: `🦽${t("v3(稳定版)")}`, link: urlPrefix + "/v3/" },
{ text: `🛰${t("v4(预览版)")}`, link: urlPrefix + "/v4/" },
],
},
];

const themeConfig: DefaultTheme.Config = {
logo: "/favicon.svg",
nav,
socialLinks: [
{
icon: "github",
link: repoLink,
},
],
footer: {
message: t("用💴发电"),
copyright:
'MIT License © 2024-PRESENT <a href="https://github.com/BakaXL-Support">Failure Cat 🐱</a>',
},
editLink: {
pattern: `${repoLink}/edit/main/docs/:path`,
text: t("在 GithuB 上编辑此页"),
},
};

if (lang === "cn") {
Object.assign(themeConfig, {
outline: {
label: "页面导航",
},
lastUpdatedText: "最后更新于",
darkModeSwitchLabel: "外观",
sidebarMenuLabel: "目录",
returnToTopLabel: "返回顶部",
langMenuLabel: "选择语言",
docFooter: {
prev: "上一页",
next: "下一页",
},
} satisfies DefaultTheme.Config);
}

const localeConfig: LocaleConfig<DefaultTheme.Config>[string] = {
label: t("中文"),
lang: t("zh-CN"),
title,
description,
head,
themeConfig,
};

return localeConfig;
};
6 changes: 6 additions & 0 deletions docs/.vitepress/i18n/composable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useData } from "vitepress";
import { t } from "./utils";

export function useTranslate(lang?: string) {
return (key: string) => t(key, lang || useData().lang.value);
}
Loading

0 comments on commit 88bf2df

Please sign in to comment.