Skip to content

Commit 69ad795

Browse files
committed
Add Page Find
1 parent 22ac8f5 commit 69ad795

File tree

7 files changed

+130
-4
lines changed

7 files changed

+130
-4
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,14 @@ jobs:
4444
uses: actions/setup-node@v4
4545
with:
4646
node-version: "18"
47-
- name: Install PurgeCSS and Terser
47+
- name: Install PurgeCSS, Terser, and PageFind
4848
run: |
4949
npm install -g purgecss
5050
npm install -g terser
51+
npm install -g pagefind
52+
53+
- name: Index site with PageFind
54+
run: npx pagefind --site _site
5155
- name: Compress CSS with PurgeCSS
5256
run: |
5357
purgecss --config purgecss.config.js

.github/workflows/deploy.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages
15+
cancel-in-progress: true
16+
17+
jobs:
18+
build:
19+
name: Build and index
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Ruby
26+
uses: ruby/setup-ruby@4a9ddd6f338a97768b8006bf671dfbad383215f4
27+
with:
28+
ruby-version: "3.1"
29+
bundler-cache: true
30+
cache-version: 0
31+
32+
- name: Build with Jekyll
33+
run: bundle exec jekyll build
34+
env:
35+
JEKYLL_ENV: production
36+
37+
- name: Install Minify
38+
run: |
39+
sudo apt-get update
40+
sudo apt-get install -y minify
41+
42+
- name: Compress HTML
43+
run: |
44+
minify --all --html-keep-document-tags --html-keep-end-tags -r -o _site/ _site/
45+
46+
- name: Setup Node
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: "18"
50+
51+
- name: Install PurgeCSS, Terser, and PageFind
52+
run: |
53+
npm install -g purgecss
54+
npm install -g terser
55+
npm install -g pagefind
56+
57+
- name: Index site with PageFind
58+
run: npx pagefind --site _site
59+
60+
- name: Compress CSS with PurgeCSS
61+
run: |
62+
purgecss --config purgecss.config.js
63+
64+
- name: Compress JavaScript with Terser
65+
run: |
66+
terser _site/assets/js/main.js --compress ecma=2015,top_retain=window.conference --mangle --comments false --output _site/assets/js/main.js
67+
68+
- name: Upload Pages artifact
69+
uses: actions/upload-pages-artifact@v3
70+
with:
71+
path: _site/
72+
73+
deploy:
74+
name: Deploy
75+
needs: build
76+
runs-on: ubuntu-latest
77+
environment:
78+
name: github-pages
79+
url: ${{ steps.deployment.outputs.page_url }}
80+
steps:
81+
- name: Deploy to GitHub Pages
82+
id: deployment
83+
uses: actions/deploy-pages@v4

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ conference:
109109
relative_url: /instructors/travel-lodging
110110
- name: Honorarium Payment, Per Diem, and Travel Reimbursement
111111
relative_url: /instructors/honoraria-logistics
112-
- name: AQMMR & EMW
112+
- name: AQMMR & EMW
113113
relative_url: /weekend-workshops/
114114
menu:
115115

_includes/partials/header.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ <h1 class="display-4">
5656
{%- endunless -%}
5757

5858
</header>
59-
<main class="container">
59+
<main class="container" data-pagefind-body>
6060

6161
{%- include partials/info_bar.html -%}

_includes/partials/navbar.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
{%- endif -%}
8080
{%- endfor %}
8181
</ul>
82+
83+
<form class="form-inline ml-3" action="/search/" method="get" role="search">
84+
<input class="form-control form-control-sm" type="search" name="q" placeholder="Search…" aria-label="Search" style="width: 120px;">
85+
</form>
8286
</div>
8387

8488
{%- if site.conference.navigation.logo %}

_layouts/page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% include partials/header.html %}
22

33
{% if page.title -%}
4-
<h1 class="display-5 mb-3 text-break">{{ page.title }}</h1>
4+
<h1 class="display-5 mb-3 text-break" data-pagefind-meta="title">{{ page.title }}</h1>
55
{%- endif %}
66

77
{{ content }}

search/index.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
layout: page
3+
title: Search
4+
---
5+
6+
<link href="/pagefind/pagefind-ui.css" rel="stylesheet" />
7+
8+
<div id="search" class="mt-3"></div>
9+
10+
<script>
11+
function initSearch() {
12+
new PagefindUI({
13+
element: '#search',
14+
showImages: false,
15+
excerptLength: 30
16+
});
17+
var q = new URLSearchParams(window.location.search).get('q');
18+
if (q) {
19+
setTimeout(function () {
20+
var input = document.querySelector('.pagefind-ui__search-input');
21+
if (input) {
22+
input.value = q;
23+
input.dispatchEvent(new Event('input', { bubbles: true }));
24+
}
25+
}, 50);
26+
}
27+
}
28+
29+
function searchUnavailable() {
30+
document.getElementById('search').innerHTML =
31+
'<p class="text-muted">Search index not available in local development. ' +
32+
'Run <code>bundle exec jekyll build &amp;&amp; npx pagefind --site _site</code> to enable search.</p>';
33+
}
34+
</script>
35+
<script src="/pagefind/pagefind-ui.js" onload="initSearch()" onerror="searchUnavailable()"></script>

0 commit comments

Comments
 (0)