feat: add titleTemplate to generate locale title

This commit is contained in:
YunYouJun 2022-11-29 06:28:37 +08:00
parent a4e201c534
commit d91a17f52b
27 changed files with 57 additions and 41 deletions

View File

@ -1,6 +1,6 @@
---
title: Demo Sites
title_zh: 站点示例
title_zh-CN: 站点示例
layout: docs
categories:
- Docs

View File

@ -1,6 +1,6 @@
---
title: Why Addon?
title_zh: 为什么需要插件
title_zh-CN: 为什么需要插件
categories:
- Addon
---

View File

@ -1,6 +1,6 @@
---
title: Use Addon
title_zh: 使用插件
title_zh-CN: 使用插件
categories:
- Addon
---

View File

@ -1,6 +1,6 @@
---
title: Write a Addon
title_zh: 编写一个插件
title_zh-CN: 编写一个插件
categories:
- Addon
---

View File

@ -1,6 +1,6 @@
---
title: FAQ
title_zh: 常见问题
title_zh-CN: 常见问题
categories:
- Dev
end: false

View File

@ -1,6 +1,6 @@
---
title: Participate in Development
title_zh: 参与开发
title_zh-CN: 参与开发
categories:
- Dev
end: false

View File

@ -1,6 +1,6 @@
---
title: FAQ
title_zh: 常见问题
title_zh-CN: 常见问题
categories:
- Guide
end: false

View File

@ -1,6 +1,6 @@
---
title: Components
title_zh: 组件
title_zh-CN: 组件
categories:
- Guide
end: false

View File

@ -1,6 +1,6 @@
---
title: Commands
title_zh: 命令行
title_zh-CN: 命令行
categories:
- Guide
top: 99

View File

@ -1,6 +1,6 @@
---
title: Config
title_zh: 配置
title_zh-CN: 配置
categories:
- Guide
end: false

View File

@ -1,5 +1,5 @@
---
title_zh: 容器
title_zh-CN: 容器
title: Container
categories:
- Guide

View File

@ -1,6 +1,6 @@
---
title: Extend
title_zh: 自定义扩展
title_zh-CN: 自定义扩展
categories:
- Custom
end: false
@ -77,20 +77,6 @@ layout: album
同样,当存在同名布局时,覆盖顺序为 `用户目录` -> `主题目录` -> `Valaxy 客户端目录`
## 自动样式注入
新建 `styles` 文件夹,目录下的以下文件将会被自动引入:
- `index.scss`
- `index.css`
- `css-vars.scss`
- `css-vars.css`
我们推荐您:
- 新建 `index.scss` 书写全局样式,并可在其中导入其他样式,它会被自动引入。
- 新建 `css-vars.scss` 书写 CSS 变量,它会被自动引入。
## 自定义 index.html
新建 `index.html`,你可以在 `<head></head>``<body></body>` 全局地插入任意内容。
@ -175,3 +161,7 @@ valaxy new <title> -l [layout]
```bash
valaxy new my-young -l album
```
## 其他
- [自定义样式 | Valaxy](/guide/custom/styles)

View File

@ -0,0 +1,21 @@
---
title: Custom Styles
title_zh-CN: 自定义样式
categories:
- Custom
end: false
---
## 自动样式注入
新建 `styles` 文件夹,目录下的以下文件将会被自动引入:
- `index.scss`
- `index.css`
- `css-vars.scss`
- `css-vars.css`
我们推荐您:
- 新建 `index.scss` 书写全局样式,并可在其中导入其他样式,它会被自动引入。
- 新建 `css-vars.scss` 书写 CSS 变量,它会被自动引入。

View File

@ -1,6 +1,6 @@
---
title: Deploy
title_zh: 部署
title_zh-CN: 部署
categories:
- Getting Started
end: false

View File

@ -1,6 +1,6 @@
---
title: Features
title_zh: 亮点
title_zh-CN: 亮点
categories:
- Getting Started
end: false

View File

@ -1,6 +1,6 @@
---
title: Getting Started
title_zh: 开始
title_zh-CN: 开始
categories:
- Getting Started
end: true

View File

@ -1,6 +1,6 @@
---
title: i18n in One Page
title_zh: 单页 i18n
title_zh-CN: 单页 i18n
categories:
- Guide
---

View File

@ -1,6 +1,6 @@
---
title: Post
title_zh: 文章
title_zh-CN: 文章
categories:
- Guide
---

View File

@ -1,6 +1,6 @@
---
title: Third Party
title_zh: 第三方集成
title_zh-CN: 第三方集成
categories:
- Third
end: false

View File

@ -1,7 +1,7 @@
---
cover: https://fastly.jsdelivr.net/gh/YunYouJun/cdn/img/bg/girl-in-water-tank.webp
title: Why Valaxy
title_zh: 为什么选 Valaxy
title_zh-CN: 为什么选 Valaxy
date: 2022-03-22
updated: 2022-03-23
categories:

View File

@ -1,5 +1,5 @@
---
title_zh: 从 Hexo 迁移至 Valaxy
title_zh-CN: 从 Hexo 迁移至 Valaxy
title: Migrate from Hexo to Valaxy
categories:
- Migration

View File

@ -1,6 +1,6 @@
---
title: Valaxy Themes Gallery
title_zh: Valaxy 主题橱窗
title_zh-CN: Valaxy 主题橱窗
categories:
- Theme
end: false

View File

@ -1,6 +1,6 @@
---
title: Use Theme
title_zh: 使用主题
title_zh-CN: 使用主题
categories:
- Theme
top: 100

View File

@ -1,6 +1,6 @@
---
title: How to write a theme?
title_zh: 如何编写一个 Valaxy 主题
title_zh-CN: 如何编写一个 Valaxy 主题
categories:
- Theme
end: false

View File

@ -23,7 +23,7 @@ const collapsable = ref(props.collapsable)
const { t, locale } = useI18n()
const getTitle = (post: Post | any) => {
const lang = locale.value === 'zh-CN' ? 'zh' : locale.value
const lang = locale.value
return post[`title_${lang}`] ? post[`title_${lang}`] : post.title
}
</script>

View File

@ -43,7 +43,7 @@ const themeConfig = useThemeConfig()
}
.dark {
--pr-navbar-c-bg: rgba(36, 36, 36, 0.8);
--pr-navbar-c-bg: rgba(24, 24, 24, 0.8);
}
.press-navbar {

View File

@ -6,6 +6,7 @@ import ValaxyUserApp from '/@valaxyjs/UserAppVue'
// @ts-expect-error virtual module
import ValaxyThemeApp from '/@valaxyjs/ThemeAppVue'
import pkg from 'valaxy/package.json'
import { useI18n } from 'vue-i18n'
import ValaxyAddons from './components/ValaxyAddons.vue'
import { isDark, useFrontmatter } from './composables'
@ -19,8 +20,13 @@ import { useConfig } from './config'
const config = useConfig()
const themeColor = computed(() => isDark.value ? '#00aba9' : '#ffffff')
const fm = useFrontmatter()
const { locale } = useI18n()
useHead({
title: config.value.title,
title: computed(() => fm.value[`title_${locale.value}`] || fm.value.title),
titleTemplate: title => title ? `${title} - ${config.value.title}` : config.value.title,
link: [
{
rel: 'icon',
@ -47,7 +53,6 @@ useHead({
// seo
// todo: get first image url from markdown
const fm = useFrontmatter()
useSeoMeta({
description: computed(() => fm.value.excerpt || config.value.description),
ogDescription: computed(() => fm.value.excerpt || config.value.description),