astro-accelerator 0.0.26 → 0.0.28
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 +2 -2
- package/public/css/main.css +9 -3
- package/src/config.ts +0 -4
- package/src/themes/accelerator/components/Authors.astro +10 -9
- package/src/themes/accelerator/components/AuthorsMini.astro +3 -3
- package/src/themes/accelerator/components/HtmlHead.astro +13 -11
- package/src/themes/accelerator/utilities/PageQueries.ts +2 -2
- package/src/themes/accelerator/utilities/Authors.ts +0 -45
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.28",
|
|
3
3
|
"author": "Steve Fenton",
|
|
4
4
|
"name": "astro-accelerator",
|
|
5
5
|
"description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@squoosh/lib": "^0.4.0",
|
|
28
28
|
"astro": "^1.6.6",
|
|
29
|
-
"astro-accelerator-utils": "^0.0.
|
|
29
|
+
"astro-accelerator-utils": "^0.0.26",
|
|
30
30
|
"hast-util-from-selector": "^2.0.0",
|
|
31
31
|
"remark-directive": "^2.0.1"
|
|
32
32
|
},
|
package/public/css/main.css
CHANGED
|
@@ -156,7 +156,7 @@ li::marker {
|
|
|
156
156
|
color: var(--fore-headings);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
-
.page-content ul, .page-content ol {
|
|
159
|
+
.page-content ul:not(.post-list), .page-content ol {
|
|
160
160
|
margin: var(--paragraph-margin) 0 var(--paragraph-margin) 1.2rem;
|
|
161
161
|
}
|
|
162
162
|
|
|
@@ -460,7 +460,7 @@ nav.site-nav h2 {
|
|
|
460
460
|
|
|
461
461
|
.content-group nav {
|
|
462
462
|
grid-area: menu;
|
|
463
|
-
width: 100
|
|
463
|
+
width: calc(100% - 40px);
|
|
464
464
|
}
|
|
465
465
|
|
|
466
466
|
.content-group main,
|
|
@@ -477,13 +477,19 @@ nav.site-nav h2 {
|
|
|
477
477
|
@media (max-width: 860px) {
|
|
478
478
|
.content-group {
|
|
479
479
|
grid-template-columns: auto;
|
|
480
|
-
grid-template-rows:
|
|
480
|
+
grid-template-rows: auto auto auto;
|
|
481
481
|
gap: var(--grid-gap);
|
|
482
482
|
grid-template-areas:
|
|
483
483
|
"top"
|
|
484
484
|
"content"
|
|
485
485
|
"menu";
|
|
486
486
|
}
|
|
487
|
+
|
|
488
|
+
.content-group article > .page-content {
|
|
489
|
+
margin: 0 20px;
|
|
490
|
+
width: calc(100% - 40px);
|
|
491
|
+
max-width: calc(100vw - 40px);
|
|
492
|
+
}
|
|
487
493
|
}
|
|
488
494
|
|
|
489
495
|
/* Table of Contents (TOC) */
|
package/src/config.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { Dates, Urls } from 'astro-accelerator-utils';
|
|
2
|
+
import { Dates, Urls, PostQueries } from 'astro-accelerator-utils';
|
|
3
3
|
import { SITE, Frontmatter } from '@config';
|
|
4
4
|
import { Translations, Lang } from '@util/Languages';
|
|
5
|
-
import { getAuthorList } from '@util/Authors';
|
|
6
5
|
import { getImageInfo } from '@util/custom-markdown.mjs';
|
|
6
|
+
import { fetchPages } from '@util/PageQueries';
|
|
7
7
|
|
|
8
8
|
// Properties
|
|
9
9
|
type Props = {
|
|
@@ -16,11 +16,12 @@ const { lang, frontmatter } = Astro.props as Props;
|
|
|
16
16
|
const _ = Lang(lang);
|
|
17
17
|
|
|
18
18
|
// Logic
|
|
19
|
-
const authorList = await
|
|
19
|
+
const authorList = await PostQueries.getAuthors(fetchPages, frontmatter);
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
const authorImage = authorList?.image?.src
|
|
23
|
-
|
|
21
|
+
// Get image info
|
|
22
|
+
const authorImage = authorList?.image?.src
|
|
23
|
+
? getImageInfo(authorList.image.src, 'author-image', SITE.images.authorSize)
|
|
24
|
+
: null;
|
|
24
25
|
---
|
|
25
26
|
{authorList.writers.length > 0 &&
|
|
26
27
|
<div class="post-meta">
|
|
@@ -34,9 +35,9 @@ const contributors = authorList.writers.slice(1);
|
|
|
34
35
|
}
|
|
35
36
|
<div class="author-info">
|
|
36
37
|
<span>{ _(Translations.post.written_by) }
|
|
37
|
-
{
|
|
38
|
-
<a href={ Urls.addSlashToAddress(
|
|
39
|
-
}{contributors.map((writer) => (
|
|
38
|
+
{authorList.mainAuthor &&
|
|
39
|
+
<a href={ Urls.addSlashToAddress(authorList.mainAuthor.url, SITE) + '1/' } itemprop="author">{ authorList.mainAuthor.frontmatter.title }</a>
|
|
40
|
+
}{authorList.contributors.map((writer) => (
|
|
40
41
|
<a href={ Urls.addSlashToAddress(writer.url, SITE) + '1/' } itemprop="contributor">{ writer.frontmatter.title }</a>
|
|
41
42
|
))}.
|
|
42
43
|
<br /><time datetime={ frontmatter.pubDate.toString() } itemprop="datePublished">
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { Dates, PostQueries } from 'astro-accelerator-utils';
|
|
2
3
|
import { SITE, Frontmatter } from '@config';
|
|
3
4
|
import { Translations, Lang } from '@util/Languages';;
|
|
4
|
-
import {
|
|
5
|
-
import { getAuthorList } from '@util/Authors';
|
|
5
|
+
import { fetchPages } from '@util/PageQueries';
|
|
6
6
|
|
|
7
7
|
// Properties
|
|
8
8
|
type Props = {
|
|
@@ -15,7 +15,7 @@ const { lang, frontmatter } = Astro.props as Props;
|
|
|
15
15
|
const _ = Lang(lang);
|
|
16
16
|
|
|
17
17
|
// Logic
|
|
18
|
-
const authorList = await
|
|
18
|
+
const authorList = await PostQueries.getAuthors(fetchPages, frontmatter);
|
|
19
19
|
---
|
|
20
20
|
{authorList.writers.length > 0 &&
|
|
21
21
|
<div class="post-meta">
|
|
@@ -17,15 +17,16 @@ const imageAlt = frontmatter.bannerImage?.alt ?? OPEN_GRAPH.image.alt;
|
|
|
17
17
|
const robots = frontmatter.robots ?? 'index, follow';
|
|
18
18
|
const canonicalImageSrc = new URL(imageSrc, Astro.site);
|
|
19
19
|
const canonicalURL = Urls.addSlashToUrl(new URL(Astro.url.pathname, Astro.site + SITE.subfolder));
|
|
20
|
-
const
|
|
20
|
+
const socialTitle = await getTextFrom(frontmatter.title);
|
|
21
|
+
const title = `${ socialTitle } | ${ SITE.title }`;
|
|
21
22
|
---
|
|
22
23
|
<head>
|
|
23
24
|
<meta charset="utf-8" />
|
|
24
25
|
<title>{ title }</title>
|
|
25
|
-
<meta name="robots" content={ 'max-image-preview:large, ' + robots }
|
|
26
|
-
<meta name="viewport" content="width=device-width, initial-scale=1"
|
|
27
|
-
<meta name="keywords" content={ frontmatter.keywords }
|
|
28
|
-
<meta name="description" content={ frontmatter.description }
|
|
26
|
+
<meta name="robots" content={ 'max-image-preview:large, ' + robots } />
|
|
27
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
28
|
+
<meta name="keywords" content={ frontmatter.keywords } />
|
|
29
|
+
<meta name="description" content={ frontmatter.description } />
|
|
29
30
|
<meta name="theme-color" content={ SITE.themeColor } />
|
|
30
31
|
<link rel="stylesheet" href={ SITE.subfolder + '/css/vars.css' } />
|
|
31
32
|
<link rel="stylesheet" href={ SITE.subfolder + '/css/main.css' } />
|
|
@@ -38,14 +39,15 @@ const title = await getTextFrom( frontmatter.title ? `${ frontmatter.title } | $
|
|
|
38
39
|
<link rel="apple-touch-icon" href={ SITE.subfolder + '/icons/apple-touch-icon.png' } />
|
|
39
40
|
<meta property="og:type" content="website" />
|
|
40
41
|
<meta property="og:url" content={ canonicalURL } />
|
|
41
|
-
<meta property="og:title" content={
|
|
42
|
+
<meta property="og:title" content={ socialTitle } />
|
|
42
43
|
<meta property="og:description" content={ frontmatter.description } />
|
|
43
44
|
<meta property="og:image" content={ canonicalImageSrc } />
|
|
44
45
|
<meta property="og:image:alt" content={ imageAlt } />
|
|
45
|
-
<meta name="twitter:card" content="summary_large_image"
|
|
46
|
-
<meta name="twitter:title" content={
|
|
47
|
-
<meta name="twitter:description" content={ frontmatter.description }
|
|
48
|
-
<meta name="twitter:image" content={ canonicalImageSrc }
|
|
49
|
-
<meta name="twitter:image:alt" content={ imageAlt }
|
|
46
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
47
|
+
<meta name="twitter:title" content={ socialTitle } />
|
|
48
|
+
<meta name="twitter:description" content={ frontmatter.description } />
|
|
49
|
+
<meta name="twitter:image" content={ canonicalImageSrc } />
|
|
50
|
+
<meta name="twitter:image:alt" content={ imageAlt } />
|
|
51
|
+
<meta name="view-transition" content="same-origin" />
|
|
50
52
|
<Fragment set:html={ HEADER_SCRIPTS }></Fragment>
|
|
51
53
|
</head>
|
|
@@ -2,8 +2,8 @@ import type { MarkdownInstance } from "astro";
|
|
|
2
2
|
import { SITE } from '@config';
|
|
3
3
|
import { Cache, PostQueries, PostFiltering } from 'astro-accelerator-utils';
|
|
4
4
|
|
|
5
|
-
export function fetchPages(): Record<string, any
|
|
6
|
-
return import.meta.glob("../../../pages/**/*.md", { eager: true });
|
|
5
|
+
export function fetchPages(): MarkdownInstance<Record<string, any>>[] {
|
|
6
|
+
return import.meta.glob<any>("../../../pages/**/*.md", { eager: true }) as MarkdownInstance<Record<string, any>>[];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export type PagePredicate = (value: MarkdownInstance<Record<string, any>>, index: number, array: MarkdownInstance<Record<string, any>>[]) => boolean;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { MarkdownInstance } from 'astro';
|
|
2
|
-
import { PostQueries, PostFiltering } from "astro-accelerator-utils";
|
|
3
|
-
import type { Frontmatter } from '@config';
|
|
4
|
-
import { fetchPages } from "@util/PageQueries";
|
|
5
|
-
|
|
6
|
-
type BannerImage = { src: string; alt: string } | null;
|
|
7
|
-
type AuthorList = {
|
|
8
|
-
image: BannerImage | null;
|
|
9
|
-
writers: MarkdownInstance<Record<string, any>>[];
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export async function getAuthors () {
|
|
13
|
-
const authors = await PostQueries.getPages(fetchPages, PostFiltering.isAuthor);
|
|
14
|
-
return authors;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function getAuthorList (frontmatter: Frontmatter) {
|
|
18
|
-
const authors = await getAuthors();
|
|
19
|
-
|
|
20
|
-
const result: AuthorList = {
|
|
21
|
-
image: null,
|
|
22
|
-
writers: [],
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
(frontmatter.authors ?? []).forEach((a) => {
|
|
26
|
-
const matches = authors.filter((x) => x.frontmatter.id == a);
|
|
27
|
-
|
|
28
|
-
if (matches.length == 0) {
|
|
29
|
-
console.warn("Unknown author", a);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (matches.length > 1) {
|
|
33
|
-
console.warn("Multiple authors with id", a);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (matches.length == 1) {
|
|
37
|
-
result.writers.push(matches[0]);
|
|
38
|
-
if (result.image == null) {
|
|
39
|
-
result.image = matches[0].frontmatter.bannerImage;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return result;
|
|
45
|
-
}
|