Git Product home page Git Product logo

canoe's People

Contributors

stkevintan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

canoe's Issues

A new way for search without lunrjs

A new way for search without any other dependencies but Hugo itself

As a fact, Hugo does have a way to generate .json format files of itself without any other dependencies. You can find it from Hugo official doc, and with some variables, you can generate a index.json file which looks like below:

[
  {
    "categories": ["A","B"],
    "content": "article content .........",
    "oriTitle": "article title",
    "permalink": "article url",
    "tags": ["tagA","tagB","tabC"],    
    "title": "file title"    
  }
];

Only two steps, you'll get it:

  • Step 1:
    Creat a new file with the name index.json, and put it into the path themes/you-theme-name/layouts/_default/index.json. Set the content of index.json the same as below:
{{- $.Scratch.Add "index" slice -}}
{{- range .Site.RegularPages -}}
    {{- $.Scratch.Add "index" (dict "oriTitle" .Params.title "title" .Title "tags" .Params.tags "categories" .Params.categories "content" .Plain "permalink" .Permalink) -}}
{{- end -}}
{{- $.Scratch.Get "index" | jsonify -}}
  • Step 2:
    Add beloe content to your config.toml
[outputs]
  home = ["HTML", "RSS", "JSON"]

Now everytime you hugo serve or hugo -b "" , Hugo will generate a index.json file in your site root.

As hugo-canoe-theme already have it's own way to render index.json file for searching in themes/canoe/static/js/index.js , you won't have to do other things.

Summary

改完之后比较了一下,搜索能力与老方案比似乎还是差了一小点,应该可以从改善 canoe 内部的 index.js 出发得以解决,因为Client side searching for Hugo.io with Fuse.js方案的搜索能力比老方案似乎还强有一些。博客https://kuleyu-hugo.netlify.com/就是采用了 Fuse.js 方案。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.