Skip to content

Commit

Permalink
yn's lunr switch
Browse files Browse the repository at this point in the history
  • Loading branch information
jhmullen committed May 19, 2022
1 parent c4bfe69 commit 6ce0ad6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/cms/src/api/searchRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ module.exports = function(app) {
let contentIds = [];
const {searchIndexByLocale} = app.settings.cache;

if (CANON_CMS_LUNR && searchIndexByLocale[locale]) {
if (yn(CANON_CMS_LUNR) && searchIndexByLocale[locale]) {
const terms = query.split(" ").map(d => `+${d}~1*`).join(" ");
const lunrResults = searchIndexByLocale[locale].search(terms);
contentIds = lunrResults.map(d => d.ref);
Expand Down
3 changes: 2 additions & 1 deletion packages/cms/src/cache/searchIndexByLocale.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const lunr = require("lunr");
require("lunr-languages/lunr.stemmer.support")(lunr);
const yn = require("yn");

const whitelist = ["ar", "da", "de", "du", "en", "es", "fi", "hi", "hu", "it", "ja", "jp", "nl", "no", "pt", "ro", "ru", "sv", "ta", "th", "tr", "vi", "zh"];

Expand All @@ -13,7 +14,7 @@ for (const locale of locales.filter(d => d !== "en")) {

module.exports = async function(app) {

if (!CANON_CMS_LUNR) return {};
if (!yn(CANON_CMS_LUNR)) return {};

const {db} = app;

Expand Down

0 comments on commit 6ce0ad6

Please sign in to comment.