diff --git a/netlify/functions/search/search.js b/netlify/functions/search/search.js
index b9501c0..1518535 100644
--- a/netlify/functions/search/search.js
+++ b/netlify/functions/search/search.js
@@ -13,6 +13,11 @@ const handler = async (event) => {
let results = index.search(search);
+ let results =
+ search[0] == "#"
+ ? index.search(`tags:${search.substring(1)}`)
+ : index.search(search);
+
results.forEach(r => {
r.title = data[r.ref].title;
r.content = truncate(data[r.ref].content, 400);
diff --git a/src/site/_includes/components/searchScript.njk b/src/site/_includes/components/searchScript.njk
index 367da67..e266f1b 100644
--- a/src/site/_includes/components/searchScript.njk
+++ b/src/site/_includes/components/searchScript.njk
@@ -11,6 +11,14 @@
}
}
+ window.toggleTagSearch=function(evt) {
+ console.log(evt.textContent);
+ const term = evt.textContent;
+ window.document.getElementById('term').value = term;
+ window.toggleSearch();
+ window.search();
+ }
+
function debounce(func, wait, immediate) {
var timeout;
return function() {
diff --git a/src/site/_includes/layouts/note.njk b/src/site/_includes/layouts/note.njk
index b59afe7..436fe42 100644
--- a/src/site/_includes/layouts/note.njk
+++ b/src/site/_includes/layouts/note.njk
@@ -24,6 +24,9 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
{% if settings.dgShowInlineTitle === true %}
{% if title %}{{ title }}{% else %}{{ page.fileSlug }}{% endif %}
{% endif %}
+
{{ content | link | highlight | safe}}
diff --git a/src/site/lunr-index.js b/src/site/lunr-index.js
index 5846ea3..03a84d2 100644
--- a/src/site/lunr-index.js
+++ b/src/site/lunr-index.js
@@ -8,6 +8,7 @@ function createIndex(posts) {
this.field('title');
this.field('content');
this.field('date');
+ this.field("tags");
posts.forEach((p, idx) => {
p.id = idx;
diff --git a/src/site/lunr.njk b/src/site/lunr.njk
index d52c19a..5dd4074 100644
--- a/src/site/lunr.njk
+++ b/src/site/lunr.njk
@@ -8,6 +8,7 @@ eleventyExcludeFromCollections: true
"title": {% if post.data.title %}{{post.data.title | jsonify | safe }}{% else %}{{post.fileSlug | jsonify | safe }}{% endif %},
"date":"{{ post.date }}",
"url":"{{ post.url }}",
- "content": {{ post.templateContent | striptags(true) | link | jsonify | safe }}
+ "content": {{ post.templateContent | striptags(true) | link | jsonify | safe }},
+ "tags": [{% if post.data.tags %}{% for tag in post.data.tags %}"{{tag}}"{% if not loop.last %},{% endif %}{% endfor %}{% endif %}]
}{% if not loop.last %},{% endif %}
{% endfor %}]
diff --git a/src/site/styles/style.scss b/src/site/styles/style.scss
index c507eeb..0ff6378 100644
--- a/src/site/styles/style.scss
+++ b/src/site/styles/style.scss
@@ -92,3 +92,13 @@ p>code {
color: #c7254e;
background-color: #1a1a1a;
}
+
+.header-tags {
+ display: flex;
+ flex-wrap: wrap;
+ margin-top: 10px;
+}
+
+.header-meta {
+ margin-bottom: 1.8em;
+}
\ No newline at end of file