From 830cabab1f638052a8c4ac39eb86370da5a676eb Mon Sep 17 00:00:00 2001 From: Jieiku Date: Sun, 14 Aug 2022 12:41:15 -0700 Subject: Alternate Search Libraries Tinysearch and Stork --- templates/macros/create_tinysearch_json.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 templates/macros/create_tinysearch_json.html (limited to 'templates/macros/create_tinysearch_json.html') diff --git a/templates/macros/create_tinysearch_json.html b/templates/macros/create_tinysearch_json.html new file mode 100644 index 0000000..f45ed42 --- /dev/null +++ b/templates/macros/create_tinysearch_json.html @@ -0,0 +1,26 @@ +{%- macro from_section(section) -%} +{%- set section = get_section(path=section) -%} +{%- for post in section.pages -%} +{%- if not post.draft -%} +{ +"title": {{ post.title | striptags | json_encode | safe }}, +"url": {{ post.permalink | json_encode | safe }}, +"meta": {% if post.summary %} + {{- post.summary | striptags | truncate(length=150) | json_encode | safe }} + {%- elif post.description %} + {{- post.description | striptags | truncate(length=150) | json_encode | safe }} + {%- elif post.content %} + {{- post.content | striptags | truncate(length=150) | json_encode | safe }} + {%- endif %}, +"body": {{ post.content | striptags | json_encode | safe }} +} +{%- if not loop.last -%},{%- endif %} +{%- endif -%} +{%- endfor -%} +{%- if section.subsections -%} +, +{%- for subsection in section.subsections -%} +{{ self::from_section(section=subsection) }} +{%- endfor -%} +{%- endif -%} +{%- endmacro from_section -%} \ No newline at end of file -- cgit v1.3.1