Skip to content

Commit

Permalink
Improved: Macros, docs, templates
Browse files Browse the repository at this point in the history
  • Loading branch information
harrymkt committed Dec 23, 2024
1 parent 951ed35 commit 4398d3e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 17 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ on:
workflow_dispatch:

env:
# Build directory where the website will run its build. Use the dot (period) to use current.
builddir: .
# Output directory where built files will deploy. This also will be used on Pagefind search generation.
outdir: HTML

defaults:
run:
shell: bash
Expand All @@ -24,9 +27,9 @@ jobs:
- name: Install
uses: taiki-e/install-action@zola
- name: Install Python Requirements
run: pip install -r requirements.txt
run: pip install pagefind[extended]
- name: Build
run: zola build
run: zola -r "${{ env.builddir }}" build
# Ignore below name if you do not use pagefind.
- name: Generate Pagefind Search
run: python -m pagefind --site ${{ env.outdir }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ git clone https://github.com/harrymkt/zluinav.git
```
Or [download manually](https://github.com/harrymkt/zluinav/archive/refs/heads/main.zip) and paste in the themes directory.

Or, add to the Git submodule
Or, add to the Git submodule (recommended):
```bash
git submodule add --name zluinav https://github.com/harrymkt/zluinav.git themes/zluinav
git submodule update --remote
Expand Down
1 change: 0 additions & 1 deletion content/_index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
+++
title = "Home"
insert_anchor_links = "heading"
+++
# UI Navigation
UI Navigation, or known as zluinav, is a Zola theme designed for accessibility rather than visual and made as easy as possible using templates and macros. Since I am a blind developer, I'd like to develop with accessibility as possible so visually impaired users can use them.
Expand Down
1 change: 0 additions & 1 deletion content/_index.my.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
+++
title = "အိမ်"
insert_anchor_links = "heading"
+++
# UI လမ်းညွှန်
UI Navigation (သို့) zluinav ဟုခေါ်သော Zola theme သည် ပုံသဏ္ဍာန်များနှင့် မက်ခရိုများကို အသုံးပြု၍ တတ်နိုင်သမျှ လွယ်ကူအောင် ပြုလုပ်ထားခြင်းထက် အလွယ်တကူ ဖန်တီးထားသည့် Zola အပြင်အဆင်တစ်ခုဖြစ်သည်။ ကျွန်ုပ်သည် မျက်မမြင် developer တစ်ဦးဖြစ်သောကြောင့် အမြင်အာရုံချို့တဲ့သောအသုံးပြုသူများသည် ၎င်းတို့ကိုအသုံးပြုနိုင်စေရန် တတ်နိုင်သမျှ သုံးစွဲနိုင်မှုဖြင့် ဖွံ့ဖြိုးတိုးတက်စေလိုပါသည်။
Expand Down
4 changes: 3 additions & 1 deletion content/docs/macros/general.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ General macros added in general namespace

## title(titles)
Returns the titles, separated by the value set in `config.extra.title_sep`, with the site title appended after it.
- `titles`(array) required: array of titles.
- `titles`(array) required: array of titles.
- `sep`(string) optional: The title's separator. Defaults to what it is set in `title_sep` site extra. Passing this string empty will set back to default.
- `overwrite`(bool) optional: `false` if the site title should be appended after the titles, or `true` otherwise. Defaults to `false`.
4 changes: 2 additions & 2 deletions content/docs/search.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ See [search configuration](@/docs/extra/config.md#searching)
You have a variety of formats to choose for your search.

### main
This format uses the default searching method configured in search according to Zola's documentation. `search.js` in the static folder provides for `elasticlunr`.
This format uses the default searching method configured in search according to Zola's documentation. `search.js` in the static folder provides for `elasticlunr`. The only disadvantage of this search format is that custom languages cannot be used to index.

### pagefind
This is the default used in Zluinav's demo and is a third party searching tool, and thus it cannot be used in `zola serve`. Instead, this is best if you run this tool after the build. In short, this tool runs over your HTML files to generate the search, and it only takes up a few seconds.

{% details(summary="Setup Pagefind") %}
#### Setup Pagefind
Do the following to get up and run Pagefind. We'll asume you have Python installed:
1. Install Pagefind extended version. You can do this by this command up to the root of this repository. `pip install -r requirements.txt`
1. Install Pagefind extended version. You can do this by this command. `pip install -r pagefind[extended]`
2. Set the search format in the `searching` object.
3. Build the site. `zola build`
4. Generate the search index. Make sure to replace outputdir with the directory where your built files live. `python -m pagefind --site outputdir`
Expand Down
1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion static/scripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function initSearch() {
};
var currentTerm = "";
var index;
const base_url = document.querySelector("base").href;
const base_url = document.querySelector("baseurl").href;
const lang = document.querySelector("html").lang;
const language = (lang ? lang : "en");
const resource_path = new URL(`search_index.${language}.json`, base_url).href;
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<!doctype html>
<html lang="{{ lang }}">
<head>
<base href="{{ get_url(path = "", lang = lang) }}"/>
<baseurl href="{{ get_url(path = "", lang = lang) }}"/>
{%- block extrahead %}
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand Down
11 changes: 8 additions & 3 deletions templates/mcs/general.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{%- macro title(titles) %}
{%- set titles = titles | concat(with = config.title) %}
{{- titles | join(sep = config.extra.title_sep) }}
{%- macro title(titles, sep="", overwrite=false) %}
{%- if not sep or sep == "" %}
{%- set sep = config.extra.title_sep %}
{%- endif %}
{%- if not overwrite %}
{%- set titles = titles | concat(with = config.title) %}
{%- endif %}
{{- titles | join(sep = sep) }}
{%- endmacro title %}
{%- macro get_nav_attributes(attributes) %}
{%- set navattr = "" %}
Expand Down
4 changes: 1 addition & 3 deletions templates/taxonomy_single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
{%- endblock title %}
{%- block content %}
<h1>{{ term.name }}</h1>
<ul>
{%- for page in term.pages %}
<li><a href="{{ page.permalink }}">{{ page.title }}</a></li>
{{- postmc::post_preview(post=page, tr=tr) }}
{%- endfor %}
</ul>
{%- endblock content %}

0 comments on commit 4398d3e

Please sign in to comment.