From fcd5d2807d2bab68c6776e031e85d65fe88a6f7a Mon Sep 17 00:00:00 2001 From: Jacky Zhao Date: Tue, 15 Feb 2022 19:39:14 -0500 Subject: [PATCH] feat: dynamically fetch indices --- .github/workflows/deploy.yaml | 2 +- .gitignore | 4 +- Makefile | 2 +- content/_index.md | 2 +- data/config.yaml | 2 +- layouts/partials/backlinks.html | 5 +- layouts/partials/graph.html | 11 +- layouts/partials/head.html | 23 ++- layouts/partials/popover.html | 6 +- layouts/partials/search.html | 323 ++++++++++++++++---------------- 10 files changed, 205 insertions(+), 175 deletions(-) diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 60773590c..3ec76dae8 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -12,7 +12,7 @@ jobs: - uses: actions/checkout@v2 - name: Build Link Index - uses: jackyzha0/hugo-obsidian@v2.7 + uses: jackyzha0/hugo-obsidian@v2.8 with: index: true input: content diff --git a/.gitignore b/.gitignore index 1eaad6086..54ae7a3f6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ public resources .idea content/.obsidian -data/linkIndex.yaml -data/contentIndex.yaml \ No newline at end of file +static/linkIndex.json +static/contentIndex.json \ No newline at end of file diff --git a/Makefile b/Makefile index 88605ebbe..3c6c0aff8 100644 --- a/Makefile +++ b/Makefile @@ -4,4 +4,4 @@ help: ## Show all Makefile targets @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' serve: ## serve - hugo-obsidian -input=content -output=data -index -root=. && hugo server + hugo-obsidian -input=content -output=static -index -root=. && hugo server diff --git a/content/_index.md b/content/_index.md index cc1f73298..1f920e031 100644 --- a/content/_index.md +++ b/content/_index.md @@ -1,5 +1,5 @@ --- -title: 🪴 Quartz 3 +title: 🪴 Quartz 3.1 --- Host your second brain and [digital garden](https://jzhao.xyz/posts/digital-gardening) for free. Quartz features 1. Extremely fast full-text search by pressing `/` diff --git a/data/config.yaml b/data/config.yaml index 5759ab2e8..a8f78bc23 100644 --- a/data/config.yaml +++ b/data/config.yaml @@ -5,7 +5,7 @@ description: Here is the page description. This is an example Quartz site that details installation, setup, customization, and troubleshooting for Quartz itself. page_title: - "🪴 Quartz 3" + "🪴 Quartz 3.1" links: - link_name: Twitter link: https://twitter.com/_jzhao diff --git a/layouts/partials/backlinks.html b/layouts/partials/backlinks.html index daee6ec77..746ebbbc3 100644 --- a/layouts/partials/backlinks.html +++ b/layouts/partials/backlinks.html @@ -3,8 +3,9 @@ {{$url := urls.Parse .Site.BaseURL }} {{$host := strings.TrimRight "/" $url.Path }} {{$curPage := strings.TrimPrefix $host (strings.TrimRight "/" .Page.RelPermalink) }} - {{$inbound := index $.Site.Data.linkIndex.index.backlinks $curPage}} - {{$contentTable := $.Site.Data.contentIndex}} + {{$linkIndex := getJSON "/static/linkIndex.json"}} + {{$inbound := index $linkIndex.index.backlinks $curPage}} + {{$contentTable := getJSON "/static/contentIndex.json"}} {{if $inbound}} {{$cleanedInbound := apply (apply $inbound "index" "." "source") "replace" "." " " "-"}} {{- range $cleanedInbound | uniq -}} diff --git a/layouts/partials/graph.html b/layouts/partials/graph.html index 10243bbca..14e1fdbeb 100644 --- a/layouts/partials/graph.html +++ b/layouts/partials/graph.html @@ -11,6 +11,8 @@ } diff --git a/layouts/partials/head.html b/layouts/partials/head.html index b754ca398..7ab5aeab7 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -8,7 +8,7 @@ - {{ $css := slice "base.scss" "darkmode.scss" "syntax.scss" "custom.scss"}} + {{$css := slice "base.scss" "darkmode.scss" "syntax.scss" "custom.scss"}} {{range $css}} {{$sass := resources.Get . | resources.ToCSS }} {{with $sass | minify}} @@ -26,9 +26,24 @@ {{ template "_internal/google_analytics.html" . }} diff --git a/layouts/partials/popover.html b/layouts/partials/popover.html index 3a7de1103..35f0738f1 100644 --- a/layouts/partials/popover.html +++ b/layouts/partials/popover.html @@ -1,5 +1,7 @@ {{if $.Site.Data.config.enableLinkPreview}} {{end}} \ No newline at end of file diff --git a/layouts/partials/search.html b/layouts/partials/search.html index 0c853a05f..c2ff77f0c 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -67,189 +67,194 @@ };