astro-accelerator 0.0.8 → 0.0.10
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.
|
|
2
|
+
"version": "0.0.10",
|
|
3
3
|
"author": "Steve Fenton",
|
|
4
4
|
"name": "astro-accelerator",
|
|
5
5
|
"description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
|
|
@@ -36,18 +36,17 @@
|
|
|
36
36
|
"node": "*"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
|
-
".gitignore",
|
|
40
39
|
".npmrc",
|
|
41
40
|
"env.d.ts",
|
|
42
41
|
"tsconfig.json",
|
|
43
42
|
"astro.config.mjs",
|
|
44
43
|
"src/config.ts",
|
|
45
44
|
"src/pages/index.md",
|
|
46
|
-
"src/pages/authors/[author]/[page].astro",
|
|
47
|
-
"src/pages/articles/[page].astro",
|
|
45
|
+
"src/pages/authors/[[]author[]]/[[]page[]].astro",
|
|
46
|
+
"src/pages/articles/[[]page[]].astro",
|
|
48
47
|
"src/pages/articles/feed.xml.ts",
|
|
49
|
-
"src/pages/category/[category]/[page].astro",
|
|
50
|
-
"src/pages/tag/[tag]/[page].astro",
|
|
48
|
+
"src/pages/category/[[]category[]]/[[]page[]].astro",
|
|
49
|
+
"src/pages/tag/[[]tag[]]/[[]page[]].astro",
|
|
51
50
|
"src/pages/search.json.ts",
|
|
52
51
|
"src/pages/sitemap.xml.ts",
|
|
53
52
|
"src/pages/report/*",
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
---
|
|
2
|
+
// For listing all articles in this folder
|
|
3
|
+
import t from '@util/language.json';
|
|
4
|
+
import { Lang } from '@util/Languages.astro';
|
|
5
|
+
|
|
6
|
+
import type { Page, MarkdownInstance } from 'astro';
|
|
7
|
+
|
|
8
|
+
import { Frontmatter, SITE } from '@config';
|
|
9
|
+
import { getPageLinks } from '@util/PageLinks.astro';
|
|
10
|
+
import { isListable, sortByPubDateDesc } from '@util/PageTypeFilters.astro';
|
|
11
|
+
import { getItem, setItem } from '@util/Cache.astro';
|
|
12
|
+
|
|
13
|
+
import Default from '@layouts/Default.astro';
|
|
14
|
+
import ArticleList from '@components/ArticleList.astro';
|
|
15
|
+
import Paging from '@components/Paging.astro';
|
|
16
|
+
|
|
17
|
+
const lang = SITE.default.lang;
|
|
18
|
+
|
|
19
|
+
// Props
|
|
20
|
+
type Props = {
|
|
21
|
+
page: Page<MarkdownInstance<Record<string, any>>>;
|
|
22
|
+
headings: { depth: number; slug: string; text: string; }[];
|
|
23
|
+
pubDate: Date;
|
|
24
|
+
};
|
|
25
|
+
const { page, headings, pubDate } = Astro.props as Props;
|
|
26
|
+
|
|
27
|
+
const frontmatter: Frontmatter = {
|
|
28
|
+
layout: 'src/layouts/Default.astro',
|
|
29
|
+
title: 'Articles',
|
|
30
|
+
keywords: 'articles,astro,accelerator',
|
|
31
|
+
description: 'Astro Accelerator articles.',
|
|
32
|
+
pubDate: pubDate,
|
|
33
|
+
robots: 'noindex, follow'
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Language
|
|
37
|
+
const _ = Lang(lang);
|
|
38
|
+
|
|
39
|
+
// Logic
|
|
40
|
+
type CacheData = {
|
|
41
|
+
posts: MarkdownInstance<Record<string, any>>[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function getCacheData() {
|
|
45
|
+
const key = 'pages_articles_[page]';
|
|
46
|
+
|
|
47
|
+
let cacheData: CacheData = await getItem(key);
|
|
48
|
+
|
|
49
|
+
if (cacheData == null) {
|
|
50
|
+
// This uses a relative glob, so we only look in the current collection
|
|
51
|
+
const sourcePosts = await Astro.glob('./**/*.md');
|
|
52
|
+
|
|
53
|
+
cacheData = { posts: []};
|
|
54
|
+
|
|
55
|
+
cacheData.posts = sourcePosts
|
|
56
|
+
.filter(isListable)
|
|
57
|
+
.sort(sortByPubDateDesc);
|
|
58
|
+
|
|
59
|
+
await setItem(key, cacheData);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return cacheData;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function getStaticPaths({ paginate }: any) {
|
|
66
|
+
let data = await getCacheData();
|
|
67
|
+
return paginate(data.posts, {
|
|
68
|
+
props: { pubDate: data.posts[0].frontmatter.pubDate },
|
|
69
|
+
pageSize: SITE.pageSize
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Page Links
|
|
74
|
+
const pageLinks = getPageLinks(SITE.pageLinks, page.lastPage, page.currentPage, page.url.current);
|
|
75
|
+
---
|
|
76
|
+
<Default frontmatter={ frontmatter } headings={ headings }>
|
|
77
|
+
<h2>Page {page.currentPage}</h2>
|
|
78
|
+
<ArticleList lang={ lang } posts={ page.data } />
|
|
79
|
+
<Paging lang={ lang } page={ page } pageLinks={ pageLinks } />
|
|
80
|
+
</Default>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
// For listing all articles in this folder
|
|
3
|
+
import t from '@util/language.json';
|
|
4
|
+
import { Lang } from '@util/Languages.astro';
|
|
5
|
+
|
|
6
|
+
import type { Page, MarkdownInstance } from 'astro';
|
|
7
|
+
|
|
8
|
+
import { Frontmatter, SITE } from '@config';
|
|
9
|
+
import { getPageLinks } from '@util/PageLinks.astro';
|
|
10
|
+
import { isListable, sortByPubDateDesc } from '@util/PageTypeFilters.astro';
|
|
11
|
+
import { getItem, setItem } from '@util/Cache.astro';
|
|
12
|
+
|
|
13
|
+
import Default from '@layouts/Default.astro';
|
|
14
|
+
import ArticleList from '@components/ArticleList.astro';
|
|
15
|
+
import Paging from '@components/Paging.astro';
|
|
16
|
+
import { getAuthorInfo } from '@util/PageQueries.astro';
|
|
17
|
+
|
|
18
|
+
const lang = SITE.default.lang;
|
|
19
|
+
const currentUrl = new URL(Astro.request.url);
|
|
20
|
+
const slug = currentUrl.pathname.split('/')[2];
|
|
21
|
+
|
|
22
|
+
let authorInfo = await getAuthorInfo(slug);
|
|
23
|
+
|
|
24
|
+
const frontmatter = authorInfo.frontmatter as Frontmatter;
|
|
25
|
+
|
|
26
|
+
// Props
|
|
27
|
+
type Props = {
|
|
28
|
+
page: Page<MarkdownInstance<Record<string, any>>>;
|
|
29
|
+
headings: { depth: number; slug: string; text: string; }[];
|
|
30
|
+
pubDate: Date;
|
|
31
|
+
};
|
|
32
|
+
const { page, headings, pubDate } = Astro.props as Props;
|
|
33
|
+
|
|
34
|
+
frontmatter.pubDate = pubDate;
|
|
35
|
+
|
|
36
|
+
// Language
|
|
37
|
+
const _ = Lang(lang);
|
|
38
|
+
|
|
39
|
+
// Logic
|
|
40
|
+
type CacheData = {
|
|
41
|
+
posts: MarkdownInstance<Record<string, any>>[];
|
|
42
|
+
authors: string[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function getCacheData() {
|
|
46
|
+
const key = 'pages_authors_[author]_[page]';
|
|
47
|
+
|
|
48
|
+
let cacheData: CacheData = await getItem(key);
|
|
49
|
+
|
|
50
|
+
if (cacheData == null) {
|
|
51
|
+
const sourcePosts = await Astro.glob('../../**/*.md');
|
|
52
|
+
|
|
53
|
+
cacheData = { posts: [], authors: []};
|
|
54
|
+
|
|
55
|
+
cacheData.posts = sourcePosts
|
|
56
|
+
.filter(isListable)
|
|
57
|
+
.sort(sortByPubDateDesc);
|
|
58
|
+
|
|
59
|
+
cacheData.posts.forEach(p => {
|
|
60
|
+
const auths: string[] = p.frontmatter.authors ?? [];
|
|
61
|
+
if (auths.length == 0) {
|
|
62
|
+
console.log('No authors found', p.url);
|
|
63
|
+
}
|
|
64
|
+
auths.forEach(a => {
|
|
65
|
+
if (!cacheData.authors.includes(a)) {
|
|
66
|
+
cacheData.authors.push(a);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
await setItem(key, cacheData);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return cacheData;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export async function getStaticPaths({ paginate }: any) {
|
|
78
|
+
let data = await getCacheData();
|
|
79
|
+
|
|
80
|
+
return data.authors.map(a => {
|
|
81
|
+
const filtered = data.posts.filter(p => {
|
|
82
|
+
const auths: string[] = p.frontmatter.authors ?? [];
|
|
83
|
+
return auths.includes(a);
|
|
84
|
+
});
|
|
85
|
+
return paginate(filtered, {
|
|
86
|
+
params: { author: a.toLowerCase() },
|
|
87
|
+
props: { pubDate: filtered[0].frontmatter.pubDate },
|
|
88
|
+
pageSize: SITE.pageSize
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Page Links
|
|
94
|
+
const pageLinks = getPageLinks(SITE.pageLinks, page.lastPage, page.currentPage, page.url.current);
|
|
95
|
+
---
|
|
96
|
+
<Default frontmatter={ frontmatter } headings={ headings }>
|
|
97
|
+
<Fragment set:html={ authorInfo.content }></Fragment>
|
|
98
|
+
<h2>Page {page.currentPage}</h2>
|
|
99
|
+
<ArticleList lang={ lang } posts={ page.data } />
|
|
100
|
+
<Paging lang={ lang } page={ page } pageLinks={ pageLinks } />
|
|
101
|
+
</Default>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
// For listing by frontmatter.categories
|
|
3
|
+
import t from '@util/language.json';
|
|
4
|
+
import { Lang } from '@util/Languages.astro';
|
|
5
|
+
|
|
6
|
+
import type { Page, MarkdownInstance } from 'astro';
|
|
7
|
+
|
|
8
|
+
import { Frontmatter, SITE } from '@config';
|
|
9
|
+
import { getPageLinks } from '@util/PageLinks.astro';
|
|
10
|
+
import { isListable, sortByPubDateDesc } from '@util/PageTypeFilters.astro';
|
|
11
|
+
import { getItem, setItem } from '@util/Cache.astro';
|
|
12
|
+
|
|
13
|
+
import Default from '@layouts/Default.astro';
|
|
14
|
+
import ArticleList from '@components/ArticleList.astro';
|
|
15
|
+
import Paging from '@components/Paging.astro';
|
|
16
|
+
|
|
17
|
+
const lang = SITE.default.lang;
|
|
18
|
+
const currentUrl = new URL(Astro.request.url);
|
|
19
|
+
const slug = currentUrl.pathname.split('/')[3];
|
|
20
|
+
|
|
21
|
+
// Props
|
|
22
|
+
type Props = {
|
|
23
|
+
title: string;
|
|
24
|
+
page: Page<MarkdownInstance<Record<string, any>>>;
|
|
25
|
+
headings: { depth: number; slug: string; text: string; }[];
|
|
26
|
+
pubDate: Date;
|
|
27
|
+
};
|
|
28
|
+
const { title, page, headings, pubDate } = Astro.props as Props;
|
|
29
|
+
|
|
30
|
+
const frontmatter: Frontmatter = {
|
|
31
|
+
layout: 'src/layouts/Default.astro',
|
|
32
|
+
title: title,
|
|
33
|
+
keywords: `${slug},articles,astro,accelerator`,
|
|
34
|
+
description: `Astro Accelerator ${slug} articles.`,
|
|
35
|
+
pubDate: pubDate,
|
|
36
|
+
robots: 'noindex, follow'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Language
|
|
40
|
+
const _ = Lang(lang);
|
|
41
|
+
|
|
42
|
+
// Logic
|
|
43
|
+
type CacheData = {
|
|
44
|
+
posts: MarkdownInstance<Record<string, any>>[];
|
|
45
|
+
categories: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function getCacheData() {
|
|
49
|
+
const key = 'pages_articles_[category]_[page]';
|
|
50
|
+
|
|
51
|
+
let cacheData: CacheData = await getItem(key);
|
|
52
|
+
|
|
53
|
+
if (cacheData == null) {
|
|
54
|
+
// This uses a relative glob, so we only look in the current collection
|
|
55
|
+
const sourcePosts = await Astro.glob('../../**/*.md');
|
|
56
|
+
|
|
57
|
+
cacheData = { posts: [], categories: []};
|
|
58
|
+
|
|
59
|
+
cacheData.posts = sourcePosts
|
|
60
|
+
.filter(isListable)
|
|
61
|
+
.sort(sortByPubDateDesc);
|
|
62
|
+
|
|
63
|
+
cacheData.posts.forEach(p => {
|
|
64
|
+
const auths: string[] = p.frontmatter.categories ?? [];
|
|
65
|
+
if (auths.length == 0) {
|
|
66
|
+
console.log('No categories found', p.url);
|
|
67
|
+
}
|
|
68
|
+
auths.forEach(a => {
|
|
69
|
+
if (!cacheData.categories.includes(a)) {
|
|
70
|
+
cacheData.categories.push(a);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await setItem(key, cacheData);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return cacheData;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function getStaticPaths({ paginate }: any) {
|
|
82
|
+
let data = await getCacheData();
|
|
83
|
+
|
|
84
|
+
return data.categories.map(c => {
|
|
85
|
+
const filtered = data.posts.filter(p => {
|
|
86
|
+
const cats: string[] = p.frontmatter.categories ?? [];
|
|
87
|
+
return cats.includes(c);
|
|
88
|
+
});
|
|
89
|
+
return paginate(filtered, {
|
|
90
|
+
params: { category: c.toLowerCase().replace(/ /g, '-') },
|
|
91
|
+
props: { title: c, pubDate: filtered[0].frontmatter.pubDate },
|
|
92
|
+
pageSize: SITE.pageSize
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Page Links
|
|
98
|
+
const pageLinks = getPageLinks(SITE.pageLinks, page.lastPage, page.currentPage, page.url.current);
|
|
99
|
+
---
|
|
100
|
+
<Default frontmatter={ frontmatter } headings={ headings }>
|
|
101
|
+
<h2>Page {page.currentPage}</h2>
|
|
102
|
+
<ArticleList lang={ lang } posts={ page.data } />
|
|
103
|
+
<Paging lang={ lang } page={ page } pageLinks={ pageLinks } />
|
|
104
|
+
</Default>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
// For listing by frontmatter.tags
|
|
3
|
+
import t from '@util/language.json';
|
|
4
|
+
import { Lang } from '@util/Languages.astro';
|
|
5
|
+
|
|
6
|
+
import type { Page, MarkdownInstance } from 'astro';
|
|
7
|
+
|
|
8
|
+
import { Frontmatter, SITE } from '@config';
|
|
9
|
+
import { getPageLinks } from '@util/PageLinks.astro';
|
|
10
|
+
import { isListable, sortByPubDateDesc } from '@util/PageTypeFilters.astro';
|
|
11
|
+
import { getItem, setItem } from '@util/Cache.astro';
|
|
12
|
+
|
|
13
|
+
import Default from '@layouts/Default.astro';
|
|
14
|
+
import ArticleList from '@components/ArticleList.astro';
|
|
15
|
+
import Paging from '@components/Paging.astro';
|
|
16
|
+
|
|
17
|
+
const lang = SITE.default.lang;
|
|
18
|
+
const currentUrl = new URL(Astro.request.url);
|
|
19
|
+
const slug = currentUrl.pathname.split('/')[3];
|
|
20
|
+
|
|
21
|
+
// Props
|
|
22
|
+
type Props = {
|
|
23
|
+
title: string;
|
|
24
|
+
page: Page<MarkdownInstance<Record<string, any>>>;
|
|
25
|
+
headings: { depth: number; slug: string; text: string; }[];
|
|
26
|
+
pubDate: Date;
|
|
27
|
+
};
|
|
28
|
+
const { title, page, headings, pubDate } = Astro.props as Props;
|
|
29
|
+
|
|
30
|
+
const frontmatter: Frontmatter = {
|
|
31
|
+
layout: 'src/layouts/Default.astro',
|
|
32
|
+
title: title,
|
|
33
|
+
keywords: `${slug},articles,astro,accelerator`,
|
|
34
|
+
description: `Astro Accelerator ${slug} articles.`,
|
|
35
|
+
pubDate: pubDate,
|
|
36
|
+
robots: 'noindex, follow'
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Language
|
|
40
|
+
const _ = Lang(lang);
|
|
41
|
+
|
|
42
|
+
// Logic
|
|
43
|
+
type CacheData = {
|
|
44
|
+
posts: MarkdownInstance<Record<string, any>>[];
|
|
45
|
+
tags: string[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function getCacheData() {
|
|
49
|
+
const key = 'pages_articles_[tag]_[page]';
|
|
50
|
+
|
|
51
|
+
let cacheData: CacheData = await getItem(key);
|
|
52
|
+
|
|
53
|
+
if (cacheData == null) {
|
|
54
|
+
// This uses a relative glob, so we only look in the current collection
|
|
55
|
+
const sourcePosts = await Astro.glob('../../**/*.md');
|
|
56
|
+
|
|
57
|
+
cacheData = { posts: [], tags: []};
|
|
58
|
+
|
|
59
|
+
cacheData.posts = sourcePosts
|
|
60
|
+
.filter(isListable)
|
|
61
|
+
.sort(sortByPubDateDesc);
|
|
62
|
+
|
|
63
|
+
cacheData.posts.forEach(p => {
|
|
64
|
+
const auths: string[] = p.frontmatter.tags ?? [];
|
|
65
|
+
if (auths.length == 0) {
|
|
66
|
+
console.log('No categories found', p.url);
|
|
67
|
+
}
|
|
68
|
+
auths.forEach(a => {
|
|
69
|
+
if (!cacheData.tags.includes(a)) {
|
|
70
|
+
cacheData.tags.push(a);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await setItem(key, cacheData);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return cacheData;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export async function getStaticPaths({ paginate }: any) {
|
|
82
|
+
let data = await getCacheData();
|
|
83
|
+
|
|
84
|
+
return data.tags.map(t => {
|
|
85
|
+
const filtered = data.posts.filter(p => {
|
|
86
|
+
const tags: string[] = p.frontmatter.tags ?? [];
|
|
87
|
+
return tags.includes(t);
|
|
88
|
+
});
|
|
89
|
+
return paginate(filtered, {
|
|
90
|
+
params: { tag: t.toLowerCase().replace(/ /g, '-') },
|
|
91
|
+
props: { title: t, pubDate: filtered[0].frontmatter.pubDate },
|
|
92
|
+
pageSize: SITE.pageSize
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Page Links
|
|
98
|
+
const pageLinks = getPageLinks(SITE.pageLinks, page.lastPage, page.currentPage, page.url.current);
|
|
99
|
+
---
|
|
100
|
+
<Default frontmatter={ frontmatter } headings={ headings }>
|
|
101
|
+
<h2>Page {page.currentPage}</h2>
|
|
102
|
+
<ArticleList lang={ lang } posts={ page.data } />
|
|
103
|
+
<Paging lang={ lang } page={ page } pageLinks={ pageLinks } />
|
|
104
|
+
</Default>
|
package/.gitignore
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# build output
|
|
2
|
-
.cache/
|
|
3
|
-
dist/
|
|
4
|
-
|
|
5
|
-
# dependencies
|
|
6
|
-
node_modules/
|
|
7
|
-
|
|
8
|
-
# logs
|
|
9
|
-
npm-debug.log*
|
|
10
|
-
yarn-debug.log*
|
|
11
|
-
yarn-error.log*
|
|
12
|
-
pnpm-debug.log*
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
# environment variables
|
|
16
|
-
.env
|
|
17
|
-
.env.production
|
|
18
|
-
|
|
19
|
-
# macOS-specific files
|
|
20
|
-
.DS_Store
|
|
21
|
-
/test-results/
|
|
22
|
-
/playwright-report/
|
|
23
|
-
/playwright/.cache/
|