Skip to content

Commit

Permalink
fix: 修复博客园可能出现的预览错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Nov 8, 2023
1 parent b58f5c3 commit a4ba0ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/adaptors/api/cnblogs/cnblogsApiAdaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,16 @@ class CnblogsApiAdaptor extends MetaweblogBlogApiAdaptor {
return result
}

public async getPreviewUrl(postid: string): Promise<string> {
const userid = this.cfg.apiUrl ? this.cfg.apiUrl.match(/[^/]+$/)?.[0] ?? "" : ""
const previewUrl = this.cfg.previewUrl.replace(/\[userid]/g, userid).replace(/\[postid]/g, postid)
// return StrUtil.pathJoin(this.cfg.home ?? "", previewUrl)
return previewUrl
}

// ================
// private methods
// ================
private assignMdCategory(post: Post) {
const cates = post.categories ?? []
if (!cates.some((cate) => cate.toLowerCase() === this.MD_CATEGORY.toLowerCase())) {
Expand Down
4 changes: 2 additions & 2 deletions src/adaptors/api/cnblogs/cnblogsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class CnblogsConfig extends MetaweblogConfig {
* @param middlewareUrl 代理地址
*/
constructor(apiUrl: string, username: string, password: string, middlewareUrl?: string) {
super("https://www.cnblogs.com/[your-blog-name]", apiUrl, username, password, middlewareUrl)
super("https://www.cnblogs.com/", apiUrl, username, password, middlewareUrl)

this.tokenSettingUrl = "https://i.cnblogs.com/settings"
this.previewUrl = "/p/[postid].html"
this.previewUrl = "/[userid]/p/[postid].html"
this.pageType = PageTypeEnum.Markdown
this.usernameEnabled = true
this.passwordType = PasswordType.PasswordType_Token
Expand Down

0 comments on commit a4ba0ed

Please sign in to comment.