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

Algolia Search Render Issue [solved] #118

Closed
3 tasks done
Myfreedom614 opened this issue Feb 6, 2018 · 18 comments
Closed
3 tasks done

Algolia Search Render Issue [solved] #118

Myfreedom614 opened this issue Feb 6, 2018 · 18 comments

Comments

@Myfreedom614
Copy link

Myfreedom614 commented Feb 6, 2018

I agree and want to create new issue


Expected behavior

Enable Algolia Search In Hexo Blog

Actual behavior

No response when click search button, encountered exception when execute hexo generate command:

INFO  Deleted database.
INFO  Deleted public folder.
INFO  Start processing
FATAL Something's wrong. Maybe you can find the solution here: http://hexo.io/docs/troubleshooting.html
Template render error: (unknown path) [Line 11, Column 16385]
  unexpected token: #
    at Object.exports.prettifyError (/home/franklin/hexo_blog/node_modules/hexo/node_modules/nunjucks/src/lib.js:34:15)
    at new_cls.render (/home/franklin/hexo_blog/node_modules/hexo/node_modules/nunjucks/src/environment.js:472:27)
    at new_cls.renderString (/home/franklin/hexo_blog/node_modules/hexo/node_modules/nunjucks/src/environment.js:328:21)
    at /home/franklin/hexo_blog/node_modules/hexo/lib/extend/tag.js:66:9
    at Promise._execute (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/debuggability.js:303:9)
    at Promise._resolveFromExecutor (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/promise.js:483:18)
    at new Promise (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/promise.js:79:10)
    at Tag.render (/home/franklin/hexo_blog/node_modules/hexo/lib/extend/tag.js:64:10)
    at Object.tagFilter [as onRenderEnd] (/home/franklin/hexo_blog/node_modules/hexo/lib/hexo/post.js:266:16)
    at /home/franklin/hexo_blog/node_modules/hexo/lib/hexo/render.js:65:19
    at tryCatcher (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/home/franklin/hexo_blog/node_modules/hexo/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)

Steps to reproduce the behavior

  1. Update Index by following this
  2. Clone theme-next-algolia-instant-search dependency in here
  3. Enable Algoria Search in theme configuration file:
# Algolia Search
algolia_search:
  enable: true
  hits:
    per_page: 10
  labels:
    input_placeholder: Search for Posts
    hits_empty: "We didn't find any results for the search: ${query}"
    hits_stats: "${hits} results found in ${time} ms"
  1. Execute hexo generate command, you will see the exception output
  • Link to demo site with this issue: N/A
  • Link(s) to source code or any usefull link(s): N/A

Node.js and NPM Information

v6.12.3
3.10.10

Package dependencies Information

{
  "name": "hexo-theme-next",
  "version": "6.0.3",
  "description": "Elegant and powerful theme for Hexo",
  "main": "index.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "gulp"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/theme-next/hexo-theme-next.git"
  },
  "keywords": [
    "NexT",
    "Hexo"
  ],
  "author": "iissnan <iissnan@gmail.com>",
  "maintainers": [
    "Ivan Nginx <ivan.nginx@gmail.com> (https://almostover.ru)"
    ],
  "license": "AGPL",
  "bugs": {
    "url": "https://github.com/theme-next/hexo-theme-next/issues"
  },
  "homepage": "https://theme-next.org",
  "devDependencies": {
    "coffee-script": "^1.10.0",
    "gulp": "^3.9.0",
    "gulp-jshint": "^1.12.0",
    "gulp-shell": "^0.6.1",
    "js-yaml": "^3.8.1",
    "jshint-stylish": "^2.1.0",
    "stylint": "^1.5.9"
  }
}

Hexo Information

Hexo version

hexo-cli: 1.0.4
os: Linux 4.4.0-111-generic linux x64
http_parser: 2.7.0
node: 6.12.3
v8: 5.1.281.111
uv: 1.15.0
zlib: 1.2.11
ares: 1.10.1-DEV
icu: 58.2
modules: 48
openssl: 1.0.2n

Hexo Configuration

algolia:
  applicationID: 'xxxxx'
  indexName: 'xxxxx'
  chunkSize: 5000

NexT Information

NexT Version:

[x] Latest Master branch.
[] Latest Release version.
[] Old version -

NexT Scheme:

[] All schemes
[] Muse
[] Mist
[] Pisces
[x] Gemini

NexT Configuration:

# Algolia Search
# Dependencies: https://github.com/theme-next/theme-next-algolia-instant-search
algolia_search:
  enable: true
  hits:
    per_page: 10
  labels:
    input_placeholder: Search for Posts
    hits_empty: "We didn't find any results for the search: ${query}"
    hits_stats: "${hits} results found in ${time} ms"

Other Information

@sli1989
Copy link
Collaborator

sli1989 commented Feb 6, 2018

u are missing apikey.
follow this doc.

@Myfreedom614
Copy link
Author

Myfreedom614 commented Feb 6, 2018

@sli1989 Append apikey in site config file, same result when excuting hexo g

If I removed the dependency https://github.com/theme-next/theme-next-algolia-instant-search, the exception was gone, but the algolia search function won't work

@sli1989
Copy link
Collaborator

sli1989 commented Feb 6, 2018

after adding the apiKey, the pop-up window of the algolia search isn't working with hexo clean? what's your output of hexo algolia.

@sli1989
Copy link
Collaborator

sli1989 commented Feb 6, 2018

I have tested for Gemini again, there seems no problem. Check carefully the doc. And
git clone https://github.com/theme-next/theme-next-algolia-instant-search` to ~/themes/next/source/lib/algolia-instant-search NOT ~/source/lib/algolia-instant-search.

@Myfreedom614
Copy link
Author

hexo g throw exception as described

@sli1989
Copy link
Collaborator

sli1989 commented Feb 6, 2018

i saw there have no algolia search lib in your 3rd libs files, did u git clone https://github.com/theme-next/theme-next-algolia-instant-search` to ~/themes/next/source/lib/algolia-instant-search.

@Myfreedom614
Copy link
Author

Sure

@Myfreedom614
Copy link
Author

u see there isno such lib cause i removed it and deploy to github

@sli1989
Copy link
Collaborator

sli1989 commented Feb 6, 2018

perhaps you need open the algolia search and provide a live demo to find your bug in your blog.


what's your output of hexo algolia not hexo g.

@Myfreedom614
Copy link
Author

hexo algolia Index successfully. Actually if you see the error log, it looks like related to swig template

@sli1989
Copy link
Collaborator

sli1989 commented Feb 6, 2018

i think it's the problem of lib's path.
u can try another way, add algolia_instant_js: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.js & algolia_instant_css: https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.min.css in vendors of next's _config.yml.

@wafer-li
Copy link
Member

wafer-li commented Feb 6, 2018

@sli1989
@Myfreedom614
theme-next-algolia-instant-search has not created the release, please use

https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.min.css for algolia_instant_css

and

https://cdn.jsdelivr.net/npm/instantsearch.js@2.4.1/dist/instantsearch.min.js for algolia_instant_js

@sli1989
Copy link
Collaborator

sli1989 commented Feb 6, 2018

ok, thanks.

@Myfreedom614 Myfreedom614 changed the title Algoria Search Render Issue Algolia Search Render Issue Feb 7, 2018
@Myfreedom614
Copy link
Author

Myfreedom614 commented Feb 7, 2018

@sli1989 @wafer-li

Thanks! It works now.

But the UI needs to be adjusted:

image

@Myfreedom614
Copy link
Author

Add custom css in blog_source/themes/next/source/css/_custom/custom.styl to hide this svg.

It works well now:)

@sli1989
Copy link
Collaborator

sli1989 commented Feb 7, 2018

can u tell me the detail steps to remove the sbx-icon-search-13 using cdn? i took a PR but don't know how to fix it. @Myfreedom614

@ivan-nginx ivan-nginx added the Bug label Feb 7, 2018
@Myfreedom614
Copy link
Author

@sli1989

  • Edit theme custom style file:
    vi themes/next/source/css/_custom/custom.styl

  • Add the following style

.ais-search-box--magnifier svg {
    display: none !important;
}

@sli1989
Copy link
Collaborator

sli1989 commented Feb 8, 2018

thanks @Myfreedom614

Maybe it's more perfect using

svg path {
  display: none;
}

@ivan-nginx ivan-nginx changed the title Algolia Search Render Issue Algolia Search Render Issue [fix added] Mar 17, 2018
@ivan-nginx ivan-nginx changed the title Algolia Search Render Issue [fix added] Algolia Search Render Issue [solved] Mar 4, 2019
@theme-next theme-next locked as resolved and limited conversation to collaborators Apr 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants