mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-06 04:35:20 +00:00
tags support
This commit is contained in:
parent
ea3199f4f1
commit
040ab398b9
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -24,6 +24,9 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
|
||||
{% if settings.dgShowInlineTitle === true %}
|
||||
<h1>{% if title %}{{ title }}{% else %}{{ page.fileSlug }}{% endif %}</h1>
|
||||
{% endif %}
|
||||
<div class="header-meta">
|
||||
{% if tags %}<div class="header-tags">{% for tag in tags %}<a class="tag" onclick="toggleTagSearch(this)">#{{tag}}</a>{% endfor %}</div>{% endif %}
|
||||
</div>
|
||||
{{ content | link | highlight | safe}}
|
||||
</div>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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 %}]
|
||||
|
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user