Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hexo 平台设置别名不生效 #1231

Closed
terwer opened this issue May 14, 2024 · 6 comments
Closed

Hexo 平台设置别名不生效 #1231

terwer opened this issue May 14, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@terwer
Copy link
Owner

terwer commented May 14, 2024

[slug].md修改之后保存会重置

@Achuan-2
Copy link

此外,设置别名还有问题
如果别名有多个
Clip_2024-08-11_19-49-05
文章别名就成了这个
Clip_2024-08-11_19-49-45
实际md名称为Wilcoxon,貌似会被空格阶段,还没有md后缀

@Achuan-2
Copy link

Achuan-2 commented Oct 5, 2024

此外,设置别名还有问题 如果别名有多个 Clip_2024-08-11_19-49-05 文章别名就成了这个 Clip_2024-08-11_19-49-45 实际md名称为Wilcoxon,貌似会被空格阶段,还没有md后缀

这个问题还没有解决,导致我设置多个别名的笔记都无法发布

@Achuan-2
Copy link

Achuan-2 commented Nov 26, 2024

[slug].md
[slug]代表什么
能修改成什么变量


哦哦,slug就有别名的意思

@terwer
Copy link
Owner Author

terwer commented Nov 27, 2024

slug保存在 custom-slug ,这个在 /data/storage/syp/sy-p-plus-cfg.json 里面(为什么存在这里。这是历史设计。暂时不适合调整了。),最终错误是因为github 名称空格不允许空格。
为什么我推荐设置 [slug].md 就是因为 github 通过 api 没有办法绕过别名不能为空这个限制。gitlab 没这个问题。我自动生成的不会有空格。

  // 别名
      const slug = ObjectUtil.getProperty(postMeta, SiyuanAttr.Custom_slug, post.wp_slug)
      if (!StrUtil.isEmptyString(slug)) {
        post.wp_slug = slug
        logger.info("Using existing siyuan note slug")
      } else {
        // 如果wp_slug为空,则生成一个新的slug
        const slug = await AliasTranslator.getPageSlug(post.title, true)
        post.wp_slug = `${slug}`
        logger.info("Generated new slug")
      }

这个逻辑是这样:
1、优先获取 custom-slug,有的话直接返回
2、没有,会尝试使用标题名称新生成一个。

image

他使用会优先调用翻译 api 生成。失败使用拼音。

https://github.com/terwer/siyuan-plugin-publisher/blob/main/src/composables/usePublish.ts#L371

https://github.com/terwer/zhi/blob/main/libs/zhi-common/src/lib/slugUtil.ts#L120

我看了下问题可能出现在,
const slug = ObjectUtil.getProperty(postMeta, SiyuanAttr.Custom_slug, post.wp_slug)

post.wp_slug 的读取逻辑,先读取 Custom_slug找不到,获取系统别名。这样的话我考虑去掉这个

image

https://github.com/terwer/zhi/blob/main/libs/zhi-siyuan-api/src/lib/adaptor/siYuanApiAdaptor.ts#L234

下版本修复

@terwer
Copy link
Owner Author

terwer commented Nov 27, 2024

fixed in v1.29.0

@terwer terwer closed this as completed Nov 27, 2024
@terwer terwer added the bug Something isn't working label Nov 27, 2024
terwer added a commit that referenced this issue Nov 27, 2024
terwer added a commit that referenced this issue Nov 27, 2024
terwer added a commit that referenced this issue Nov 27, 2024
@Achuan-2
Copy link

Achuan-2 commented Nov 27, 2024

ok,谢谢大佬的耐心回复
辛苦啦

terwer added a commit that referenced this issue Nov 27, 2024
feat: #1231 support filename.md as hexo md filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants