Skip to content

Commit 3299548

Browse files
committed
feat(search): add search using pagefind
1 parent 289ea5e commit 3299548

13 files changed

Lines changed: 739 additions & 78 deletions

_includes/layouts/base.njk

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>{{ title or metadata.title }}</title>
6+
<title data-pagefind-meta="title">{{ title or metadata.title }}</title>
77
<meta name="description" content="{{ description or metadata.description }}">
88
{% favicon './public/favicon.svg' %}
99
{# Atom and JSON feeds included by default #}
@@ -21,6 +21,7 @@
2121
See https://github.com/11ty/eleventy/issues/2807
2222
#}
2323
<link rel="stylesheet" href="/css/index.css" />
24+
<link rel="stylesheet" href="/css/search.css" />
2425
{# Add an arbitrary string to the bundle #}
2526
{# {%- css %}* { box-sizing: border-box; }{% endcss %} #}
2627
{# Render the CSS bundle using Inlined CSS (for the fastest site performance in production) #}
@@ -111,13 +112,14 @@
111112
</div>
112113
<div id="bug-tracker-form" class="flex-column flex-between-center">
113114
<h1>Bug Tracker</h1>
114-
<form class="flex-row flex-start-center" action="/search" method="get">
115+
<div id="search"></div>
116+
{# <form class="flex-row flex-start-center" action="/search" method="get">
115117
<label for="jq-primarySearch">Search Tickets</label>
116118
<input type="text" value="" title="Search jQuery" name="q" id="jq-primarySearch">
117119
<button type="submit" name="go" id="jq-searchButton">
118120
<span class="visually-hidden">Search</span>
119121
</button>
120-
</form>
122+
</form> #}
121123
</div>
122124
</header>
123125
<main id="skip" class="flex-column">
@@ -139,6 +141,18 @@
139141
<a href="https://openjsf.org">The OpenJS Foundation</a>
140142
</footer>
141143
</div>
142-
<!-- Current page: {{ page.url | htmlBaseUrl }} -->
144+
<script src="/_pagefind/pagefind-ui.js" type="text/javascript"></script>
145+
<script>
146+
window.addEventListener('DOMContentLoaded', (event) => {
147+
new PagefindUI({
148+
element: "#search",
149+
showImages: false,
150+
translations: {
151+
placeholder: '',
152+
zero_results: 'No matches found.'
153+
}
154+
})
155+
})
156+
</script>
143157
</body>
144158
</html>

_includes/layouts/ticket.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ layout: layouts/base.njk
44

55
<link rel="stylesheet" href="/css/ticket.css" />
66

7-
<div class="flex-column">
7+
<div class="flex-column" data-pagefind-body>
88
{{ content | safe }}
99
</div>

content/milestone.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ permalink: '/milestone/{{ milestone.name }}/index.html'
1111
tags: ['milestone']
1212
---
1313

14-
<div class="flex-column">
14+
<div class="flex-column" data-pagefind-body>
1515
<nav class="content-nav">
1616
<ul class="flex-row">
1717
{% if pagination.href.previous %}

content/search.njk

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
layout: layouts/base.njk
3+
---
4+
5+
<link rel="stylesheet" href="/css/fullpagesearch.css" />
6+
7+
<h1>Search</h1>
8+
<hr>
9+
10+
<div id="full-page-search"></div>
11+
12+
<script>
13+
window.addEventListener('DOMContentLoaded', (event) => {
14+
new PagefindUI({
15+
element: "#full-page-search",
16+
showImages: false,
17+
translations: {
18+
placeholder: 'Search all tickets and milestones',
19+
zero_results: 'No matches found.'
20+
}
21+
})
22+
})
23+
</script>

content/ticket.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
return tickets
1616
}
17-
return paginationData
17+
return paginationData.slice(0, 5)
1818
}
1919
},
2020
layout: 'layouts/ticket.njk',

eleventy.config.drafts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = (eleventyConfig) => {
4949

5050
// Only log once.
5151
if (!logged) {
52-
console.log(`[elevent.config.drafts] ${text} drafts.`)
52+
console.log(`[eleventy.config.drafts] ${text} drafts.`)
5353
}
5454

5555
logged = true

eleventy.config.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,17 @@ module.exports = function (eleventyConfig) {
3939
[`./zip-attachment/ticket/${attachTicket}`]: `/zip-attachment/ticket/${attachTicket}`
4040
})
4141
} else {
42-
eleventyConfig.addPassthroughCopy({
43-
'./raw-attachment/': '/raw-attachment/',
44-
'./zip-attachment/': '/zip-attachment/'
45-
})
42+
eleventyConfig.addPassthroughCopy(
43+
{
44+
'./raw-attachment/': '/raw-attachment/',
45+
'./zip-attachment/': '/zip-attachment/'
46+
},
47+
{
48+
// Lower default concurrency to avoid EMFILE errors
49+
// See https://github.com/11ty/eleventy/issues/2604
50+
concurrency: 100
51+
}
52+
)
4653
}
4754

4855
// Run Eleventy when these files change:

0 commit comments

Comments
 (0)