astro-accelerator 0.0.111 → 0.3.0

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/astro.config.mjs CHANGED
@@ -17,6 +17,6 @@ export default defineConfig({
17
17
  ],
18
18
  extendDefaultPlugins: true,
19
19
  trailingSlash: 'always',
20
- server: { port: 3000, host: true},
21
20
  },
21
+ server: { port: 3000, host: true},
22
22
  });
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.111",
2
+ "version": "0.3.0",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -25,15 +25,15 @@
25
25
  "dts": "tsc ./tests/locate-content.js ./tests/locate-navigation.js ./tests/locate-search.js --allowJs --declaration --emitDeclarationOnly"
26
26
  },
27
27
  "dependencies": {
28
- "@astrojs/mdx": "^0.19.7",
29
- "astro": "^2.10.1",
30
- "astro-accelerator-utils": "^0.2.38",
31
- "csv": "^6.3.1",
28
+ "@astrojs/mdx": "^1.0.0",
29
+ "astro": "^3.0.0",
30
+ "astro-accelerator-utils": "^0.2.39",
31
+ "csv": "^6.3.3",
32
32
  "hast-util-from-selector": "^3.0.0",
33
33
  "html-to-text": "^9.0.5",
34
34
  "keyword-extractor": "^0.0.25",
35
35
  "remark-directive": "^2.0.1",
36
- "sharp": "^0.32.4"
36
+ "sharp": "^0.32.5"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@playwright/test": "^1.36.2"
@@ -616,7 +616,7 @@ form.site-search label > * {
616
616
  padding: 0.2em;
617
617
  }
618
618
 
619
- form.site-search button {
619
+ form.site-search #site-search-button {
620
620
  display: none;
621
621
  }
622
622
 
@@ -676,6 +676,39 @@ form.site-search button {
676
676
  }
677
677
  }
678
678
 
679
+ /* Search dialog */
680
+
681
+ .search-dialog {
682
+ margin: auto;
683
+ padding: 2rem 3rem;
684
+ border-radius: var(--block-radius);
685
+ box-shadow: var(--box-shadow);
686
+ height: calc(90vh - 4em);
687
+ width: calc(80vw - 6em);
688
+ }
689
+
690
+ .search-dialog form {
691
+ margin-top: 2rem;
692
+ }
693
+
694
+ #site-search-close {
695
+ float: right;
696
+ position: relative;
697
+ top: -1rem;
698
+ left: 2.5rem;
699
+ background: none;
700
+ cursor: pointer;
701
+ font-size: 2rem;
702
+ stroke: var(--link-head);
703
+ }
704
+
705
+ @media (max-width: 860px) {
706
+ .search-dialog {
707
+ height: calc(100vh - 4em);
708
+ width: calc(100vw - 6em);
709
+ }
710
+ }
711
+
679
712
  /* Articles */
680
713
 
681
714
  .post-list {
package/public/js/main.js CHANGED
@@ -59,3 +59,8 @@ if (enabled(f.headers, 'link')) {
59
59
  const headers = await import('./modules/headers.js');
60
60
  headers.enhanceHeaders();
61
61
  }
62
+
63
+ if (enabled(f.search, 'dialog')) {
64
+ const searchDialog = await import ('./modules/search-dialog.js');
65
+ searchDialog.enhanceSearchIcon();
66
+ }
@@ -0,0 +1,55 @@
1
+ // @ts-check
2
+
3
+ function enhanceSearchIcon() {
4
+ if (document.querySelector('#site-search-query') == null) {
5
+ const icon = document.querySelector('a.search-icon');
6
+
7
+ if (icon != null) {
8
+ fetch(icon.href)
9
+ .then(response => response.text())
10
+ .then(html => {
11
+ const parser = new DOMParser();
12
+ const doc = parser.parseFromString(html, 'text/html');
13
+ const form = doc.querySelector('#site-search');
14
+ const input = form.querySelector('#site-search-query');
15
+ const results = doc.querySelector('#site-search-results');
16
+
17
+
18
+ input?.setAttribute('autofocus', 'autofocus');
19
+
20
+ const close = document.createElement('button');
21
+ close.id = 'site-search-close';
22
+ close.value = 'cancel';
23
+ close.formMethod = 'dialog';
24
+ close.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 24 24" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round">
25
+ <path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
26
+ <line x1="18" y1="6" x2="6" y2="18"></line>
27
+ <line x1="6" y1="6" x2="18" y2="18"></line>
28
+ </svg>`;
29
+ close.addEventListener('click', () => dialog.close());
30
+
31
+ const script = doc.querySelector('script[src*="/search.js"]');
32
+ const scr = document.createElement('script');
33
+ for (let att, i = 0, atts = script.attributes, n = atts.length; i < n; i++){
34
+ att = atts[i];
35
+ scr.setAttribute(att.nodeName, att.nodeValue ?? '');
36
+ }
37
+
38
+ const dialog = document.createElement('dialog');
39
+ dialog.className = 'search-dialog';
40
+ dialog.append(close, form, results);
41
+
42
+ document.body.appendChild(dialog);
43
+ document.body.appendChild(scr);
44
+
45
+ icon.addEventListener('click', (e) => {
46
+ e.preventDefault();
47
+ dialog.showModal();
48
+ return false;
49
+ })
50
+ });
51
+ }
52
+ }
53
+ }
54
+
55
+ export { enhanceSearchIcon };
@@ -247,8 +247,6 @@ function search(s, r) {
247
247
  return;
248
248
  }
249
249
 
250
- raiseEvent('searched', { search: s });
251
-
252
250
  currentQuery = cleanQuery;
253
251
  /** @type {string[]} */
254
252
  const stemmedTerms = [];
@@ -447,6 +445,7 @@ function search(s, r) {
447
445
 
448
446
  const address = window.location.href.split('?')[0];
449
447
  window.history.pushState({}, '', address + '?q=' + encodeURIComponent(cleanQuery));
448
+ raiseEvent('searched', { search: s });
450
449
  }
451
450
 
452
451
  /** @type {Number} */
package/src/config.ts CHANGED
@@ -38,6 +38,7 @@ const SITE: Site = {
38
38
  youTubeLinks: ['embed'],
39
39
  headers: ['link'],
40
40
  details: ['tabs'],
41
+ search: ['dialog'],
41
42
  },
42
43
  images: {
43
44
  // Generated using https://ausi.github.io/respimagelint/
package/src/env.d.ts ADDED
@@ -0,0 +1 @@
1
+ /// <reference types="astro/client" />
@@ -54,7 +54,7 @@ stats.stop();
54
54
  </time>
55
55
  {frontmatter.modDate &&
56
56
  <br /><time datetime={ frontmatter.modDate.toString() } itemprop="dateModified">
57
- { _(Translations.post.last_modified) } { accelerator.dateFormatter.formatDate(frontmatter.modDate, lang) }
57
+ { _(Translations.post.last_modified) + ' ' + accelerator.dateFormatter.formatDate(frontmatter.modDate, lang) }
58
58
  </time>
59
59
  }{authorList.mainAuthor &&
60
60
  <p>{ authorList.mainAuthor.frontmatter.description }</p>