From b484a5263e33170ebf88bdb52b79e13d50ab7ff4 Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Fri, 10 May 2024 19:41:54 -0400 Subject: [PATCH 01/25] Issue #607: proof of concept for site search with pagefind --- .gitignore | 3 ++ layouts/index.html | 2 ++ layouts/partials/head.html | 4 +++ layouts/partials/navbar.html | 5 ++++ layouts/partials/search.html | 56 ++++++++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+) create mode 100644 layouts/partials/search.html diff --git a/.gitignore b/.gitignore index a988bda2..e0d12fb7 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ resources # Auto-generated doc/content/shortcodes.md public + +# vim droppings +.*.swp diff --git a/layouts/index.html b/layouts/index.html index b62c7aec..479b44b0 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,4 +1,6 @@ {{ define "main" }} + {{ partial "search.html" . }} + {{ if .Site.Params.hero }} {{ partial "hero.html" . }} {{ end }} diff --git a/layouts/partials/head.html b/layouts/partials/head.html index a6a20082..4d1a05c9 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -12,3 +12,7 @@ {{ end }} + + + + diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index 535571b4..06a79c54 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -25,6 +25,10 @@ diff --git a/layouts/partials/search.html b/layouts/partials/search.html new file mode 100644 index 00000000..60ed7cc0 --- /dev/null +++ b/layouts/partials/search.html @@ -0,0 +1,56 @@ + + + + From efd2841d494c86b016d564aa448de93d9c991fde Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 12:24:25 -0400 Subject: [PATCH 02/25] Build pagefind search index in doc/Makefile --- doc/Makefile | 1 + layouts/partials/head.html | 1 + 2 files changed, 2 insertions(+) create mode 100644 layouts/partials/head.html diff --git a/doc/Makefile b/doc/Makefile index accaf781..331a61f8 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -24,6 +24,7 @@ themes: themes/scientific-python-hugo-theme html: ## Build site in `./public` html: themes content/shortcodes.md hugo + yes | npx pagefind --site public serve: ## Serve site, typically on http://localhost:1313 serve: themes content/shortcodes.md diff --git a/layouts/partials/head.html b/layouts/partials/head.html new file mode 100644 index 00000000..c2daa253 --- /dev/null +++ b/layouts/partials/head.html @@ -0,0 +1 @@ + From 04103ee73e9905a3c22829778a1dac91b6c93624 Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 12:52:31 -0400 Subject: [PATCH 03/25] more gracefully handle missing doc/themes --- doc/Makefile | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 331a61f8..17a13928 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -6,14 +6,9 @@ help: themes/scientific-python-hugo-theme: @if [ ! -d "$<" ]; then \ - echo "*** ERROR: missing theme" ; \ - echo ; \ - echo "It looks as though you are missing the themes directory."; \ - echo "You need to add the scientific-python-hugo-theme as a submodule."; \ - echo ; \ - echo "Please see https://theme.scientific-python.org/getstarted/"; \ - echo ; \ - exit 1; \ + mkdir -p themes; \ + cd themes; \ + ln -s ../.. scientific-python-hugo-theme; \ fi content/shortcodes.md: From b1e13d1ea1634ceb2d58b5026dbd80e11dd5b3f1 Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 13:35:43 -0400 Subject: [PATCH 04/25] fix unwanted interactions between pagefind ui css and theme styles --- layouts/partials/search.html | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/layouts/partials/search.html b/layouts/partials/search.html index 373da9ae..35342410 100644 --- a/layouts/partials/search.html +++ b/layouts/partials/search.html @@ -1,5 +1,6 @@ + + + - From 8c0e630a7d7327a0941289ced9f9f32453b10a1b Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 14:57:13 -0400 Subject: [PATCH 05/25] Make search controlled by a config switch --- config.yaml | 1 + layouts/index.html | 2 ++ 2 files changed, 3 insertions(+) diff --git a/config.yaml b/config.yaml index 5641a9f6..a6a63242 100644 --- a/config.yaml +++ b/config.yaml @@ -7,6 +7,7 @@ params: images: - /images/logo.svg navColor: blue + search: true plausible: dataDomain: null javaScript: "https://views.scientific-python.org/js/script.js" diff --git a/layouts/index.html b/layouts/index.html index 479b44b0..60ada675 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,5 +1,7 @@ {{ define "main" }} + {{ if .Site.Params.search }} {{ partial "search.html" . }} + {{ end }} {{ if .Site.Params.hero }} {{ partial "hero.html" . }} From 1cf13e70da0b122e32836120302a3ddd116e0749 Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 14:58:59 -0400 Subject: [PATCH 06/25] Restore original handling for missing themes in Makefile --- doc/Makefile | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 17a13928..5aaaf41e 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -6,9 +6,14 @@ help: themes/scientific-python-hugo-theme: @if [ ! -d "$<" ]; then \ - mkdir -p themes; \ - cd themes; \ - ln -s ../.. scientific-python-hugo-theme; \ + echo "*** ERROR: missing theme" ; \ + echo ; \ + echo "It looks as though you are missing the themes directory."; \ + echo "You need to add the scientific-python-hugo-theme as a submodule."; \ + echo ; \ + echo "Please see https://theme.scientific-python.org/getstarted/"; \ + echo ; \ + exit 1; \ fi content/shortcodes.md: @@ -22,8 +27,8 @@ html: themes content/shortcodes.md yes | npx pagefind --site public serve: ## Serve site, typically on http://localhost:1313 -serve: themes content/shortcodes.md - @hugo --printI18nWarnings server +serve: html + @hugo --printI18nWarnings serve clean: ## Remove built files clean: From ed5dc795d519f3062f0bc53d7a766bc47d32e364 Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 15:24:23 -0400 Subject: [PATCH 07/25] update outer Makefile to build pagefind for doc site --- Makefile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 30f67453..ae42cd97 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,10 @@ doc/content/shortcodes.md: $(wildcard layouts/shortcodes/*.html) # Serve for development purposes. serve-dev: doc-serve doc-serve: doc/content/shortcodes.md - (cd doc && hugo --printI18nWarnings serve --themesDir="../.." --disableFastRender --poll 1000ms) + (cd doc; \ + hugo; \ + yes | npx pagefind --site public; \ + hugo --printI18nWarnings serve --themesDir="../.." --disableFastRender --poll 1000ms) # ----------------------------------- # The following is for use on netlify @@ -44,7 +47,7 @@ preview-theme: python tools/add_preview_links.py theme: doc/content/shortcodes.md - (cd doc ; hugo --themesDir="../..") + (cd doc ; hugo --themesDir="../.."; yes | npx pagefind --site public) scipy: rm -rf $@ From bdff709bbe35703fd01621f0baa538abe5f99780 Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 15:33:16 -0400 Subject: [PATCH 08/25] fix whitespace in doc/Makefile --- doc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/Makefile b/doc/Makefile index 5aaaf41e..48b8109c 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -6,7 +6,7 @@ help: themes/scientific-python-hugo-theme: @if [ ! -d "$<" ]; then \ - echo "*** ERROR: missing theme" ; \ + echo "*** ERROR: missing theme" ; \ echo ; \ echo "It looks as though you are missing the themes directory."; \ echo "You need to add the scientific-python-hugo-theme as a submodule."; \ From e2899cabcf897dd628a90f7f23f1b12dbb40bb86 Mon Sep 17 00:00:00 2001 From: Brian Hawthorne Date: Sat, 11 May 2024 15:35:17 -0400 Subject: [PATCH 09/25] only show search affordance when search is enabled --- layouts/partials/navbar.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/layouts/partials/navbar.html b/layouts/partials/navbar.html index 06a79c54..4d61238d 100644 --- a/layouts/partials/navbar.html +++ b/layouts/partials/navbar.html @@ -25,9 +25,11 @@