astro-accelerator 5.10.29 → 5.10.32
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": "5.10.
|
|
2
|
+
"version": "5.10.32",
|
|
3
3
|
"author": "Steve Fenton",
|
|
4
4
|
"name": "astro-accelerator",
|
|
5
5
|
"description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@astrojs/mdx": "^4.3.13",
|
|
38
38
|
"@img/sharp-linux-x64": "^0.34.5",
|
|
39
|
-
"astro": "^5.16.
|
|
40
|
-
"astro-accelerator-utils": "^0.3.
|
|
41
|
-
"cspell": "^9.
|
|
39
|
+
"astro": "^5.16.11",
|
|
40
|
+
"astro-accelerator-utils": "^0.3.67",
|
|
41
|
+
"cspell": "^9.6.0",
|
|
42
42
|
"csv": "^6.4.1",
|
|
43
43
|
"glob": "^13.0.0",
|
|
44
44
|
"hast-util-from-selector": "^3.0.1",
|
|
@@ -55,7 +55,7 @@ export async function getData() {
|
|
|
55
55
|
const data: CategoryData = { posts: [], categories: []};
|
|
56
56
|
|
|
57
57
|
data.posts = sourcePosts
|
|
58
|
-
.filter(PostFiltering.
|
|
58
|
+
.filter(PostFiltering.forTaxonomy)
|
|
59
59
|
.sort(PostOrdering.sortByPubDateDesc);
|
|
60
60
|
|
|
61
61
|
data.posts.forEach(p => {
|
package/src/pages/search.json.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Accelerator, PostFiltering } from 'astro-accelerator-utils';
|
|
6
6
|
import type { MarkdownInstance } from 'astro';
|
|
7
7
|
import { SITE } from '@config';
|
|
8
|
-
import {
|
|
8
|
+
import { convert } from 'html-to-text';
|
|
9
9
|
import keywordExtractor from 'keyword-extractor';
|
|
10
10
|
|
|
11
11
|
const getData = async () => {
|
|
@@ -2,23 +2,27 @@
|
|
|
2
2
|
// warning: This file is overwritten by Astro Accelerator
|
|
3
3
|
|
|
4
4
|
// For listing by frontmatter.tags
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
5
|
+
import {
|
|
6
|
+
PostFiltering,
|
|
7
|
+
PostOrdering,
|
|
8
|
+
Accelerator,
|
|
9
|
+
} from "astro-accelerator-utils";
|
|
10
|
+
import type { Frontmatter } from "astro-accelerator-utils/types/Frontmatter";
|
|
11
|
+
import type { MarkdownInstance } from "astro-accelerator-utils/types/Astro";
|
|
12
|
+
import type { Page } from "astro";
|
|
13
|
+
import { Translations, Lang } from "@util/Languages";
|
|
14
|
+
import { SITE } from "@config";
|
|
15
|
+
import Default from "src/layouts/Default.astro";
|
|
16
|
+
import ArticleList from "@components/ArticleList.astro";
|
|
17
|
+
import PagingLinks from "@components/PagingLinks.astro";
|
|
14
18
|
|
|
15
19
|
const accelerator = new Accelerator(SITE);
|
|
16
|
-
const stats = new accelerator.statistics(
|
|
20
|
+
const stats = new accelerator.statistics("pages/authors/[tag]/[page].astro");
|
|
17
21
|
stats.start();
|
|
18
22
|
|
|
19
23
|
const lang = SITE.default.lang;
|
|
20
24
|
const currentUrl = new URL(Astro.request.url);
|
|
21
|
-
const slug = currentUrl.pathname.split(
|
|
25
|
+
const slug = currentUrl.pathname.split("/")[3];
|
|
22
26
|
|
|
23
27
|
// Language
|
|
24
28
|
const _ = Lang(lang);
|
|
@@ -27,43 +31,45 @@ const _ = Lang(lang);
|
|
|
27
31
|
type Props = {
|
|
28
32
|
title: string;
|
|
29
33
|
page: Page<MarkdownInstance>;
|
|
30
|
-
headings: { depth: number; slug: string; text: string
|
|
34
|
+
headings: { depth: number; slug: string; text: string }[];
|
|
31
35
|
pubDate: Date;
|
|
32
36
|
};
|
|
33
37
|
const { title, page, headings, pubDate } = Astro.props satisfies Props;
|
|
34
38
|
|
|
35
39
|
// Enhance the title
|
|
36
|
-
const pageTitle = `${_(Translations.articles.archive_title).replace(
|
|
40
|
+
const pageTitle = `${_(Translations.articles.archive_title).replace("{name}", title)} - ${_(Translations.articles.page_title).replace("{n}", page.currentPage.toString())}`;
|
|
37
41
|
|
|
38
42
|
const frontmatter: Frontmatter = {
|
|
39
|
-
layout:
|
|
43
|
+
layout: "src/layouts/Default.astro",
|
|
40
44
|
title: pageTitle,
|
|
41
45
|
keywords: `${slug},articles`,
|
|
42
46
|
description: `${SITE.title} ${slug} articles.`,
|
|
43
|
-
pubDate: pubDate
|
|
47
|
+
pubDate: pubDate,
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
// Logic
|
|
47
51
|
type CacheData = {
|
|
48
52
|
posts: MarkdownInstance[];
|
|
49
53
|
tags: string[];
|
|
50
|
-
}
|
|
54
|
+
};
|
|
51
55
|
|
|
52
56
|
export async function getData() {
|
|
53
|
-
const sourcePosts = Object.values(
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
const sourcePosts = Object.values(
|
|
58
|
+
import.meta.glob("../../**/*.md*", { eager: true })
|
|
59
|
+
) satisfies MarkdownInstance[];
|
|
60
|
+
|
|
61
|
+
const data: CacheData = { posts: [], tags: [] };
|
|
56
62
|
|
|
57
63
|
data.posts = sourcePosts
|
|
58
|
-
.filter(PostFiltering.
|
|
64
|
+
.filter(PostFiltering.forTaxonomy)
|
|
59
65
|
.sort(PostOrdering.sortByPubDateDesc);
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
data.posts.forEach((p) => {
|
|
62
68
|
const auths: string[] = p.frontmatter.tags ?? [];
|
|
63
69
|
if (auths.length == 0) {
|
|
64
|
-
console.log(
|
|
70
|
+
console.log("No categories found", p.url);
|
|
65
71
|
}
|
|
66
|
-
auths.forEach(a => {
|
|
72
|
+
auths.forEach((a) => {
|
|
67
73
|
if (!data.tags.includes(a)) {
|
|
68
74
|
data.tags.push(a);
|
|
69
75
|
}
|
|
@@ -76,30 +82,37 @@ export async function getData() {
|
|
|
76
82
|
export async function getStaticPaths({ paginate }: any) {
|
|
77
83
|
let data = await getData();
|
|
78
84
|
|
|
79
|
-
return data.tags
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
85
|
+
return data.tags
|
|
86
|
+
.map((t) => {
|
|
87
|
+
const filtered = data.posts.filter((p) => {
|
|
88
|
+
const tags: string[] = p.frontmatter.tags ?? [];
|
|
89
|
+
return tags.includes(t);
|
|
90
|
+
});
|
|
91
|
+
return paginate(filtered, {
|
|
92
|
+
params: { tag: t.toLowerCase().replace(/ /g, "-") },
|
|
93
|
+
props: { title: t, pubDate: filtered[0].frontmatter.pubDate },
|
|
94
|
+
pageSize: SITE.pageSize,
|
|
95
|
+
});
|
|
96
|
+
})
|
|
97
|
+
.flat();
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
// Page Links
|
|
93
|
-
const pageLinks = accelerator.paging.links(
|
|
101
|
+
const pageLinks = accelerator.paging.links(
|
|
102
|
+
SITE.pageLinks,
|
|
103
|
+
page.lastPage,
|
|
104
|
+
page.currentPage,
|
|
105
|
+
page.url.current
|
|
106
|
+
);
|
|
94
107
|
|
|
95
108
|
// Breadcrumbs
|
|
96
|
-
const breadcrumbs: { url: string; title: string; ariaCurrent?: string
|
|
109
|
+
const breadcrumbs: { url: string; title: string; ariaCurrent?: string }[] = [];
|
|
97
110
|
|
|
98
111
|
if (page.url.current == pageLinks[0].url) {
|
|
99
112
|
breadcrumbs.push({
|
|
100
113
|
url: pageLinks[0].url as string,
|
|
101
114
|
title: title,
|
|
102
|
-
ariaCurrent:
|
|
115
|
+
ariaCurrent: "page",
|
|
103
116
|
});
|
|
104
117
|
}
|
|
105
118
|
|
|
@@ -111,14 +124,21 @@ if (page.url.current != pageLinks[0].url) {
|
|
|
111
124
|
|
|
112
125
|
breadcrumbs.push({
|
|
113
126
|
url: page.url.current,
|
|
114
|
-
title: _(Translations.articles.page_title).replace(
|
|
115
|
-
|
|
127
|
+
title: _(Translations.articles.page_title).replace(
|
|
128
|
+
"{n}",
|
|
129
|
+
page.currentPage.toString()
|
|
130
|
+
),
|
|
131
|
+
ariaCurrent: "page",
|
|
116
132
|
});
|
|
117
133
|
}
|
|
118
134
|
|
|
119
135
|
stats.stop();
|
|
120
136
|
---
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
137
|
+
|
|
138
|
+
<Default
|
|
139
|
+
frontmatter={frontmatter}
|
|
140
|
+
headings={headings}
|
|
141
|
+
breadcrumbs={breadcrumbs}>
|
|
142
|
+
<ArticleList lang={lang} posts={page.data} />
|
|
143
|
+
<PagingLinks lang={lang} page={page} pageLinks={pageLinks} />
|
|
144
|
+
</Default>
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
---
|
|
2
2
|
// warning: This file is overwritten by Astro Accelerator
|
|
3
3
|
|
|
4
|
-
import { Accelerator } from
|
|
5
|
-
import type { Frontmatter } from
|
|
6
|
-
import type { MarkdownInstance } from
|
|
7
|
-
import { SITE } from
|
|
8
|
-
import { getImageInfo } from
|
|
9
|
-
import AuthorsMini from
|
|
4
|
+
import { Accelerator, PostFiltering } from "astro-accelerator-utils";
|
|
5
|
+
import type { Frontmatter } from "astro-accelerator-utils/types/Frontmatter";
|
|
6
|
+
import type { MarkdownInstance } from "astro";
|
|
7
|
+
import { SITE } from "@config";
|
|
8
|
+
import { getImageInfo } from "@util/custom-markdown.mjs";
|
|
9
|
+
import AuthorsMini from "@components/AuthorsMini.astro";
|
|
10
10
|
|
|
11
11
|
const accelerator = new Accelerator(SITE);
|
|
12
|
-
const stats = new accelerator.statistics(
|
|
12
|
+
const stats = new accelerator.statistics(
|
|
13
|
+
"accelerator/components/ArticleList.astro"
|
|
14
|
+
);
|
|
13
15
|
stats.start();
|
|
14
16
|
|
|
15
17
|
// Properties
|
|
16
18
|
type Props = {
|
|
17
19
|
lang: string;
|
|
18
|
-
posts: MarkdownInstance<Record<string, any>>[]
|
|
20
|
+
posts: MarkdownInstance<Record<string, any>>[];
|
|
19
21
|
};
|
|
20
22
|
const { lang, posts } = Astro.props satisfies Props;
|
|
21
23
|
|
|
@@ -28,7 +30,7 @@ type ImageInfo = {
|
|
|
28
30
|
metadata: {
|
|
29
31
|
width: number;
|
|
30
32
|
height: number;
|
|
31
|
-
}
|
|
33
|
+
};
|
|
32
34
|
};
|
|
33
35
|
|
|
34
36
|
type Article = {
|
|
@@ -40,53 +42,63 @@ type Article = {
|
|
|
40
42
|
|
|
41
43
|
const articles: Article[] = [];
|
|
42
44
|
|
|
43
|
-
for (let p of posts) {
|
|
45
|
+
for (let p of posts.filter(PostFiltering.isListable)) {
|
|
44
46
|
const item = {
|
|
45
|
-
url: p.url ??
|
|
47
|
+
url: p.url ?? "",
|
|
46
48
|
title: await accelerator.markdown.getTextFrom(p.frontmatter?.title),
|
|
47
49
|
frontmatter: p.frontmatter,
|
|
48
50
|
img: p.frontmatter.bannerImage
|
|
49
|
-
? getImageInfo(p.frontmatter.bannerImage.src,
|
|
50
|
-
: null
|
|
51
|
+
? getImageInfo(p.frontmatter.bannerImage.src, "", SITE.images.listerSize)
|
|
52
|
+
: null,
|
|
51
53
|
};
|
|
52
54
|
|
|
53
|
-
articles.push(item)
|
|
55
|
+
articles.push(item);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
let articleIndex = 0;
|
|
57
59
|
function getLoadingAttribute() {
|
|
58
60
|
articleIndex++;
|
|
59
|
-
return articleIndex > 2
|
|
60
|
-
? 'lazy'
|
|
61
|
-
: 'eager';
|
|
61
|
+
return articleIndex > 2 ? "lazy" : "eager";
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
stats.stop();
|
|
65
65
|
---
|
|
66
|
+
|
|
66
67
|
<ul class="post-list anim-show-parent">
|
|
67
|
-
{
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
</
|
|
68
|
+
{
|
|
69
|
+
articles.map((post) => (
|
|
70
|
+
<li
|
|
71
|
+
class="list-item"
|
|
72
|
+
data-destination={accelerator.urlFormatter.formatAddress(post.url)}
|
|
73
|
+
data-image={(post.frontmatter.bannerImage?.src.length > 0).toString()}>
|
|
74
|
+
<article>
|
|
75
|
+
<div class="list-item-image">
|
|
76
|
+
{post.img && (
|
|
77
|
+
<img
|
|
78
|
+
srcset={post.img.srcset}
|
|
79
|
+
sizes={post.img.sizes}
|
|
80
|
+
src={post.img.src}
|
|
81
|
+
alt={post.frontmatter.bannerImage.alt}
|
|
82
|
+
class={post.img.class}
|
|
83
|
+
width={post.img.metadata?.width}
|
|
84
|
+
height={post.img.metadata?.height}
|
|
85
|
+
loading={getLoadingAttribute()}
|
|
86
|
+
/>
|
|
87
|
+
)}
|
|
88
|
+
</div>
|
|
89
|
+
<div class="list-item-content">
|
|
90
|
+
<h2>
|
|
91
|
+
<a href={accelerator.urlFormatter.formatAddress(post.url)}>
|
|
92
|
+
{post.title}
|
|
93
|
+
</a>
|
|
94
|
+
</h2>
|
|
95
|
+
<AuthorsMini
|
|
96
|
+
lang={lang}
|
|
97
|
+
frontmatter={post.frontmatter satisfies Frontmatter}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
</article>
|
|
101
|
+
</li>
|
|
102
|
+
))
|
|
103
|
+
}
|
|
104
|
+
</ul>
|