mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-06 04:35:20 +00:00
Add tag to search result and remove home note tag
This commit is contained in:
parent
8f32df6bb8
commit
2c3bddded8
@ -11,8 +11,6 @@ const handler = async (event) => {
|
||||
const index = lunrjs.Index.load(indexJson);
|
||||
console.log('index made');
|
||||
|
||||
let results = index.search(search);
|
||||
|
||||
let results =
|
||||
search[0] == "#"
|
||||
? index.search(`tags:${search.substring(1)}`)
|
||||
@ -23,6 +21,7 @@ const handler = async (event) => {
|
||||
r.content = truncate(data[r.ref].content, 400);
|
||||
r.date = data[r.ref].date;
|
||||
r.url = data[r.ref].url;
|
||||
r.tags = data[r.ref].tags;
|
||||
|
||||
delete r.ref;
|
||||
});
|
||||
|
@ -206,12 +206,8 @@
|
||||
<a class="search-link" href="${r.url}">${r.title}</a>
|
||||
<div onclick="window.location='${r.url}'">
|
||||
<div class="header-meta">
|
||||
{% if tags %}
|
||||
<div class="header-tags">
|
||||
{% for tag in tags %}
|
||||
<a class="tag" href="JavaScript:Void(0);">#{{tag}}</a>
|
||||
{% endfor %}</a>
|
||||
{% endif %}
|
||||
${r.tags.map(tag=>'<a class="tag" href="JavaScript:Void(0);">#'+tag+'</a>').join("")}
|
||||
</div>
|
||||
</div>
|
||||
${r.content}
|
||||
|
@ -25,7 +25,17 @@ permalink: "notes/{{ page.fileSlug | slugify }}/"
|
||||
<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 %}
|
||||
{% if tags %}
|
||||
<div class="header-tags">
|
||||
{% for tag in tags %}
|
||||
{% if tag != 'gardenEntry' %}
|
||||
<a class="tag" onclick="toggleTagSearch(this)">
|
||||
#{{tag}}
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{{ content | link | highlight | safe}}
|
||||
</div>
|
||||
|
@ -9,6 +9,6 @@ eleventyExcludeFromCollections: true
|
||||
"date":"{{ post.date }}",
|
||||
"url":"{{ post.url }}",
|
||||
"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 %}]
|
||||
"tags": [{% if post.data.tags %}{% for tag in post.data.tags %}{% if tag != 'gardenEntry' %}"{{tag}}"{% endif %}{% if not loop.last %},{% endif %}{% endfor %}{% endif %}]
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}]
|
||||
|
Loading…
x
Reference in New Issue
Block a user