reuixiy / hugo-theme-meme

😝 You can’t spell awesome without MemE!
https://io-oi.me/hugo-theme-meme
MIT License
1.01k stars 279 forks source link

多语言的配置下每篇文章下面的版权中的文章链接显示不正确 #334

Closed newdivide2014 closed 1 year ago

newdivide2014 commented 3 years ago

不知道这是不是个bug,我看了别人多语言的博客也有这样的问题。问题如下图:

多语言配置完了,这每篇文章下面版权信息里的链接会多显示一次"/zh"

Screenshot from 2021-05-26 22-31-43

英文的同样也会有这样的问题。 Screenshot from 2021-05-26 22-35-16

我的博客配置在https://github.com/newdivide2014/sharpknife/tree/main/config/_default 我翻看了所有的closed/opened issues都没有说到这个,但是看别人的博客多语言的也是有这个问题的。还请作者大大看看是配置的问题还是本身的bug。

如果是配置请指教一番,如果是bug那就辛苦作者大大改bug了 [捂脸] 我实在是看不懂前端代码啊 ~

reuixiy commented 3 years ago

我这边(https://github.com/reuixiy/io-oi.me)好像无法复现,能否贴一个有这个问题的源码仓库链接,你的或者其他人的都可以

reuixiy commented 3 years ago

抱歉,看到了……

https://github.com/newdivide2014/sharpknife/blob/167c2583d7ccdb2b60875318f98f009fd4770fb2/config/_default/languages.toml#L6

后面的 trailing slash 删除试试?

newdivide2014 commented 3 years ago

抱歉,看到了……

https://github.com/newdivide2014/sharpknife/blob/167c2583d7ccdb2b60875318f98f009fd4770fb2/config/_default/languages.toml#L6

后面的 trailing slash 删除试试?

我试了试删除后面的 trailing slash,还是有这个问题的,没能解决。

我在Awesome MemE!里面翻了翻有多语言配置的也是有这样的情况,基本上默认语言的版权url是没问题。也可能样本比较少看不出来是啥问题。以下俩个是我翻看的有类似问题的。作者大大可以参考一下。

https://blog.coelacanthus.moe/zh-tw/tech/welcome-to-fcitx5/

Screenshot from 2021-06-12 14-39-08

https://tokenbrice.xyz/fr/defi-flywheel/

Screenshot from 2021-06-12 14-43-56

reuixiy commented 3 years ago

OK,谢谢,我再看一下

你使用的 Hugo 版本是什么,可不可以贴一下 hugo version 的输出

另外,相关的代码是

https://github.com/reuixiy/hugo-theme-meme/blob/159652eafbd79a1956174be36989354686f08654/layouts/partials/components/post-copyright.html#L12-L17

URL 直接取自 .RelPermalink 所以是没问题的,文本是 $decodedPermalink 是上面代码处理过的,当时做这样的处理是因为如果 URL 有中文的话,会被转码成「乱码」,显示出来不好看,所以利用一些 Hugo 的 functions 曲线解码,然后拼接 URL……

有时间的话可以尝试 debug

newdivide2014 commented 3 years ago

OK,谢谢,我再看一下

你使用的 Hugo 版本是什么,可不可以贴一下 hugo version 的输出

另外,相关的代码是

https://github.com/reuixiy/hugo-theme-meme/blob/159652eafbd79a1956174be36989354686f08654/layouts/partials/components/post-copyright.html#L12-L17

URL 直接取自 .RelPermalink 所以是没问题的,文本是 $decodedPermalink 是上面代码处理过的,当时做这样的处理是因为如果 URL 有中文的话,会被转码成「乱码」,显示出来不好看,所以利用一些 Hugo 的 functions 曲线解码,然后拼接 URL……

有时间的话可以尝试 debug

hugo version显示如下 hugo v0.82.1-60618210+extended linux/amd64 BuildDate=2021-04-20T11:02:50Z VendorInfo=gohugoio

我先自己debug试试,感谢作者大大。