astro-accelerator 0.3.17 → 0.3.19

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": "0.3.17",
2
+ "version": "0.3.19",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -31,10 +31,10 @@
31
31
  "dts": "tsc ./tests/locate-content.js ./tests/locate-navigation.js ./tests/locate-search.js --allowJs --declaration --emitDeclarationOnly"
32
32
  },
33
33
  "dependencies": {
34
- "@astrojs/mdx": "^1.1.3",
35
- "astro": "^3.4.3",
36
- "astro-accelerator-utils": "^0.3.2",
37
- "cspell": "^7.3.8",
34
+ "@astrojs/mdx": "^1.1.4",
35
+ "astro": "^3.5.3",
36
+ "astro-accelerator-utils": "^0.3.4",
37
+ "cspell": "^7.3.9",
38
38
  "csv": "^6.3.5",
39
39
  "hast-util-from-selector": "^3.0.0",
40
40
  "html-to-text": "^9.0.5",
@@ -768,6 +768,14 @@ form.site-search #site-search-button {
768
768
  object-fit: cover;
769
769
  }
770
770
 
771
+ .recent-updates li {
772
+ margin-block-end: 1em;
773
+ }
774
+
775
+ .recent-updates time {
776
+ display: block;
777
+ }
778
+
771
779
  @media (max-width: 680px) {
772
780
  /* This is deliberately 680, not 860 */
773
781
  .post-list .list-item[data-image='true'] > article {
@@ -252,8 +252,8 @@ async function getSynonyms() {
252
252
  * Replaces synonyms
253
253
  * @param {string[]} queryTerms
254
254
  */
255
- function replaceSynonyms(queryTerms) {
256
- const synonyms = getSynonyms();
255
+ async function replaceSynonyms(queryTerms) {
256
+ const synonyms = await getSynonyms();
257
257
 
258
258
  for (let i = 0; i < queryTerms.length; i++) {
259
259
  const term = queryTerms[i];
@@ -271,7 +271,7 @@ function replaceSynonyms(queryTerms) {
271
271
  * @param {number|null} [r=12]
272
272
  * @returns
273
273
  */
274
- function search(s, r) {
274
+ async function search(s, r) {
275
275
  const numberOfResults = r ?? 12;
276
276
  console.log('search', s, numberOfResults);
277
277
 
@@ -288,7 +288,7 @@ function search(s, r) {
288
288
  currentQuery = cleanQuery;
289
289
  /** @type {string[]} */
290
290
  const stemmedTerms = [];
291
- const queryTerms = replaceSynonyms(explode(currentQuery));
291
+ const queryTerms = await replaceSynonyms(explode(currentQuery));
292
292
 
293
293
  for (const term of queryTerms) {
294
294
  const stemmed = stemmer(term);
@@ -0,0 +1,38 @@
1
+ ---
2
+ import { PostOrdering, PostFiltering, Accelerator } from 'astro-accelerator-utils';
3
+ import { SITE } from '@config';
4
+
5
+ const accelerator = new Accelerator(SITE);
6
+ const stats = new accelerator.statistics('accelerator/components/RecentlyUpdated.astro');
7
+ stats.start();
8
+
9
+ // Properties
10
+ type Props = {
11
+ lang: string;
12
+ count: number;
13
+ };
14
+ const { lang, count } = Astro.props satisfies Props;
15
+
16
+ // Logic
17
+ const allPages = accelerator.posts.all();
18
+ const pageCount = allPages.length;
19
+ const pages = allPages
20
+ .filter(PostFiltering.hasModDate)
21
+ .filter(PostFiltering.isListable)
22
+ .sort(PostOrdering.sortByModDateDesc)
23
+ .slice(0, Math.min(count, pageCount));
24
+
25
+ console.log('Recent Pages: ' + pageCount);
26
+
27
+ stats.stop();
28
+ ---
29
+ <ul class="recent-updates">
30
+ {pages.map((post) => (
31
+ <li data-destination={ accelerator.urlFormatter.formatAddress(post.url) }>
32
+ <a href={ accelerator.urlFormatter.formatAddress(post.url) }>{ accelerator.markdown.getTextFrom(post.frontmatter.title) }</a>
33
+ <time datetime={ post.frontmatter.modDate.toString() }>
34
+ { accelerator.dateFormatter.formatDate(post.frontmatter.modDate, lang) }
35
+ </time>
36
+ </li>
37
+ ))}
38
+ </ul>
@@ -1,38 +0,0 @@
1
- ---
2
- title: Welcome to Astro *Accelerator*
3
- subtitle: A *super-lightweight*, accessible, SEO-friendly starter project for Astro
4
- navTitle: Home
5
- navOrder: 0
6
- pubDate: 2022-09-17
7
- keywords: astro,accelerator,site generator
8
- description: An accelerator for a very clean version of Astro.
9
- bannerImage:
10
- src: /img/surface-accessories.png
11
- alt: Dummy image
12
- ---
13
-
14
- Welcome to Astro Accelerator. A super-lightweight, accessible, SEO friendly starter project for [Astro](https://astro.build/).
15
-
16
- :::div{.note}
17
- The Astro Accelerator source code is available on [GitHub](https://github.com/Steve-Fenton/astro-accelerator).
18
- :::
19
-
20
- Astro Accelerator is built on some strong opinions:
21
-
22
- - Accessibility is not just important, it's fundamental
23
- - Everything should work without JavaScript
24
- - The democratizing force in the World Wide Web is HTML files
25
- - Software supply chains should be minimal
26
-
27
- > Astro is the first framework build on the *majestic HTML* concept, where pages can be largely static but still enhanced with additional stateful behavior where needed.
28
- >
29
- > It's clean semantic HTML, simple CSS, and some minor non-essential enhancements in plain JavaScript. <cite>Steve Fenton</cite>
30
-
31
- Out of the box, Astro Accelerator is a "top scores" high-performance website in the lab. [Pagespeed Insights](https://developers.google.com/speed/docs/insights/v5/about?hl=en-US) tests website performance on mobile and desktop across a number of measurements.
32
-
33
- :::figure
34
- :img{ src="/img/astro-lighthouse.png" alt="Astro Lighthouse Score (100% in all categories)" loading="lazy" }
35
- ::figcaption[Top scores across the board]
36
- :::
37
-
38
- Test scores aren't everything, but Astro Accelerator is light and fast.