From 8780e0cb02697c7e6da17ef79d1d8e95b207710b Mon Sep 17 00:00:00 2001 From: Len Bucchino Date: Sat, 25 Nov 2023 16:40:58 -0600 Subject: [PATCH] Changes to make the search work --- _data/locales/en.yml | 90 +++++++++++++++++++++++++++++++++++ _includes/search-loader.html | 46 ++++++++++++++++++ _includes/search-results.html | 6 +++ assets/js/data/search.json | 55 +++++++++++++++++++++ 4 files changed, 197 insertions(+) create mode 100644 _data/locales/en.yml create mode 100644 _includes/search-loader.html create mode 100644 _includes/search-results.html create mode 100644 assets/js/data/search.json diff --git a/_data/locales/en.yml b/_data/locales/en.yml new file mode 100644 index 0000000..065894b --- /dev/null +++ b/_data/locales/en.yml @@ -0,0 +1,90 @@ +# The layout text of site + +# ----- Commons label ----- + +layout: + post: Post + category: Category + tag: Tag + +# The tabs of sidebar +tabs: + # format: : + home: Home + categories: Categories + tags: Tags + archives: Archives + about: About + +# the text displayed in the search bar & search results +search: + hint: search + cancel: Cancel + no_results: Oops! No results found. + +panel: + lastmod: Recently Updated + trending_tags: Trending Tags + toc: Contents + +copyright: + # Shown at the bottom of the post + license: + template: All Rights Reserved + name: All Rights Reserved + link: https://en.wikipedia.org/wiki/All_rights_reserved + + # Displayed in the footer + brief: All rights reserved. + verbose: >- + Except where otherwise noted all rights are reserved and this content may not be reused without explicit permission from the author. + +meta: Using the :THEME theme for :PLATFORM. + +not_found: + statment: Sorry, we've misplaced that URL or it's pointing to something that doesn't exist. + +notification: + update_found: A new version of content is available. + update: Update + +# ----- Posts related labels ----- + +post: + written_by: By + posted: Posted + updated: Updated + words: words + pageview_measure: views + read_time: + unit: min + prompt: read + relate_posts: Further Reading + share: Share + button: + next: Newer + previous: Older + copy_code: + succeed: Copied! + share_link: + title: Copy link + succeed: Link copied successfully! + +# Date time format. +# See: , +df: + post: + strftime: "%b %e, %Y" + dayjs: "ll" + archives: + strftime: "%b" + dayjs: "MMM" + +# categories page +categories: + category_measure: + singular: category + plural: categories + post_measure: + singular: post + plural: posts diff --git a/_includes/search-loader.html b/_includes/search-loader.html new file mode 100644 index 0000000..48f4103 --- /dev/null +++ b/_includes/search-loader.html @@ -0,0 +1,46 @@ + + +{% capture result_elem %} +
+ {title} + +

{content}

+
+{% endcapture %} + +{% capture not_found %}

{{ site.data.locales[site.lang].search.no_results }}

{% endcapture %} + + + + diff --git a/_includes/search-results.html b/_includes/search-results.html new file mode 100644 index 0000000..85d07b4 --- /dev/null +++ b/_includes/search-results.html @@ -0,0 +1,6 @@ + +
+
+
+
+
diff --git a/assets/js/data/search.json b/assets/js/data/search.json new file mode 100644 index 0000000..dd25266 --- /dev/null +++ b/assets/js/data/search.json @@ -0,0 +1,55 @@ +--- +layout: compress +swcache: true +--- + +[ +{% for post in site.data.block_data %} + {% assign desc = site.data.block_descriptions[post.id].description %} + { + "title": {{ post.name | jsonify }}, + "url": {{ './items/?s=' | append: post.id | append: '#' | append: post.id | relative_url | jsonify }}, + "imgUrl": {{ post.path | relative_url | jsonify }}, + "content": {{ desc | append: ' ' | jsonify }} + },` +{% endfor %} + +{% for post in site.data.item_data %} + {% assign desc = site.data.item_descriptions[post.id].description %} + { + "title": {{ post.name | jsonify }}, + "url": {{ './items/?s=' | append: post.id | append: '#' | append: post.id | relative_url | jsonify }}, + "imgUrl": {{ post.path | relative_url | jsonify }}, + "content": {{ desc | append: ' ' | jsonify }} + }, +{% endfor %} + +{% for post in site.data.spellbook_data %} + {% assign desc = site.data.spellbook_descriptions[post.id].description %} + { + "title": {{ post.name | jsonify }}, + "url": {{ './spellbooks/?s=' | append: post.id | append: '#' | append: post.id | relative_url | jsonify }}, + "imgUrl": {{ post.path | relative_url | jsonify }}, + "content": {{ post.tooltip | append: ' ' | jsonify }} + }, +{% endfor %} + +{% for post in site.data.spell_data %} + { + "title": {{ post.name | jsonify }}, + "url": {{ './spells/?s=' | append: post.name | append: '#' | append: post.name | relative_url | jsonify }}, + "imgUrl": {{ post.icon | relative_url | jsonify }}, + "content": {{ post.description | jsonify }} + }, +{% endfor %} + +{% for post in site.data.armor_data %} + { + "title": {{ post.name | jsonify }}, + "url": {{ './armor/?s=' | append: post.id | append: '#' | append: post.id | relative_url | jsonify }}, + "imgUrl": {{ post.path | relative_url | jsonify }}, + "content": {{ post.tooltip | jsonify }} + }{% unless forloop.last %},{% endunless %} +{% endfor %} + +]