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

帖子链接用纯数字的可能性? #646

Closed
yihui opened this issue Jul 18, 2017 · 5 comments
Closed

帖子链接用纯数字的可能性? #646

yihui opened this issue Jul 18, 2017 · 5 comments
Labels

Comments

@yihui
Copy link
Member

yihui commented Jul 18, 2017

例如是否可以做到 https://d.cosx.org/d/419222-catboost-boosting -> https://d.cosx.org/d/419222。对中文论坛来说,带标题的链接通常没什么意义,如看到 https://d.cosx.org/d/419200-r 也不会知道它是“第十届中国 R 会议(合肥)纪要”。

当然,保底的办法是用 JS 重写 <a>的 href 属性。就是略暗黑,而且加载更多帖子时候还得继续重写。

@yihui yihui added the 论坛 label Jul 18, 2017
@yixuan
Copy link
Member

yixuan commented Jul 19, 2017

这个是论坛核心的代码,我不是很清楚,但只用数字也是可以访问的。

@yihui
Copy link
Member Author

yihui commented Jul 19, 2017

嗯,我知道可以访问。只是想着有没有办法从源头生成干净的链接。

这个问题不是特别重要。能办就办,办不了也无妨。我早已经跟 Flarum 反馈过了:flarum/framework#194 (comment)

@yihui
Copy link
Member Author

yihui commented Jul 22, 2017

@yixuan 你觉得加这么一句会有问题吗?主要是看看各种可能的链接有哪些,以及 Flarum 自己有没有用 replaceState()

<script>
window.history.replaceState({}, "", window.location.href.replace(/(\/d\/[0-9]+)-[^/]+/, "$1"));
</script>

它可以插在“自定义 HTML 头”中。

@yixuan
Copy link
Member

yixuan commented Jul 22, 2017

这两天出去一趟,只能回来再砍 bug 了。如果有网的话可能可以稍微测试一下。

@yihui
Copy link
Member Author

yihui commented Jul 24, 2017

我简单试了一下,不行。Flarum 会以某种方式动态改写地址栏中的链接(我估计就是 replaceState())。即使放在文档加载完毕的事件中也不行:

document.addEventListener("DOMContentLoaded", function(event) { 

});

我估计需要动用插件之类的东西。

@yufree yufree closed this as completed Jun 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants