Skip to content

Commit 8c02395

Browse files
committed
Switch to pagefind for search
We have more control over search indices if we use a local search library Signed-off-by: adelaney21 <[email protected]>
1 parent 76f355f commit 8c02395

File tree

8 files changed

+63
-644
lines changed

8 files changed

+63
-644
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ jobs:
2121
uses: actions/setup-go@v6
2222
with:
2323
go-version: '1.x'
24+
# Node is used to generate the pagefind index
25+
- name: Setup Node.js environment
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: 'latest'
2429
- name: Install Dependencies
2530
run: sudo apt-get install make curl jq
2631
- name: Install pack

Makefile

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,9 @@ TOOLS_BIN:=tools/bin
3030
$(TOOLS_BIN):
3131
mkdir $(TOOLS_BIN)
3232

33-
# adapted from https://stackoverflow.com/a/12099167/552902
3433
HUGO_OS:=Linux
35-
HUGO_ARCH:=32bit
34+
HUGO_ARCH:=64bit
3635
HUGO_EXT:=tar.gz
37-
ifeq ($(OS),Windows_NT)
38-
HUGO_OS:=Windows
39-
HUGO_EXT:=zip
40-
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
41-
HUGO_ARCH:=64bit
42-
endif
43-
endif
4436

4537
ifeq ($(shell uname -s),Darwin)
4638
HUGO_OS:=darwin
@@ -135,6 +127,8 @@ build: export PACK_VERSION:=$(PACK_VERSION)
135127
build: $(HUGO_BIN) pack-version pack-docs-update
136128
@echo "> Building..."
137129
$(HUGO_BIN)
130+
# Github Workflows ensures `node` is installed.
131+
npx run pagefind --source ./public --destination ./public/pagefind
138132

139133
.PHONY: test
140134
test: install-pack-cli check-pack-cli-version install-ugo

themes/buildpacks/assets/scss/components/_algolia.scss

Lines changed: 0 additions & 3 deletions
This file was deleted.

themes/buildpacks/assets/scss/site.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
@import 'code';
77
@import 'syntax';
88

9-
@import 'components/algolia';
109
@import 'components/header';
1110
@import 'components/hero';
1211
@import 'components/grid';

themes/buildpacks/layouts/_default/baseof.html

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
{{ $style := resources.Get "scss/site.scss" | toCSS }}
1818
<link rel="stylesheet" href="{{ $style.Permalink }}" integrity="{{ $style.Data.Integrity }}" media="screen">
1919

20-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
21-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js"></script>
20+
<link rel="stylesheet" href="/pagefind/pagefind-ui.css">
21+
<script src="/pagefind/pagefind-ui.js"></script>
2222

2323
<script async src="https://www.googletagmanager.com/gtag/js?id=G-CJLSR4FQXL"></script>
2424
<link rel="stylesheet"
@@ -35,31 +35,6 @@
3535
}
3636
</style>
3737

38-
<script>
39-
$(function () {
40-
$('h1[id], h2[id], h3[id], h4[id], h5[id]').not(':has(a)').each(function () {
41-
this.innerHTML =
42-
`<a href="#${this.id}" class="h-anchor">
43-
${this.innerHTML} <i class="fas fa-link icon" aria-label="Anchor"></i>
44-
</a>`;
45-
});
46-
47-
if ($('input#search').length > 0) {
48-
docsearch({
49-
apiKey: '5c00a51f166dab99e1cc6e0a9976e9f9',
50-
indexName: 'buildpacks',
51-
inputSelector: 'input#search',
52-
debug: false
53-
});
54-
}
55-
});
56-
57-
window.dataLayer = window.dataLayer || [];
58-
function gtag() { dataLayer.push(arguments); }
59-
gtag('js', new Date());
60-
gtag('config', 'G-CJLSR4FQXL');
61-
</script>
62-
6338
<title>{{ .Title | plainify }} · {{ .Site.Title }}</title>
6439
</head>
6540

themes/buildpacks/layouts/partials/sidebar.html

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
{{- $currentNode := . -}}
22

33
<nav class='sidebar'>
4-
<form class="pt-1 pb-3 pl-2 pr-3 border-bottom">
5-
<input id="search" class="form-control" type="search" placeholder="Search..." aria-label="Search">
6-
</form>
4+
<div id="search"></div>
5+
<script>
6+
window.addEventListener('DOMContentLoaded', (event) => {
7+
new PagefindUI({
8+
element: "#search",
9+
showSubResults: true,
10+
bundlePath: "/pagefind/"
11+
});
12+
});
13+
</script>
714
{{ with .Site.GetPage "/docs" }}
815
{{- $home := . -}}
916
<ul>

tools/go.mod

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ require (
9696
github.com/cespare/xxhash/v2 v2.3.0 // indirect
9797
github.com/chrismellard/docker-credential-acr-env v0.0.0-20230304212654-82a0ddb27589 // indirect
9898
github.com/clbanning/mxj/v2 v2.7.0 // indirect
99-
github.com/cli/safeexec v1.0.1 // indirect
10099
github.com/clipperhouse/stringish v0.1.1 // indirect
101100
github.com/clipperhouse/uax29/v2 v2.3.0 // indirect
102101
github.com/cloudflare/circl v1.6.1 // indirect
@@ -131,15 +130,13 @@ require (
131130
github.com/gdamore/encoding v1.0.1 // indirect
132131
github.com/gdamore/tcell/v2 v2.9.0 // indirect
133132
github.com/getkin/kin-openapi v0.133.0 // indirect
134-
github.com/ghodss/yaml v1.0.0 // indirect
135133
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
136134
github.com/go-git/go-billy/v5 v5.6.2 // indirect
137135
github.com/go-git/go-git/v5 v5.16.3 // indirect
138136
github.com/go-jose/go-jose/v4 v4.1.3 // indirect
139137
github.com/go-logr/logr v1.4.3 // indirect
140138
github.com/go-logr/stdr v1.2.2 // indirect
141139
github.com/go-openapi/jsonpointer v0.22.1 // indirect
142-
github.com/go-openapi/swag v0.25.1 // indirect
143140
github.com/go-openapi/swag/jsonname v0.25.1 // indirect
144141
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
145142
github.com/gobuffalo/flect v1.0.3 // indirect
@@ -171,7 +168,6 @@ require (
171168
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
172169
github.com/heroku/color v0.0.6 // indirect
173170
github.com/inconshreveable/mousetrap v1.1.0 // indirect
174-
github.com/invopop/yaml v0.3.1 // indirect
175171
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
176172
github.com/jdkato/prose v1.2.1 // indirect
177173
github.com/jmespath/go-jmespath v0.4.0 // indirect
@@ -255,8 +251,6 @@ require (
255251
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
256252
github.com/yuin/goldmark v1.7.13 // indirect
257253
github.com/yuin/goldmark-emoji v1.0.6 // indirect
258-
github.com/zeebo/errs v1.4.0 // indirect
259-
go.opencensus.io v0.24.0 // indirect
260254
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
261255
go.opentelemetry.io/contrib/detectors/gcp v1.38.0 // indirect
262256
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
@@ -270,7 +264,6 @@ require (
270264
go.yaml.in/yaml/v2 v2.4.3 // indirect
271265
gocloud.dev v0.43.0 // indirect
272266
golang.org/x/crypto v0.43.0 // indirect
273-
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
274267
golang.org/x/image v0.32.0 // indirect
275268
golang.org/x/mod v0.29.0 // indirect
276269
golang.org/x/net v0.46.0 // indirect
@@ -289,7 +282,6 @@ require (
289282
google.golang.org/grpc v1.76.0 // indirect
290283
google.golang.org/protobuf v1.36.10 // indirect
291284
gopkg.in/warnings.v0 v0.1.2 // indirect
292-
gopkg.in/yaml.v2 v2.4.0 // indirect
293285
gopkg.in/yaml.v3 v3.0.1 // indirect
294286
howett.net/plist v1.0.1 // indirect
295287
rsc.io/qr v0.2.0 // indirect

0 commit comments

Comments
 (0)