Skip to content

Commit 28dd9d1

Browse files
dougaitkenclaude
andcommitted
Add search functionality with Pagefind
- Add search icon to header navigation linking to search box - Add search box on homepage with Pagefind UI - Configure Pagefind to index all company profile pages individually - Add comprehensive dark mode styling for search UI - Ensure search results are visible and accessible in both themes Search now indexes 877 pages including all company profiles, allowing users to quickly find companies by name, website, or region. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent de9fd8b commit 28dd9d1

File tree

4 files changed

+120
-5
lines changed

4 files changed

+120
-5
lines changed

src/_includes/partials/header.njk

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,31 @@
99
</a>
1010
<div class="cluster gutter-s">
1111
{% include "partials/main-nav.njk" %}
12+
<a href="/#search" class="search-icon" aria-label="Search companies">
13+
{% svg "misc/search" %}
14+
</a>
1215
{% include 'partials/theme-switch.njk' %}
1316
</div>
1417
</div>
1518
</header>
19+
20+
{%- css "global" -%}
21+
.search-icon {
22+
display: inline-flex;
23+
align-items: center;
24+
padding: var(--space-xs);
25+
color: var(--color-text);
26+
text-decoration: none;
27+
border-radius: var(--border-radius-small);
28+
transition: background-color 0.2s ease;
29+
}
30+
31+
.search-icon:hover {
32+
background-color: var(--color-bg-accent);
33+
}
34+
35+
.search-icon svg {
36+
width: 1.2em;
37+
height: 1.2em;
38+
}
39+
{%- endcss -%}

src/_layouts/company.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
layout: base
33
---
44

5-
<article class="region wrapper flow prose">
5+
<article class="region wrapper flow prose" data-pagefind-body>
66
<header>
77
<h1 class="gradient-text">{{ name }}</h1>
88
<p class="meta | cluster gutter-xs-s">

src/assets/svg/misc/search.svg

Lines changed: 4 additions & 0 deletions
Loading

src/pages/index.njk

Lines changed: 91 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,26 @@ description: 'A list of semi to fully remote-friendly companies in tech'
2020
</p>
2121
</div>
2222

23-
<!-- Search will be inserted here by Pagefind -->
24-
<div id="search"></div>
23+
<!-- Search Companies -->
24+
<div class="search-container">
25+
<div id="search"></div>
26+
</div>
2527

2628
<script>
2729
window.addEventListener('DOMContentLoaded', (event) => {
2830
new PagefindUI({
2931
element: "#search",
3032
showSubResults: true,
3133
showImages: false,
32-
excerptLength: 15
34+
excerptLength: 15,
35+
placeholder: "Search companies..."
3336
});
3437
});
3538
</script>
3639

3740
<!-- Company Table -->
3841
<div class="company-list-container region">
39-
<table class="company-table" data-pagefind-body>
42+
<table class="company-table">
4043
<thead>
4144
<tr>
4245
<th>Name</th>
@@ -71,6 +74,90 @@ description: 'A list of semi to fully remote-friendly companies in tech'
7174
</div>
7275

7376
{%- css "local" -%}
77+
/* Search container */
78+
.search-container {
79+
margin-block: var(--space-m);
80+
}
81+
82+
/* Pagefind UI dark mode styles */
83+
.pagefind-ui__search-input {
84+
background-color: var(--color-bg) !important;
85+
border-color: var(--color-bg-accent) !important;
86+
color: var(--color-text) !important;
87+
}
88+
89+
.pagefind-ui__search-input::placeholder {
90+
color: var(--color-text-accent) !important;
91+
}
92+
93+
.pagefind-ui__search-input:focus {
94+
border-color: var(--color-primary) !important;
95+
}
96+
97+
.pagefind-ui__search-clear {
98+
background-color: var(--color-bg-accent) !important;
99+
color: var(--color-text) !important;
100+
}
101+
102+
.pagefind-ui__search-clear:hover {
103+
background-color: var(--color-bg-accent-2) !important;
104+
}
105+
106+
.pagefind-ui__drawer {
107+
background-color: var(--color-bg) !important;
108+
border-color: var(--color-bg-accent) !important;
109+
}
110+
111+
.pagefind-ui__result {
112+
background-color: var(--color-bg) !important;
113+
border-color: var(--color-bg-accent) !important;
114+
}
115+
116+
.pagefind-ui__result:hover {
117+
background-color: var(--color-bg-accent) !important;
118+
}
119+
120+
.pagefind-ui__result-link {
121+
color: var(--color-text) !important;
122+
text-decoration: none !important;
123+
}
124+
125+
.pagefind-ui__result-link:hover {
126+
color: var(--color-primary) !important;
127+
}
128+
129+
.pagefind-ui__result-title {
130+
color: var(--color-primary) !important;
131+
}
132+
133+
.pagefind-ui__result-excerpt {
134+
color: var(--color-text) !important;
135+
}
136+
137+
.pagefind-ui__result-nested {
138+
color: var(--color-text-accent) !important;
139+
}
140+
141+
.pagefind-ui__message {
142+
color: var(--color-text) !important;
143+
}
144+
145+
.pagefind-ui__button {
146+
background-color: var(--color-bg-accent) !important;
147+
border-color: var(--color-bg-accent-2) !important;
148+
color: var(--color-text) !important;
149+
}
150+
151+
.pagefind-ui__button:hover {
152+
background-color: var(--color-bg-accent-2) !important;
153+
}
154+
155+
.pagefind-ui mark,
156+
mark {
157+
background-color: var(--color-tertiary) !important;
158+
color: var(--color-dark) !important;
159+
}
160+
74161
/* Override global table styles for company table */
75162
.company-list-container {
76163
--region-space: var(--space-m);

0 commit comments

Comments
 (0)