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

站内搜索search.xml文件越来越大如何解决 #1146

Closed
vinoZHU opened this issue Sep 28, 2016 · 7 comments
Closed

站内搜索search.xml文件越来越大如何解决 #1146

vinoZHU opened this issue Sep 28, 2016 · 7 comments

Comments

@vinoZHU
Copy link

vinoZHU commented Sep 28, 2016

文章数量越多,search.xml内容越多,加载超级慢,该如何解决?

@Neveryu
Copy link

Neveryu commented Sep 28, 2016

In new version , we can user contain search server.This way not use search.xml。
https://neveryu.github.io/guestbook/

@mritd
Copy link

mritd commented Oct 1, 2016

已经对 hexo 无爱.....https://mritd.me

@hzlpy
Copy link

hzlpy commented Oct 2, 2016

@mritd 你这个也挺好的,请问是怎么制作的?

@mritd
Copy link

mritd commented Oct 2, 2016

@hzlpy 用的 jekyll,直接找个主题 就行,ruby写的,Github 目前用的就是这个;感觉 Hexo 不太友好,遇到很多次 都是环境没法复现,比如在这个版本能用,从别的电脑上用新版本重建一个就会出现各种莫名奇怪的错误,而且社区感觉 也并不是太活跃。。。。可能是后台狗 对 js 和 node 不熟悉的原因吧。。。反正总是毛病不断,全站 https 也会有问题,只好放弃了

@vinoZHU
Copy link
Author

vinoZHU commented Oct 3, 2016

不想再去折腾jekyll或者其他什么的了,就退而求其次,修改下插件吧。修改hexoblog/node_modules/hexo-generator-searchsearch.ejs文件,将其中的post.contentpages.content改成post.titlepages.title。然后原先由50篇文章生成的search.xml从800+kb瞬间变成10+kb,至少短期内应该没问题了。

<?xml version="1.0" encoding="utf-8"?>
<search>
  <% var url = config.url + config.root %>
  <% if(posts){ %>
    <% posts.each(function(post){ %>
    <entry>
      <title><%-: post.title | cdata %></title>
      <url><%- encodeURI(post.permalink) %></url>
      <content type="html"><%-: post.title | cdata %></content>
    </entry>
    <% }) %>
  <% } %>
  <% if(pages){ %>
    <% pages.each(function(page){ %>
    <entry>
      <title><%-: page.title | cdata %></title>
      <url><%- encodeURI(page.permalink) %></url>
      <content type="html"><%-: page.title | cdata %></content>
    </entry>
    <% }) %>
  <% } %>
</search>

@hausen1012
Copy link

已经对 hexo 无爱.....https://mritd.me
请问搜索用什么做的

@LauArmy
Copy link

LauArmy commented Nov 7, 2023 via email

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

7 participants