Skip to content

Commit

Permalink
fix: #899 重构 YAML 部分逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Nov 13, 2023
1 parent 3219fd2 commit 55e52e8
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 118 deletions.
8 changes: 4 additions & 4 deletions package.json
Expand Up @@ -57,8 +57,8 @@
"dependencies": {
"@element-plus/icons-vue": "^2.1.0",
"@terwer/esbuild-config-custom": "^2.0.0",
"@vueuse/components": "^10.6.0",
"@vueuse/core": "^10.6.0",
"@vueuse/components": "^10.6.1",
"@vueuse/core": "^10.6.1",
"chatgpt": "^5.2.5",
"cheerio": "1.0.0-rc.12",
"cross-fetch": "^3.1.8",
Expand All @@ -79,15 +79,15 @@
"vue-i18n": "^9.6.5",
"vue-router": "^4.2.5",
"xmlbuilder2": "^3.1.1",
"zhi-blog-api": "^1.51.2",
"zhi-blog-api": "^1.53.0",
"zhi-common": "^1.28.0",
"zhi-device": "^2.10.0",
"zhi-fetch-middleware": "^0.7.15",
"zhi-github-middleware": "^0.4.12",
"zhi-gitlab-middleware": "^0.6.22",
"zhi-lib-base": "^0.8.0",
"zhi-notion-markdown": "^0.1.4",
"zhi-siyuan-api": "^2.14.3",
"zhi-siyuan-api": "^2.14.5",
"zhi-xmlrpc-middleware": "^0.6.15"
}
}
60 changes: 30 additions & 30 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions src/adaptors/api/hexo/hexoYamlConverterAdaptor.ts
Expand Up @@ -39,9 +39,13 @@ import { toRaw } from "vue"
class HexoYamlConverterAdaptor extends YamlConvertAdaptor {
private readonly logger = createAppLogger("hexo-yaml-converter-adaptor")

public convertToYaml(post: Post, cfg?: BlogConfig): YamlFormatObj {
public convertToYaml(post: Post, yamlFormatObj?: YamlFormatObj, cfg?: BlogConfig): YamlFormatObj {
this.logger.debug("您正在使用 Hexo Yaml Converter", { post: toRaw(post) })
let yamlFormatObj: YamlFormatObj = new YamlFormatObj()
// 没有的情况默认初始化一个
if (!yamlFormatObj) {
yamlFormatObj = new YamlFormatObj()
}

// title
yamlFormatObj.yamlObj.title = post.title

Expand Down
7 changes: 5 additions & 2 deletions src/adaptors/api/hugo/hugoYamlConverterAdaptor.ts
Expand Up @@ -38,9 +38,12 @@ import { toRaw } from "vue"
class HugoYamlConverterAdaptor extends YamlConvertAdaptor {
private readonly logger = createAppLogger("hugo-yaml-converter-adaptor")

public convertToYaml(post: Post, cfg?: BlogConfig): YamlFormatObj {
public convertToYaml(post: Post, yamlFormatObj?: YamlFormatObj, cfg?: BlogConfig): YamlFormatObj {
this.logger.debug("您正在使用 Hugo Yaml Converter", { post: toRaw(post) })
let yamlFormatObj: YamlFormatObj = new YamlFormatObj()
// 没有的情况默认初始化一个
if (!yamlFormatObj) {
yamlFormatObj = new YamlFormatObj()
}

// title
yamlFormatObj.yamlObj.title = post.title
Expand Down
7 changes: 5 additions & 2 deletions src/adaptors/api/jekyll/jekyllYamlConverterAdaptor.ts
Expand Up @@ -39,9 +39,12 @@ import {CommonGithubConfig} from "~/src/adaptors/api/base/github/commonGithubCon
class JekyllYamlConverterAdaptor extends YamlConvertAdaptor {
private readonly logger = createAppLogger("hexo-yaml-converter-adaptor")

public convertToYaml(post: Post, cfg?: BlogConfig): YamlFormatObj {
public convertToYaml(post: Post, yamlFormatObj?: YamlFormatObj, cfg?: BlogConfig): YamlFormatObj {
this.logger.debug("您正在使用 Jekyll Yaml Converter", { post: toRaw(post) })
let yamlFormatObj: YamlFormatObj = new YamlFormatObj()
// 没有的情况默认初始化一个
if (!yamlFormatObj) {
yamlFormatObj = new YamlFormatObj()
}

// layout
yamlFormatObj.yamlObj.layout = "post"
Expand Down
8 changes: 6 additions & 2 deletions src/adaptors/api/vitepress/vitepressYamlConverterAdaptor.ts
Expand Up @@ -38,9 +38,13 @@ import { toRaw } from "vue"
class VitepressYamlConverterAdaptor extends YamlConvertAdaptor {
private readonly logger = createAppLogger("vitepress-yaml-converter-adaptor")

public convertToYaml(post: Post, cfg?: BlogConfig): YamlFormatObj {
public convertToYaml(post: Post, yamlFormatObj?: YamlFormatObj, cfg?: BlogConfig): YamlFormatObj {
this.logger.debug("您正在使用 Vitepress Yaml Converter", { post: toRaw(post) })
let yamlFormatObj: YamlFormatObj = new YamlFormatObj()
// 没有的情况默认初始化一个
if (!yamlFormatObj) {
yamlFormatObj = new YamlFormatObj()
}

// title
yamlFormatObj.yamlObj.title = post.title

Expand Down
8 changes: 6 additions & 2 deletions src/adaptors/api/vuepress/vuepressYamlConverterAdaptor.ts
Expand Up @@ -39,9 +39,13 @@ import { toRaw } from "vue"
class VuepressYamlConverterAdaptor extends YamlConvertAdaptor {
private readonly logger = createAppLogger("vuepress-yaml-converter-adaptor")

public convertToYaml(post: Post, cfg?: BlogConfig): YamlFormatObj {
public (post: Post, yamlFormatObj?: YamlFormatObj, cfg?: BlogConfig): YamlFormatObj {
this.logger.debug("您正在使用 Vuepress Yaml Converter", { post: toRaw(post) })
let yamlFormatObj: YamlFormatObj = new YamlFormatObj()
// 没有的情况默认初始化一个
if (!yamlFormatObj) {
yamlFormatObj = new YamlFormatObj()
}

// title
yamlFormatObj.yamlObj.title = post.title

Expand Down
9 changes: 7 additions & 2 deletions src/adaptors/api/vuepress2/vuepress2YamlConverterAdaptor.ts
Expand Up @@ -42,12 +42,17 @@ class Vuepress2YamlConverterAdaptor extends YamlConvertAdaptor {
* 将文章转换为YAML格式对象
*
* @param post - 要转换的文章对象
* @param yamlFormatObj (可选)
* @param cfg - 博客配置(可选)
* @returns 返回YAML格式对象
*/
public convertToYaml(post: Post, cfg?: BlogConfig): YamlFormatObj {
public convertToYaml(post: Post, yamlFormatObj?: YamlFormatObj, cfg?: BlogConfig): YamlFormatObj {
this.logger.debug("您正在使用 Vuepress2 Yaml Converter", { post: toRaw(post) })
let yamlFormatObj: YamlFormatObj = new YamlFormatObj()
// 没有的情况默认初始化一个
if (!yamlFormatObj) {
yamlFormatObj = new YamlFormatObj()
}

// title
yamlFormatObj.yamlObj.title = post.title

Expand Down

0 comments on commit 55e52e8

Please sign in to comment.