-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #390 from terwer/dev
feat: fit latest siyuan note
- Loading branch information
Showing
106 changed files
with
11,987 additions
and
408 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,127 @@ | ||
# zhi-blog-api | ||
|
||
## 1.45.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: not force lowercase | ||
|
||
## 1.44.4 | ||
|
||
### Patch Changes | ||
|
||
- fix: remove same item | ||
|
||
## 1.44.3 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- [email protected] | ||
|
||
## 1.44.2 | ||
|
||
### Patch Changes | ||
|
||
- fix: add search | ||
|
||
## 1.44.1 | ||
|
||
### Patch Changes | ||
|
||
- fix: add search option | ||
|
||
## 1.44.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: add search for getCategories | ||
|
||
## 1.43.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: add mdFilename | ||
|
||
## 1.42.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: add usePathCategory | ||
|
||
## 1.41.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: add useMdFilename | ||
|
||
## 1.40.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: add mdFilename | ||
|
||
## 1.39.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: export TagInfo | ||
|
||
## 1.38.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: add getTags method | ||
|
||
## 1.37.1 | ||
|
||
### Patch Changes | ||
|
||
- feat: add tagSlugEnabled | ||
|
||
## 1.37.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: add tags_slugs field | ||
|
||
## 1.36.3 | ||
|
||
### Patch Changes | ||
|
||
- feat: add filename for uploadFile | ||
|
||
## 1.36.2 | ||
|
||
### Patch Changes | ||
|
||
- fix: deduplicate duplicate null values | ||
|
||
## 1.36.1 | ||
|
||
### Patch Changes | ||
|
||
- fix; change empty categories | ||
|
||
## 1.36.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: YAML serialization requires merge labels and classifications | ||
|
||
## 1.35.0 | ||
|
||
### Minor Changes | ||
|
||
- feat: Extract fromYaml and toYamlObj | ||
|
||
## 1.34.14 | ||
|
||
### Patch Changes | ||
|
||
- Updated dependencies | ||
- [email protected] | ||
|
||
## 1.34.13 | ||
|
||
### Patch Changes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright (c) 2023, Terwer . All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Terwer designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Terwer in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Terwer, Shenzhen, Guangdong, China, [email protected] | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { describe, it } from "vitest" | ||
|
||
describe("test PostUtil", () => { | ||
it("test fromYaml", () => { | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/* | ||
* Copyright (c) 2023, Terwer . All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Terwer designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Terwer in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Terwer, Shenzhen, Guangdong, China, [email protected] | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import Post from "./models/post" | ||
import { DateUtil } from "zhi-common" | ||
|
||
/** | ||
* 文章处理工具类 | ||
* | ||
* @since 1.11.2 | ||
*/ | ||
class PostUtil { | ||
/** | ||
* 将当前对象的数据转换为适用于 YAML 的对象 | ||
* | ||
* @returns {Object} 表示数据的适用于 YAML 的对象 | ||
*/ | ||
public static toYamlObj(post: Post): Record<string, any> { | ||
const yamlObj: Record<string, any> = {} | ||
|
||
post.dateCreated && (yamlObj.created = DateUtil.formatIsoToZh(post.dateCreated.toISOString(), true)) | ||
post.dateUpdated && (yamlObj.updated = DateUtil.formatIsoToZh(post.dateUpdated.toISOString(), true)) | ||
post.title && (yamlObj.title = post.title) | ||
post.wp_slug && (yamlObj.slug = post.wp_slug) | ||
post.permalink && (yamlObj.permalink = post.permalink) | ||
post.shortDesc && (yamlObj.desc = post.shortDesc) | ||
post.mt_keywords && (yamlObj.tags = post.mt_keywords?.split(",")) | ||
post.categories && (yamlObj.categories = post.categories) | ||
|
||
return yamlObj | ||
} | ||
|
||
/** | ||
* 使用来自适用于 YAML 的对象的数据填充当前对象的属性 | ||
* | ||
* @param post - 文章对象 | ||
* @param {Object} yamlObj - 包含要填充对象属性的数据的适用于 YAML 的对象 | ||
*/ | ||
public static fromYaml(post: Post, yamlObj: Record<string, any>): void { | ||
post.dateCreated = yamlObj?.created ? DateUtil.convertStringToDate(yamlObj.created) : post.dateCreated | ||
post.dateUpdated = | ||
(yamlObj?.updated ? DateUtil.convertStringToDate(yamlObj.updated) : post.dateUpdated) ?? new Date() | ||
post.title = yamlObj?.title ?? post.title | ||
post.wp_slug = yamlObj?.slug ?? post.wp_slug | ||
post.permalink = yamlObj?.permalink ?? post.permalink | ||
post.shortDesc = yamlObj?.desc ?? post.shortDesc | ||
|
||
// // 标签合并 | ||
// if (yamlObj?.tags && yamlObj.tags.length > 0) { | ||
// const existingTags = post.mt_keywords.split(",") | ||
// const uniqueKeywords = [...new Set([...existingTags, ...yamlObj.tags])].filter((tag) => tag.trim() !== "") | ||
// post.mt_keywords = uniqueKeywords.length > 0 ? uniqueKeywords.join(",") : "" | ||
// } | ||
// | ||
// // 分类合并 | ||
// if (yamlObj?.categories && yamlObj.categories.length > 0) { | ||
// const combinedCategories = [...new Set([...post.categories, ...yamlObj.categories])].filter( | ||
// (cate) => cate.trim() !== "" | ||
// ) | ||
// post.categories = combinedCategories.length > 0 ? combinedCategories : [] | ||
// } | ||
|
||
// 标签合并 | ||
if (yamlObj?.tags && yamlObj.tags.length > 0) { | ||
const existingTags = post.mt_keywords.split(",") | ||
const uniqueKeywords = [ | ||
...new Set([...existingTags.map((tag) => tag.trim()), ...yamlObj.tags.map((tag) => tag.trim())]), | ||
].filter((tag) => tag.trim() !== "") | ||
|
||
post.mt_keywords = uniqueKeywords.length > 0 ? uniqueKeywords.join(",") : "" | ||
} | ||
|
||
// 分类合并 | ||
if (yamlObj?.categories && yamlObj.categories.length > 0) { | ||
const combinedCategories = [ | ||
...new Set([...post.categories.map((cate) => cate.trim()), ...yamlObj.categories.map((cate) => cate.trim())]), | ||
].filter((cate) => cate.trim() !== "") | ||
|
||
post.categories = combinedCategories.length > 0 ? combinedCategories : [] | ||
} | ||
} | ||
} | ||
|
||
export default PostUtil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.