I'm using Docpad to build a static website. I'm trying to set up the Lunr plugin for full-text site search, but I keep getting this error:
$ docpad run
info: Welcome to DocPad v6.78.1 (local installation: /PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad)
info: Plugins: cleanurls, eco, livereload, lunr, marked, moment, partials, rss, sitemap, stylus
info: Environment: development
info: DocPad listening to http://127.0.0.1:9778/ on directory /PATH/TO/WEBSITE/REPOSITORY/out
info: LiveReload listening to new socket on channel /docpad-livereload
ReferenceError: partial is not defined
at Object.eval (<anonymous>:41:18)
at Object.eval (<anonymous>:51:8)
at eval (<anonymous>:53:6)
at Function.eco.render (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad-plugin-eco/node_modules/eco/lib/index.js:26:25)
at EcoPlugin.render (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad-plugin-eco/out/eco.plugin.js:23:32)
at ambi (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:57:27)
at Task.<anonymous> (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/event-emitter-grouped/out/lib/event-emitter-grouped.js:45:23)
at ambi (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:55:18)
at fireMethod (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:397:23)
at b (domain.js:183:18)
at Domain.run (domain.js:123:23)
at Task.fire (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:435:27)
at Object._onImmediate (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:452:26)
at processImmediate [as _immediateCallback] (timers.js:354:15)
info: Generating...
error: The action completed successfully
error: Something went wrong while rendering: /PATH/TO/WEBSITE/REPOSITORY/src/render/search.html.eco
The error follows:
ReferenceError: partial is not defined
at Object.eval (<anonymous>:41:18)
at Object.eval (<anonymous>:51:8)
at eval (<anonymous>:53:6)
at Function.eco.render (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad-plugin-eco/node_modules/eco/lib/index.js:26:25)
at EcoPlugin.render (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad-plugin-eco/out/eco.plugin.js:23:32)
at ambi (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:57:27)
at Task.<anonymous> (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/event-emitter-grouped/out/lib/event-emitter-grouped.js:45:23)
at ambi (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/ambi/out/lib/ambi.js:55:18)
at fireMethod (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:397:23)
at b (domain.js:183:18)
at Domain.run (domain.js:123:23)
at Task.fire (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:435:27)
at Object._onImmediate (/PATH/TO/WEBSITE/REPOSITORY/node_modules/docpad/node_modules/taskgroup/out/lib/taskgroup.js:452:26)
at processImmediate [as _immediateCallback] (timers.js:354:15)
I read the Lunr plugin's repository README, and I wasn't always sure where to put the config properties. But here's the docpad.coffee
properties I came up with.
plugins:
lunr:
indexes:
myIndex:
collection: [ "story", "meta" ]
resultsTemplate: "src/partials/search-excerpt.html.eco"
...And the search results partial in src/partials/searc-excerpt.html.eco
<div>
<a href="<%= post.url %>"><%= post.title %></a>
<span>posted on <%= post.date %></span>
</div>
...And the search results page in src/render/search.html.eco
---
title: "search results"
---
<%- partial( "header" ) %>
<%- @getLunrSearchPage( "myIndex" ) %>
<%- partial( "footer" ) %>
I haven't gotten around to trying to insert the search bar in website templates, because the basics is already breaking. What am I doing wrong? Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire