Skip to content

Commit

Permalink
add sourcegraph, github search to suggestions (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed May 29, 2020
1 parent 89b2841 commit 3c7f714
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .vuepress/config.js
@@ -1,3 +1,5 @@
const fs = require('fs');
const { path } = require('@vuepress/shared-utils');
const vuepressUtils = require('@vuepress/shared-utils');
const emojiRegex = require('emoji-regex')();

Expand Down Expand Up @@ -92,7 +94,9 @@ module.exports = {

plugins: [
// fulltext search for site content - https://github.com/leo-buneev/vuepress-plugin-fulltext-search
'fulltext-search',
['fulltext-search', {
processSuggestions: fs.readFileSync(path.resolve(__dirname, 'processSuggestions.js')),
}],

// remove trailing .html for example - https://vuepress.github.io/en/plugins/clean-urls
'vuepress-plugin-clean-urls',
Expand Down
20 changes: 20 additions & 0 deletions .vuepress/processSuggestions.js
@@ -0,0 +1,20 @@
// This function extends suggestions provided by the fulltext-search plugin
export default async function(suggestions, queryString, queryTerms) {
if (queryString) {
suggestions.push({
path: 'https://sourcegraph.com/search?patternType=literal&q=repo:^github.com/ubclaunchpad/*+',
slug: queryString,
parentPageTitle: 'Other',
title: 'Content and code',
contentStr: 'Search our repositories',
external: true,
}, {
path: 'https://github.com/search?q=org%3Aubclaunchpad+type%3Aissue+',
slug: queryString,
title: 'Issues and pull requests',
contentStr: 'Search our GitHub organization',
external: true,
});
}
return suggestions;
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -17,7 +17,7 @@
"markdownlint-cli": "^0.22.0",
"vuepress": "^1.4.1",
"vuepress-plugin-clean-urls": "^1.1.1",
"vuepress-plugin-fulltext-search": "^2.0.2",
"vuepress-plugin-fulltext-search": "https://github.com/bobheadlabs/vuepress-plugin-fulltext-search.git",
"vuepress-theme-yuu": "^2.2.1"
}
}

0 comments on commit 3c7f714

Please sign in to comment.