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

主站搜索结果链接错误 #874

Closed
nanxstats opened this issue Jan 21, 2020 · 8 comments
Closed

主站搜索结果链接错误 #874

nanxstats opened this issue Jan 21, 2020 · 8 comments
Assignees

Comments

@nanxstats
Copy link
Member

重现方法:

在主站搜索关键词:心理学

第一个结果的链接为

https://cosx.org/Sat%20/ep/psychology-in-crisis

正确的链接应为

https://cosx.org/2017/09/psychology-in-crisis/

Screen Shot 2020-01-21 at 9 22 46 AM

@yihui
Copy link
Member

yihui commented Jan 21, 2020

怪哉…… @fyears @Lchiffon @XiangyunHuang @tcgriffith 求关注

@tcgriffith
Copy link
Contributor

大概知道啥问题

@tcgriffith
Copy link
Contributor

tcgriffith commented Jan 21, 2020

提交的algolia index里的url字段就是这个

搜索页F12的返回结果:

            "uri": "psychology-in-crisis",
            "title": "心理学的危机",
            "autor": "杨洵默",
            "date": "2017-09-30T00:00:00.000Z",
            "url": "https://cosx.org/Sat /ep/psychology-in-crisis",
            "objectID": "2017-09-30-psychology-in-crisis.md",

与其他帖子的源文件对比了一下,源文件yaml头里的日期没有用引号括起来,估计是用hugo源文件生成algolia索引这一步有问题,依稀记得之前我的站也碰到过

不过主站生成algolia index的模块可能跟我用的不一样,下面我就没法试了,同志们交给你们了哈哈哈哈

@nanxstats
Copy link
Member Author

好的,如果问题是引号引起的话,至少有 4 篇文章加 members 页面需要修复,我来发个 PR 好了:

fn <- list.files("content/", recursive = TRUE, full.names = TRUE)
k <- length(fn)
content <- vector("list", k)
for (i in 1:k) content[[i]] <- readLines(fn[i])
dates <- rep(NA, k)
for (i in 1:k) {
  x <- which(grepl("date:", content[[i]]))[1]
  dates[i] <- if (length(x)) content[[i]][x] else NA
}

fn[which(!grepl("\\\"|'", dates))]

# [1] "content//archives.md"                                               
# [2] "content//members.md"                                                
# [3] "content//post/2017-09-30-psychology-in-crisis.md"                   
# [4] "content//post/2018-04-01-RoTK-Analysis.md"                          
# [5] "content//post/2018-10-12-Python-and-R-implementation-of-gcForest.md"
# [6] "content//post/2019-10-24-bayesian-multilevel-lijin.md"              
# [7] "content//search.md"  

@nanxstats nanxstats mentioned this issue Jan 23, 2020
@yihui yihui closed this as completed in 237a2ce Jan 23, 2020
@yihui
Copy link
Member

yihui commented Jan 23, 2020

按理说引号是可以省略的,不过试试看吧。

@yihui
Copy link
Member

yihui commented Jan 23, 2020

我扒拉了半天才想起来我们的网站是通过什么手段提交给 Algolia 索引的了……大为设置了个 Travis 定期运行脚本向 Algolia 提交数据,不过好像是每周跑一次:https://travis-ci.org/Lchiffon/cosx-algolia/builds

@yihui
Copy link
Member

yihui commented Jan 23, 2020

看样子还真是因为引号的问题:https://github.com/Lchiffon/cosx-algolia/blob/master/gulpfile.babel.js#L86

@tcgriffith
Copy link
Contributor

石锤了,确实是引号问题, @nanxstats 找的另一个帖子

用R分析光荣《三国志》系列人物数据

返回链接也有问题

https://cosx.org/Fri%20/ov/RoTK-Analysis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants