astro-accelerator 0.0.46 → 0.0.48

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.0.46",
2
+ "version": "0.0.48",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@squoosh/lib": "^0.4.0",
28
- "astro": "^1.6.13",
29
- "astro-accelerator-utils": "^0.2.10",
28
+ "astro": "^1.6.14",
29
+ "astro-accelerator-utils": "^0.2.12",
30
30
  "hast-util-from-selector": "^2.0.0",
31
31
  "remark-directive": "^2.0.1"
32
32
  },
33
33
  "devDependencies": {
34
- "@playwright/test": "^1.27.1"
34
+ "@playwright/test": "^1.28.1"
35
35
  },
36
36
  "engines": {
37
37
  "node": "*"
@@ -44,7 +44,7 @@ summary:focus {
44
44
  background-color: var(--aft-link-alt);
45
45
  }
46
46
 
47
- :focus {
47
+ .input-keyboard :focus {
48
48
  outline: 2px dashed var(--fore-link-alt);
49
49
  border-radius: 5px;
50
50
  }
package/public/js/main.js CHANGED
@@ -5,6 +5,7 @@ import { addStickyNavigation } from './modules/nav-sticky.js';
5
5
  import { addMobileNav } from './modules/nav-mobile.js';
6
6
  import { setClickableBlocks } from './modules/click-blocks.js';
7
7
  import { setExternalLinkAttributes } from './modules/external-links.js';
8
+ import { monitorInputType } from './modules/input-type.js';
8
9
 
9
10
  const resizedEventName = addResizedEvent();
10
11
 
@@ -14,6 +15,7 @@ addStickyNavigation('.site-header', '#site-nav', '#site-nav > ul', resizedEventN
14
15
  addMobileNav(resizedEventName);
15
16
  addIntersectionObserver('.anim-show-parent img, .anim-show-parent > *:not(h1, h2, h3, h4, h5, h6)');
16
17
  addListImageIntersectionObserver('.post-list img');
18
+ monitorInputType();
17
19
 
18
20
  // @ts-ignore
19
21
  const f = site_features ?? {};
@@ -0,0 +1,53 @@
1
+ // @ts-check
2
+
3
+ let inputType = 'unknown';
4
+
5
+ /**
6
+ * Sets the user input mode as a class
7
+ */
8
+ function monitorInputType() {
9
+ window.addEventListener('keydown', event => {
10
+ const eventType = 'input-keyboard';
11
+ processInput(eventType);
12
+ });
13
+
14
+ window.addEventListener('mousemove', event => {
15
+ const eventType = 'input-mouse';
16
+ processInput(eventType);
17
+ });
18
+
19
+ window.addEventListener('touchstart', event => {
20
+ const eventType = 'input-touch';
21
+ processInput(eventType);
22
+ });
23
+ }
24
+
25
+ /**
26
+ * Processes the keyboard, mouse, or touch event
27
+ * @param {string} eventType
28
+ */
29
+ function processInput(eventType) {
30
+ if (inputType !== eventType) {
31
+ removeClass(inputType);
32
+ inputType = eventType;
33
+ addClass(inputType);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Removes an input type class from the body
39
+ * @param {string} inputType
40
+ */
41
+ function removeClass(inputType) {
42
+ document.body.classList.remove(inputType);
43
+ }
44
+
45
+ /**
46
+ * Adds an input type class to the body
47
+ * @param {string} inputType
48
+ */
49
+ function addClass(inputType) {
50
+ document.body.classList.add(inputType);
51
+ }
52
+
53
+ export { monitorInputType };
package/src/config.ts CHANGED
@@ -35,6 +35,9 @@ const SITE: Site = {
35
35
  figures: ['enlarge'],
36
36
  youTubeLinks: ['embed'],
37
37
  },
38
+ layouts: {
39
+ default: 'src/layouts/Default.astro'
40
+ },
38
41
  images: {
39
42
  contentSize: '(max-width: 860px) 100vw, 620px',
40
43
  listerSize: '(max-width: 860px) 90vw, 350px',
@@ -38,9 +38,9 @@ const authorImage = authorList?.image?.src
38
38
  <div class="author-info">
39
39
  <span class="author-list">{ _(Translations.post.written_by) }
40
40
  {authorList.mainAuthor &&
41
- <a href={ accelerator.urlFormatter.addSlashToAddress(authorList.mainAuthor.url) + '1/' } itemprop="author">{ authorList.mainAuthor.frontmatter.title }</a>
41
+ <span itemprop="author" itemscope itemtype="https://schema.org/Person"><a href={ accelerator.urlFormatter.addSlashToAddress(authorList.mainAuthor.url) + '1/' } itemprop="url"><span itemprop="name">{ authorList.mainAuthor.frontmatter.title }</span></a></span>
42
42
  }{authorList.contributors.map((writer) => (
43
- <span>, </span><a href={ accelerator.urlFormatter.addSlashToAddress(writer.url) + '1/' } itemprop="contributor">{ writer.frontmatter.title }</a>
43
+ <span>, </span><span itemprop="contributor" itemscope itemtype="https://schema.org/Person"><a href={ accelerator.urlFormatter.addSlashToAddress(writer.url) + '1/' } itemprop="url"><span itemprop="name">{ writer.frontmatter.title }</span></a></span>
44
44
  ))}
45
45
  <br /><time datetime={ frontmatter.pubDate.toString() } itemprop="datePublished">
46
46
  { accelerator.dateFormatter.formatDate(frontmatter.pubDate, lang) }
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import { Accelerator } from 'astro-accelerator-utils';
3
3
  import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
+ import { getImageInfo } from '@util/custom-markdown.mjs';
4
5
  import { SITE } from '@config';
5
6
  import Head from '@components/HtmlHead.astro';
6
7
  import Header from '@components/Header.astro';
@@ -25,6 +26,10 @@ const textDirection = frontmatter.dir ?? SITE.default.dir;
25
26
  // Logic
26
27
  const accelerator = new Accelerator(SITE);
27
28
 
29
+ const metaImage = frontmatter.bannerImage
30
+ ? getImageInfo(frontmatter.bannerImage.src, '', SITE.images.contentSize)
31
+ : null
32
+
28
33
  const title = await accelerator.markdown.getInlineHtmlFrom(frontmatter.title ?? SITE.title);
29
34
  const subtitle = frontmatter.subtitle
30
35
  ? await accelerator.markdown.getInlineHtmlFrom(frontmatter.subtitle)
@@ -55,6 +60,7 @@ const site_features = SITE.featureFlags;
55
60
  <Authors frontmatter={ frontmatter } lang={ lang } />
56
61
  <Taxonomy frontmatter={ frontmatter } lang={ lang } />
57
62
  <Related frontmatter={ frontmatter } headings={ headings } lang={ lang } />
63
+ {metaImage && <meta itemprop="image" content={ metaImage.src } />}
58
64
  </div>
59
65
  </article>
60
66
  </main>