mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-07 13:15:20 +00:00
Allow searching both inline and frontmatter tags
This commit is contained in:
parent
0c46242b0a
commit
5cf5aa1566
@ -18,7 +18,7 @@ module.exports = function(eleventyConfig) {
|
|||||||
.use(require("markdown-it-hashtag"))
|
.use(require("markdown-it-hashtag"))
|
||||||
.use(function(md){
|
.use(function(md){
|
||||||
md.renderer.rules.hashtag_open = function(tokens, idx) {
|
md.renderer.rules.hashtag_open = function(tokens, idx) {
|
||||||
return '<a class="tag" onclick="toggleInlineTagSearch(this)">'
|
return '<a class="tag" onclick="toggleSearch(this)">'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.use(require('markdown-it-mathjax3'), {
|
.use(require('markdown-it-mathjax3'), {
|
||||||
|
@ -13,11 +13,11 @@ const handler = async (event) => {
|
|||||||
|
|
||||||
let results;
|
let results;
|
||||||
if(search[0] == "#" && search.length > 1){
|
if(search[0] == "#" && search.length > 1){
|
||||||
results = index.search(`tags:${search.substring(1)}`)
|
results = index.search(`${search.substring(1)}`)
|
||||||
}else if(search.length > 2 && search[0] == ">" && search[1] == "#"){
|
}else if(search.length > 2 && search[0] == ">" && search[1] == "#"){
|
||||||
results = index.search(`${search.substring(2)}`)
|
results = index.search(`${search.substring(2)}`)
|
||||||
}else{
|
}else{
|
||||||
results = index.search(search);
|
results = index.search(search+"*");
|
||||||
}
|
}
|
||||||
|
|
||||||
results.forEach(r => {
|
results.forEach(r => {
|
||||||
|
@ -11,17 +11,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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) {
|
window.toggleTagSearch=function(evt) {
|
||||||
console.log(evt.textContent);
|
console.log(evt.textContent);
|
||||||
const term = evt.textContent;
|
const term = evt.textContent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user