diff --git a/.eleventy.js b/.eleventy.js index beb0859..7614803 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -15,6 +15,12 @@ module.exports = function(eleventyConfig) { }) .use(require("markdown-it-footnote")) .use(require("markdown-it-attrs")) + .use(require("markdown-it-hashtag")) + .use(function(md){ + md.renderer.rules.hashtag_open = function(tokens, idx) { + return '' + } + }) .use(require('markdown-it-mathjax3'), { tex: { inlineMath: [ diff --git a/netlify/functions/search/search.js b/netlify/functions/search/search.js index fc15843..d793657 100644 --- a/netlify/functions/search/search.js +++ b/netlify/functions/search/search.js @@ -11,10 +11,14 @@ const handler = async (event) => { const index = lunrjs.Index.load(indexJson); console.log('index made'); - let results = - search[0] == "#" && search.length > 1 - ? index.search(`tags:${search.substring(1)}`) - : index.search(search); + let results; + if(search[0] == "#" && search.length > 1){ + results = index.search(`tags:${search.substring(1)}`) + }else if(search.length > 2 && search[0] == ">" && search[1] == "#"){ + results = index.search(`${search.substring(2)}`) + }else{ + results = index.search(search); + } results.forEach(r => { r.title = data[r.ref].title; diff --git a/package-lock.json b/package-lock.json index 8c7adcd..780980d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "markdown-it": "^12.3.2", "markdown-it-attrs": "^4.1.6", "markdown-it-footnote": "^3.0.3", + "markdown-it-hashtag": "^0.4.0", "markdown-it-mathjax3": "^4.3.1", "markdown-it-plantuml": "^1.4.1", "markdown-it-task-checkbox": "^1.0.6" @@ -3437,6 +3438,11 @@ "resolved": "https://registry.npmjs.org/markdown-it-footnote/-/markdown-it-footnote-3.0.3.tgz", "integrity": "sha512-YZMSuCGVZAjzKMn+xqIco9d1cLGxbELHZ9do/TSYVzraooV8ypsppKNmUJ0fVH5ljkCInQAtFpm8Rb3eXSrt5w==" }, + "node_modules/markdown-it-hashtag": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/markdown-it-hashtag/-/markdown-it-hashtag-0.4.0.tgz", + "integrity": "sha512-+VCMH+f4/Ud5wPEtcAMrlLbUrrGViwR9JvjPy//X3Z7ZG1j5nQuHtDLTGZfMhkqYTMY+cTZgZkVNBsXMfU93Yg==" + }, "node_modules/markdown-it-mathjax3": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/markdown-it-mathjax3/-/markdown-it-mathjax3-4.3.2.tgz", @@ -8980,6 +8986,11 @@ "resolved": "https://registry.npmjs.org/markdown-it-footnote/-/markdown-it-footnote-3.0.3.tgz", "integrity": "sha512-YZMSuCGVZAjzKMn+xqIco9d1cLGxbELHZ9do/TSYVzraooV8ypsppKNmUJ0fVH5ljkCInQAtFpm8Rb3eXSrt5w==" }, + "markdown-it-hashtag": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/markdown-it-hashtag/-/markdown-it-hashtag-0.4.0.tgz", + "integrity": "sha512-+VCMH+f4/Ud5wPEtcAMrlLbUrrGViwR9JvjPy//X3Z7ZG1j5nQuHtDLTGZfMhkqYTMY+cTZgZkVNBsXMfU93Yg==" + }, "markdown-it-mathjax3": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/markdown-it-mathjax3/-/markdown-it-mathjax3-4.3.2.tgz", diff --git a/package.json b/package.json index f6f39cc..9965bbc 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "markdown-it": "^12.3.2", "markdown-it-attrs": "^4.1.6", "markdown-it-footnote": "^3.0.3", + "markdown-it-hashtag": "^0.4.0", "markdown-it-mathjax3": "^4.3.1", "markdown-it-plantuml": "^1.4.1", "markdown-it-task-checkbox": "^1.0.6" diff --git a/src/site/_includes/components/searchScript.njk b/src/site/_includes/components/searchScript.njk index 14fc91a..a257e23 100644 --- a/src/site/_includes/components/searchScript.njk +++ b/src/site/_includes/components/searchScript.njk @@ -11,6 +11,17 @@ } } + + window.toggleInlineTagSearch=function(evt) { + console.log(evt.textContent); + const term = evt.textContent; + if(term){ + window.document.getElementById('term').value = '>' + term.trim(); + window.toggleSearch(); + window.search(); + } + } + window.toggleTagSearch=function(evt) { console.log(evt.textContent); const term = evt.textContent;