diff options
| author | Eltrac <hi@guhub.cn> | 2025-09-10 19:38:18 +0800 |
|---|---|---|
| committer | Eltrac <hi@guhub.cn> | 2025-09-10 19:38:18 +0800 |
| commit | ab09dc19b06d71068d6eca04729b0ecca363d4ad (patch) | |
| tree | 8198b196852c1f26f5f7d1edf2cffe0a0dc97071 | |
| parent | a9df6135afc96607fbb8d576c944cedf91e36948 (diff) | |
perf: load pagefind js and css only when needed
Former-commit-id: ab0f89677c5daced755b64b66f3c79cd61d65220
| -rw-r--r-- | config/_default/params.yaml | 3 | ||||
| -rw-r--r-- | layouts/_partials/head/css.html | 5 | ||||
| -rw-r--r-- | layouts/taxonomy.html | 1 |
3 files changed, 6 insertions, 3 deletions
diff --git a/config/_default/params.yaml b/config/_default/params.yaml index fe8ca907..5865e801 100644 --- a/config/_default/params.yaml +++ b/config/_default/params.yaml @@ -5,11 +5,8 @@ mainSections: - fictions - library favicon: /favicon.png -extraCSSFiles: - - /pagefind/pagefind-ui.css externalJSFIles: - /js/littlefoot.js - - /pagefind/pagefind-ui.js footerExternalLinks: - name: GitHub link: https://github.com/BigCoke233/geek-death-project diff --git a/layouts/_partials/head/css.html b/layouts/_partials/head/css.html index cbc0f4ba..250ef4a3 100644 --- a/layouts/_partials/head/css.html +++ b/layouts/_partials/head/css.html @@ -12,6 +12,11 @@ <style>{{ .Content | safeCSS }}</style> {{ end }} +<!-- Pagefind --> +{{ if eq .Kind "taxonomy" }} +<link rel="stylesheet" href="/pagefind/pagefind-ui.css"> +{{ end }} + <!-- Extra --> {{ range .Site.Params.extraCSSFiles -}} <link diff --git a/layouts/taxonomy.html b/layouts/taxonomy.html index 150879f5..02624d59 100644 --- a/layouts/taxonomy.html +++ b/layouts/taxonomy.html @@ -12,6 +12,7 @@ {{ partial "taxonomy/all-categories.html" . }} </article> +<script src="/pagefind/pagefind-ui.js"></script> <script> window.addEventListener('DOMContentLoaded', () => { new PagefindUI({ element: "#pagefind", showSubResults: true }); |
