Skip to content

Commit

Permalink
Merge pull request #18 from linglilongyi/main
Browse files Browse the repository at this point in the history
bug fixed: 文章标题末尾的d被去除
  • Loading branch information
huangwb8 authored Nov 13, 2024
2 parents 7fb6907 + 7f4b331 commit 9eb3bdf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion m2w/rest_api/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def _create_article(self, md_path, post_metadata) -> None:

# 5 构造上传的请求内容
post_data = {
"title": filename.strip(".md"),
"title": filename.split(".md")[0],
"content": str(post_content_html, encoding="utf-8"),
"status": post_metadata["status"],
"comment_status": "open",
Expand Down
4 changes: 2 additions & 2 deletions m2w/rest_api/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ async def upload_article(
for new_md in md_create:
if not force_upload:
if (
os.path.basename(new_md).strip(".md")
os.path.basename(new_md).split('.md')[0]
in self.article_title_dict.keys()
):
if verbose:
Expand All @@ -85,7 +85,7 @@ async def upload_article(
else:
print(f"The post {new_md} is updating")
if (
os.path.basename(new_md).strip(".md")
os.path.basename(new_md).split('.md')[0]
in self.article_title_dict.keys()
):
_update_article(
Expand Down
4 changes: 1 addition & 3 deletions m2w/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def make_post(filepath, metadata):
"""
filename = os.path.basename(filepath) # 例如:test(2021.11.19).md
filename_suffix = filename.split('.')[-1] # 例如:md
filename_prefix = filename.strip(
".md"
) # 例如:test(2021.11.19)
filename_prefix = filename.split('.md')[0] # 例如:test(2021.11.19)

# 目前只支持 .md 后缀的文件
if filename_suffix != 'md':
Expand Down

0 comments on commit 9eb3bdf

Please sign in to comment.