astro-accelerator 6.0.12 → 6.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "6.0.12",
2
+ "version": "6.0.14",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -859,6 +859,7 @@ code {
859
859
  }
860
860
 
861
861
  pre.astro-code {
862
+ border-radius: var(--block-radius);
862
863
  font-family: var(--code-font);
863
864
  margin: var(--block-gap) 0;
864
865
  overflow: auto;
@@ -59,6 +59,7 @@ function sanitise(string) {
59
59
  string
60
60
  .trim()
61
61
  .normalize('NFD')
62
+ .replace(/./g, ' ')
62
63
  .replace(/[\u0300-\u036f]/g, '')
63
64
  .toLowerCase()
64
65
  .replace(/-/g, '');
@@ -60,6 +60,7 @@ function unique(value, index, array) {
60
60
  tags: string[];
61
61
  url: string;
62
62
  date: string;
63
+ bannerImage: { src: string; alt: string } | null;
63
64
  matchedHeadings: Heading[];
64
65
  }
65
66
  } SearchEntry
@@ -358,40 +359,11 @@ function initializeSearch() {
358
359
 
359
360
  const path = document.createElement('div');
360
361
  path.className = 'result-path';
361
-
362
- // Split the path into segments, filter out empty segments (in case of leading slash)
363
- const segments = address.pathname.split('/').filter(Boolean);
364
-
365
- segments.forEach((segment, index) => {
366
- const words = segment.replace(/-/g, ' ').split(' ');
367
- const processedSegment = words
368
- .map((word, index) =>
369
- index === 0
370
- ? word.charAt(0).toUpperCase() +
371
- word.slice(1).toLowerCase()
372
- : word.toLowerCase()
373
- )
374
- .join(' ');
375
-
376
- const segmentSpan = document.createElement('span');
377
- segmentSpan.className = 'result-path-segment';
378
- segmentSpan.textContent = processedSegment;
379
- path.appendChild(segmentSpan);
380
-
381
- if (index < segments.length - 1) {
382
- const svgIcon = document.createElement('span');
383
- svgIcon.className = 'result-path-icon';
384
- svgIcon.innerHTML = `
385
- <svg xmlns="http://www.w3.org/2000/svg" width="6" height="10" viewBox="0 0 6 10">
386
- <path d="M1 9L5 5L1 1" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
387
- </svg>
388
- `;
389
- path.appendChild(svgIcon);
390
- }
391
- });
362
+ path.innerText = address.pathname;
392
363
 
393
364
  const listElementDescription = document.createElement('p');
394
365
  listElementDescription.className = 'result-description';
366
+
395
367
  // Only highlight user query terms, not stemmed terms
396
368
  listElementDescription.innerHTML = highlight(
397
369
  needle.description,
@@ -404,9 +376,22 @@ function initializeSearch() {
404
376
  li.dataset.score = (
405
377
  Math.round((needle.score / total) * 1000) / 1000
406
378
  ).toString();
407
- listElementWrapper.appendChild(path);
408
- listElementWrapper.appendChild(listElementTitle);
409
- listElementWrapper.appendChild(listElementDescription);
379
+ const resultContent = document.createElement('div');
380
+ resultContent.className = 'result-content';
381
+ resultContent.appendChild(path);
382
+ resultContent.appendChild(listElementTitle);
383
+ resultContent.appendChild(listElementDescription);
384
+
385
+ if (needle.bannerImage) {
386
+ const resultImage = document.createElement('img');
387
+ resultImage.src = needle.bannerImage.src;
388
+ resultImage.alt = needle.bannerImage.alt;
389
+ resultImage.className = 'result-image';
390
+ resultImage.loading = 'lazy';
391
+ listElementWrapper.appendChild(resultImage);
392
+ }
393
+
394
+ listElementWrapper.appendChild(resultContent);
410
395
  li.appendChild(listElementWrapper);
411
396
 
412
397
  if (
@@ -489,8 +474,8 @@ function initializeSearch() {
489
474
  throw new Error('Cannot find .site-search-query');
490
475
  }
491
476
 
492
- // Words chained with . are combined, i.e. System.Text is "systemtext"
493
- var s = input.value.replace(/\./g, '').trim();
477
+ // Words chained with . are exploded, i.e. System.Text is "system text"
478
+ var s = input.value.replace(/\./g, ' ').trim();
494
479
 
495
480
  if (!s) {
496
481
  const address = window.location.href.split('?')[0];
@@ -70,6 +70,7 @@ const getData = async () => {
70
70
  tags: page.frontmatter.tags ?? [],
71
71
  url: SITE.url + accelerator.urlFormatter.formatAddress(url),
72
72
  date: page.frontmatter.pubDate ?? '',
73
+ bannerImage: page.frontmatter.bannerImage ?? null,
73
74
  });
74
75
  }
75
76
 
@@ -36,56 +36,127 @@ const accelerator = new Accelerator(SITE);
36
36
  </div>
37
37
 
38
38
  <style is:global>
39
+ .site-search-wrapper {
40
+ width: 100%;
41
+ }
42
+
39
43
  .site-search-wrapper fieldset {
40
44
  height: 100%;
41
45
  display: flex;
42
- align-items: center;
46
+ gap: 0.75rem;
47
+ align-items: stretch;
43
48
  padding: 0;
44
49
  }
45
50
 
46
51
  .site-search-wrapper input {
47
52
  background-color: var(--aft-block);
48
53
  border-radius: var(--block-radius);
54
+ border: 2px solid var(--fore-link);
49
55
  color: var(--fore);
50
- font-size: 1.3rem;
51
- padding: 0.5em;
56
+ font-size: 1.1rem;
57
+ font-family: var(--content-font);
58
+ padding: 0.75em 1em;
59
+ flex: 1;
60
+ transition: border-color 0.2s ease, box-shadow 0.2s ease;
52
61
  }
53
62
 
54
- .site-search-wrapper input {
55
- width: calc(100% - 110px);
63
+ .site-search-wrapper input::placeholder {
64
+ color: var(--fore-block);
65
+ opacity: 0.7;
56
66
  }
57
67
 
58
68
  .site-search-wrapper button {
59
- width: 80px;
69
+ width: 100px;
70
+ border-radius: var(--block-radius);
71
+ background-color: var(--fore-link);
72
+ color: var(--aft);
73
+ font-family: var(--content-font);
74
+ font-size: 1rem;
75
+ font-weight: 600;
76
+ border: none;
77
+ cursor: pointer;
78
+ transition: background-color 0.2s ease, transform 0.1s ease;
79
+ }
80
+
81
+ .site-search-wrapper button:hover {
82
+ background-color: var(--fore-link-alt);
83
+ }
84
+
85
+ .site-search-wrapper button:active {
86
+ transform: scale(0.98);
87
+ }
88
+
89
+ .site-search-results {
90
+ margin-top: 2rem;
60
91
  }
61
92
 
62
93
  .site-search-results ul.site-search-results-list {
63
94
  list-style-type: none;
64
- margin-block: 1rem;
95
+ margin-block: 0;
65
96
  margin-inline: 0;
97
+ padding: 0;
98
+ display: flex;
99
+ flex-direction: column;
100
+ gap: 1.5rem;
66
101
  }
67
102
 
68
103
  .site-search-results li.site-search-results-item {
69
104
  list-style-type: none;
70
- margin: var(--block-gap-l) 0 var(--block-gap-l) 0;
105
+ padding: var(--paragraph-margin);
106
+ background-color: var(--aft-block);
107
+ border-radius: var(--block-radius);
108
+ box-shadow: var(--box-shadow-slight);
109
+ color: var(--fore-block);
110
+ transition: box-shadow 0.2s ease, transform 0.2s ease;
111
+ }
112
+
113
+ .site-search-results li.site-search-results-item:hover {
114
+ box-shadow: var(--box-shadow);
115
+ transform: translateY(-2px);
71
116
  }
72
117
 
73
118
  .site-search-results-item a {
74
119
  text-decoration: none;
120
+ display: flex;
121
+ gap: 1.5rem;
122
+ align-items: flex-start;
123
+ }
124
+
125
+ .result-image {
126
+ width: 120px;
127
+ height: 120px;
128
+ object-fit: cover;
129
+ border-radius: var(--block-radius);
130
+ flex-shrink: 0;
131
+ }
132
+
133
+ .result-content {
134
+ flex: 1;
135
+ min-width: 0;
75
136
  }
76
137
 
77
138
  .site-search-results .show-more {
78
- margin-block-start: 1rem;
79
139
  display: inline-block;
80
- font-size: 1.2rem;
140
+ font-size: 1rem;
141
+ font-family: var(--content-font);
81
142
  border-radius: 100px;
82
143
  text-decoration: none;
83
144
  text-align: center;
84
- padding: 0.2em 0.6em 0.3em 0.6em;
85
- color: var(--aft-link-alt);
145
+ padding: 0.6em 1.5em;
146
+ margin-top: 1.5rem;
147
+ color: var(--aft);
86
148
  background-color: var(--fore-link);
87
149
  cursor: pointer;
88
150
  width: auto;
151
+ transition: background-color 0.2s ease, transform 0.1s ease;
152
+ }
153
+
154
+ .site-search-results .show-more:hover {
155
+ background-color: var(--fore-link-alt);
156
+ }
157
+
158
+ .site-search-results .show-more:active {
159
+ transform: scale(0.98);
89
160
  }
90
161
 
91
162
  .result-wrapper mark,
@@ -96,36 +167,85 @@ const accelerator = new Accelerator(SITE);
96
167
  }
97
168
 
98
169
  .result-path {
99
- display: none;
100
- }
101
-
102
- .result-path-icon {
103
- stroke: var(--fore);
170
+ font-size: 0.85rem;
171
+ color: var(--fore-block);
172
+ opacity: 0.7;
173
+ margin-bottom: 0.25rem;
174
+ white-space: nowrap;
175
+ overflow: hidden;
176
+ text-overflow: ellipsis;
104
177
  }
105
178
 
106
179
  .result-path-segment:last-child {
107
180
  color: var(--fore-link);
181
+ font-weight: 600;
182
+ }
183
+
184
+ .result-path-icon {
185
+ stroke: var(--fore-block);
186
+ opacity: 0.5;
108
187
  }
109
188
 
110
189
  .result-title {
111
190
  color: var(--fore-link);
112
- font-size: 1.5rem;
191
+ font-size: 1.35rem;
113
192
  font-weight: 700;
193
+ font-family: var(--heading-font);
194
+ line-height: 1.3;
195
+ margin-bottom: 0.5rem;
114
196
  }
115
197
 
116
198
  .result-description {
117
199
  color: var(--fore-block);
118
200
  font-size: 1rem;
119
201
  font-weight: 400;
202
+ font-family: var(--content-font);
120
203
  margin: 0;
204
+ line-height: 1.6;
121
205
  }
122
206
 
123
207
  .result-headings {
124
208
  list-style: none;
125
- font-size: 1rem;
209
+ font-size: 0.95rem;
210
+ margin-top: 0.5rem;
211
+ padding-inline-start: 0;
212
+ }
213
+
214
+ .result-headings li {
215
+ padding: 0 0 calc(var(--paragraph-margin) / 2) 0;
216
+ list-style-type: '➜ ';
126
217
  }
127
218
 
128
- .result-headings li:not(:last-child) {
129
- text-align: left;
219
+ @media (max-width: 600px) {
220
+ .site-search-wrapper fieldset {
221
+ flex-direction: column;
222
+ }
223
+
224
+ .site-search-wrapper input {
225
+ width: unset;
226
+ }
227
+
228
+ .result-wrapper {
229
+ flex-direction: column;
230
+ gap: 1rem;
231
+ }
232
+
233
+ .result-image {
234
+ width: 100%;
235
+ height: auto;
236
+ max-height: 200px;
237
+ }
238
+
239
+ .site-search-wrapper button {
240
+ width: 100%;
241
+ }
242
+
243
+ .site-search-results li.site-search-results-item {
244
+ padding: 1rem;
245
+ }
246
+
247
+ .result-title {
248
+ font-size: 1.2rem;
249
+ }
130
250
  }
131
251
  </style>