astro-accelerator 0.0.24 → 0.0.25
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 -1
- package/src/config.ts +3 -3
- package/src/layouts/Default.astro +0 -1
- package/src/pages/articles/[page].astro +1 -2
- package/src/pages/articles/feed.xml.ts +5 -3
- package/src/pages/authors/[author]/[page].astro +2 -3
- package/src/pages/category/[category]/[page].astro +2 -3
- package/src/pages/report/missing-banner.astro +3 -3
- package/src/pages/report/missing-meta.astro +3 -3
- package/src/pages/report/missing-pubdate.astro +3 -2
- package/src/pages/report/oldest-content.astro +3 -3
- package/src/pages/search.json.ts +5 -4
- package/src/pages/sitemap.xml.ts +2 -3
- package/src/pages/tag/[tag]/[page].astro +2 -3
- package/src/themes/accelerator/components/ArticleList.astro +30 -9
- package/src/themes/accelerator/components/Authors.astro +3 -4
- package/src/themes/accelerator/components/AuthorsMini.astro +1 -1
- package/src/themes/accelerator/components/Breadcrumbs.astro +3 -3
- package/src/themes/accelerator/components/Header.astro +4 -5
- package/src/themes/accelerator/components/HtmlHead.astro +1 -1
- package/src/themes/accelerator/components/NavigationItem.astro +3 -2
- package/src/themes/accelerator/components/Paging.astro +5 -4
- package/src/themes/accelerator/components/Related.astro +6 -9
- package/src/themes/accelerator/layouts/Author.astro +3 -2
- package/src/themes/accelerator/layouts/Default.astro +6 -2
- package/src/themes/accelerator/utilities/Authors.ts +3 -3
- package/src/themes/accelerator/utilities/Breadcrumbs.ts +3 -2
- package/src/themes/accelerator/utilities/Footer.ts +1 -1
- package/src/themes/accelerator/utilities/NavPage.ts +3 -2
- package/src/themes/accelerator/utilities/Navigation.ts +3 -4
- package/src/themes/accelerator/utilities/PageQueries.ts +21 -18
- package/src/themes/accelerator/utilities/Taxonomy.ts +5 -6
- package/src/themes/accelerator/utilities/Cache.ts +0 -40
- package/src/themes/accelerator/utilities/DateFormat.ts +0 -23
- package/src/themes/accelerator/utilities/PageTypeFilters.ts +0 -67
- package/src/themes/accelerator/utilities/Url.ts +0 -19
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.0.
|
|
2
|
+
"version": "0.0.25",
|
|
3
3
|
"author": "Steve Fenton",
|
|
4
4
|
"name": "astro-accelerator",
|
|
5
5
|
"description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@squoosh/lib": "^0.4.0",
|
|
28
28
|
"astro": "^1.6.6",
|
|
29
|
+
"astro-accelerator-utils": "^0.0.18",
|
|
29
30
|
"hast-util-from-selector": "^2.0.0",
|
|
30
31
|
"remark-directive": "^2.0.1"
|
|
31
32
|
},
|
package/src/config.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Site } from 'astro-accelerator-utils';
|
|
2
|
+
|
|
3
|
+
export const SITE: Site = {
|
|
2
4
|
url: 'https://astro.stevefenton.co.uk',
|
|
3
5
|
subfolder: '',
|
|
4
6
|
feedUrl: '/articles/feed.xml',
|
|
@@ -62,8 +64,6 @@ type Mapped<T> = {
|
|
|
62
64
|
[P in keyof T]?: any
|
|
63
65
|
}
|
|
64
66
|
|
|
65
|
-
export type Site = Mapped<typeof SITE>;
|
|
66
|
-
|
|
67
67
|
export type Frontmatter = {
|
|
68
68
|
layout: string;
|
|
69
69
|
title: string;
|
|
@@ -6,8 +6,7 @@ import { Translations, Lang } from '@util/Languages';
|
|
|
6
6
|
import type { Page, MarkdownInstance } from 'astro';
|
|
7
7
|
import { Frontmatter, SITE } from '@config';
|
|
8
8
|
import { getPageLinks } from '@util/PageLinks';
|
|
9
|
-
import { isListable, sortByPubDateDesc } from '
|
|
10
|
-
import { getItem, setItem } from '@util/Cache';
|
|
9
|
+
import { isListable, sortByPubDateDesc, getItem, setItem } from 'astro-accelerator-utils';
|
|
11
10
|
import Default from 'src/layouts/Default.astro';
|
|
12
11
|
import ArticleList from '@components/ArticleList.astro';
|
|
13
12
|
import Paging from '@components/Paging.astro';
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
// Generates an ATOM feed of recent posts
|
|
4
4
|
import { SITE } from '@config';
|
|
5
|
-
import { addSlashToAddress } from '
|
|
6
|
-
import {
|
|
5
|
+
import { addSlashToAddress, isListable } from 'astro-accelerator-utils';
|
|
6
|
+
import { getTextFrom } from '@util/Markdown';
|
|
7
7
|
|
|
8
8
|
async function getData() {
|
|
9
9
|
//@ts-ignore
|
|
@@ -15,6 +15,8 @@ async function getData() {
|
|
|
15
15
|
const article: any = await allArticles[path]();
|
|
16
16
|
|
|
17
17
|
if (isListable(article)) {
|
|
18
|
+
article.frontmatter.title = await getTextFrom(article.frontmatter.title ?? '');
|
|
19
|
+
|
|
18
20
|
articles.push({
|
|
19
21
|
url: article.url,
|
|
20
22
|
frontmatter: article.frontmatter
|
|
@@ -31,7 +33,7 @@ async function getData() {
|
|
|
31
33
|
<entry>
|
|
32
34
|
<title>${a.frontmatter.title ?? ''}</title>
|
|
33
35
|
<link href="${ SITE.url + a.url }" />
|
|
34
|
-
<id>${ SITE.url + addSlashToAddress(a.url) }</id>
|
|
36
|
+
<id>${ SITE.url + addSlashToAddress(a.url, SITE) }</id>
|
|
35
37
|
<published>${ a.frontmatter.pubDate }</published>
|
|
36
38
|
<updated>${ a.frontmatter.pubDate ?? a.frontmatter.pubDate }</updated>
|
|
37
39
|
<summary>${ a.frontmatter.description ?? '' }</summary>
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
// For listing all articles in this folder
|
|
5
5
|
import { Translations, Lang } from '@util/Languages';
|
|
6
6
|
import type { Page, MarkdownInstance } from 'astro';
|
|
7
|
-
import {
|
|
7
|
+
import { SITE, Frontmatter } from '@config';
|
|
8
8
|
import { getPageLinks } from '@util/PageLinks';
|
|
9
|
-
import { isListable, sortByPubDateDesc } from '
|
|
10
|
-
import { getItem, setItem } from '@util/Cache';
|
|
9
|
+
import { isListable, sortByPubDateDesc, getItem, setItem } from 'astro-accelerator-utils';
|
|
11
10
|
import { getAuthorInfo } from '@util/PageQueries';
|
|
12
11
|
import Default from '@layouts/Default.astro';
|
|
13
12
|
import ArticleList from '@components/ArticleList.astro';
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
// For listing by frontmatter.categories
|
|
5
5
|
import { Translations, Lang } from '@util/Languages';
|
|
6
6
|
import type { Page, MarkdownInstance } from 'astro';
|
|
7
|
-
import {
|
|
7
|
+
import { SITE, Frontmatter } from '@config';
|
|
8
8
|
import { getPageLinks } from '@util/PageLinks';
|
|
9
|
-
import { isListable, sortByPubDateDesc } from '
|
|
10
|
-
import { getItem, setItem } from '@util/Cache';
|
|
9
|
+
import { isListable, sortByPubDateDesc, getItem, setItem } from 'astro-accelerator-utils';
|
|
11
10
|
import Default from 'src/layouts/Default.astro';
|
|
12
11
|
import ArticleList from '@components/ArticleList.astro';
|
|
13
12
|
import Paging from '@components/Paging.astro';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { sortByPubDateDesc } from '
|
|
3
|
-
import {
|
|
2
|
+
import { sortByPubDateDesc, getPages } from 'astro-accelerator-utils';
|
|
3
|
+
import { fetchPages } from '@util/PageQueries';
|
|
4
4
|
|
|
5
5
|
// Logic
|
|
6
|
-
const allPages = await getPages();
|
|
6
|
+
const allPages = await getPages(fetchPages);
|
|
7
7
|
const missingBanner = allPages.filter(p => p.frontmatter.bannerImage == null && p.frontmatter.layout != 'src/layouts/Redirect.astro');
|
|
8
8
|
const pageCount = missingBanner.length;
|
|
9
9
|
const pages = missingBanner.sort(sortByPubDateDesc).slice(0, Math.min(50, pageCount));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { sortByPubDateDesc } from '
|
|
3
|
-
import {
|
|
2
|
+
import { sortByPubDateDesc, getPages } from 'astro-accelerator-utils';
|
|
3
|
+
import { fetchPages } from '@util/PageQueries';
|
|
4
4
|
|
|
5
5
|
// Logic
|
|
6
|
-
const allPages = await getPages();
|
|
6
|
+
const allPages = await getPages(fetchPages);
|
|
7
7
|
const missingMeta = allPages.filter(p => (p.frontmatter.keywords == null || p.frontmatter.description == null) && p.frontmatter.layout != 'src/layouts/Redirect.astro');
|
|
8
8
|
const pageCount = missingMeta.length;
|
|
9
9
|
const pages = missingMeta.sort(sortByPubDateDesc).slice(0, Math.min(50, pageCount));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { getPages } from '
|
|
2
|
+
import { getPages } from 'astro-accelerator-utils';
|
|
3
|
+
import { fetchPages } from '@util/PageQueries';
|
|
3
4
|
|
|
4
5
|
// Logic
|
|
5
|
-
const allPages = await getPages();
|
|
6
|
+
const allPages = await getPages(fetchPages);
|
|
6
7
|
const missingMeta = allPages.filter(p => (p.frontmatter.pubDate == null && p.frontmatter.layout != 'src/layouts/Redirect.astro'));
|
|
7
8
|
const pageCount = missingMeta.length;
|
|
8
9
|
const pages = missingMeta.slice(0, Math.min(50, pageCount));
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { sortByModDate } from '
|
|
3
|
-
import {
|
|
2
|
+
import { sortByModDate, getPages } from 'astro-accelerator-utils';
|
|
3
|
+
import { fetchPages } from '@util/PageQueries';
|
|
4
4
|
|
|
5
5
|
// Logic
|
|
6
|
-
const allPages = await getPages();
|
|
6
|
+
const allPages = await getPages(fetchPages);
|
|
7
7
|
const pageCount = allPages.length;
|
|
8
8
|
const pages = allPages.sort(sortByModDate).slice(0, Math.min(50, pageCount));
|
|
9
9
|
---
|
package/src/pages/search.json.ts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type { MarkdownInstance } from 'astro';
|
|
4
4
|
import { SITE } from '@config';
|
|
5
|
-
import { showInSearch } from '
|
|
6
|
-
import {
|
|
5
|
+
import { addSlashToAddress, showInSearch } from 'astro-accelerator-utils';
|
|
6
|
+
import { getTextFrom } from '@util/Markdown';
|
|
7
7
|
|
|
8
8
|
const getData = async () => {
|
|
9
9
|
//@ts-ignore
|
|
@@ -24,15 +24,16 @@ const getData = async () => {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
const headings = await page.getHeadings();
|
|
27
|
+
const title = await getTextFrom(page.frontmatter.title ?? '');
|
|
27
28
|
|
|
28
29
|
items.push({
|
|
29
|
-
title:
|
|
30
|
+
title: title,
|
|
30
31
|
headings: headings.map(h => {
|
|
31
32
|
return {text: h.text, slug: h.slug }
|
|
32
33
|
}),
|
|
33
34
|
description: page.frontmatter.description ?? '',
|
|
34
35
|
tags: page.frontmatter.tags ?? [],
|
|
35
|
-
url: SITE.url + addSlashToAddress(url),
|
|
36
|
+
url: SITE.url + addSlashToAddress(url, SITE),
|
|
36
37
|
date: page.frontmatter.pubDate ?? ''
|
|
37
38
|
});
|
|
38
39
|
}
|
package/src/pages/sitemap.xml.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// Generates an ATOM feed of recent posts
|
|
4
4
|
import { SITE } from '@config';
|
|
5
|
-
import { showInSitemap } from '
|
|
6
|
-
import { addSlashToAddress } from '@util/Url';
|
|
5
|
+
import { addSlashToAddress, showInSitemap } from 'astro-accelerator-utils';
|
|
7
6
|
|
|
8
7
|
async function getData() {
|
|
9
8
|
//@ts-ignore
|
|
@@ -18,7 +17,7 @@ async function getData() {
|
|
|
18
17
|
if (addToSitemap) {
|
|
19
18
|
pages.push(`
|
|
20
19
|
<url>
|
|
21
|
-
<loc>${ SITE.url + addSlashToAddress(article.url) }</loc>
|
|
20
|
+
<loc>${ SITE.url + addSlashToAddress(article.url, SITE) }</loc>
|
|
22
21
|
<lastmod>${ article.frontmatter.pubDate }</lastmod>
|
|
23
22
|
</url>`);
|
|
24
23
|
}
|
|
@@ -4,10 +4,9 @@
|
|
|
4
4
|
// For listing by frontmatter.tags
|
|
5
5
|
import { Translations, Lang } from '@util/Languages';
|
|
6
6
|
import type { Page, MarkdownInstance } from 'astro';
|
|
7
|
-
import {
|
|
7
|
+
import { SITE, Frontmatter } from '@config';
|
|
8
8
|
import { getPageLinks } from '@util/PageLinks';
|
|
9
|
-
import { isListable, sortByPubDateDesc } from '
|
|
10
|
-
import { getItem, setItem } from '@util/Cache';
|
|
9
|
+
import { isListable, sortByPubDateDesc, getItem, setItem } from 'astro-accelerator-utils';
|
|
11
10
|
import Default from 'src/layouts/Default.astro';
|
|
12
11
|
import ArticleList from '@components/ArticleList.astro';
|
|
13
12
|
import Paging from '@components/Paging.astro';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { MarkdownInstance } from 'astro';
|
|
3
3
|
import { SITE, Frontmatter } from '@config';
|
|
4
|
-
import { addSlashToAddress } from '
|
|
4
|
+
import { addSlashToAddress } from 'astro-accelerator-utils';
|
|
5
5
|
import { getImageInfo } from '@util/custom-markdown.mjs';
|
|
6
|
+
import { getTextFrom } from '@util/Markdown';
|
|
6
7
|
import AuthorsMini from '@components/AuthorsMini.astro';
|
|
7
8
|
|
|
8
9
|
|
|
@@ -14,15 +15,35 @@ type Props = {
|
|
|
14
15
|
const { lang, posts } = Astro.props as Props;
|
|
15
16
|
|
|
16
17
|
// Logic
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
type ImageInfo = {
|
|
19
|
+
src: string;
|
|
20
|
+
srcset: string;
|
|
21
|
+
sizes: string;
|
|
22
|
+
class: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type Article = {
|
|
26
|
+
url: string;
|
|
27
|
+
frontmatter: Record<string, any>;
|
|
28
|
+
img: ImageInfo | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
const articles: Article[] = [];
|
|
33
|
+
|
|
34
|
+
for (let p of posts) {
|
|
35
|
+
const item = {
|
|
36
|
+
url: p.url ?? '',
|
|
20
37
|
frontmatter: p.frontmatter,
|
|
21
38
|
img: p.frontmatter.bannerImage
|
|
22
|
-
|
|
23
|
-
|
|
39
|
+
? getImageInfo(p.frontmatter.bannerImage.src, '', SITE.images.listerSize)
|
|
40
|
+
: null
|
|
24
41
|
};
|
|
25
|
-
|
|
42
|
+
|
|
43
|
+
item.frontmatter.title = await getTextFrom(p.frontmatter.title);
|
|
44
|
+
|
|
45
|
+
articles.push(item)
|
|
46
|
+
}
|
|
26
47
|
|
|
27
48
|
let articleIndex = 0;
|
|
28
49
|
function getLoadingAttribute() {
|
|
@@ -34,7 +55,7 @@ function getLoadingAttribute() {
|
|
|
34
55
|
---
|
|
35
56
|
<ul class="post-list anim-show-parent">
|
|
36
57
|
{articles.map((post) => (
|
|
37
|
-
<li class="list-item" data-destination={ addSlashToAddress(post.url) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
|
|
58
|
+
<li class="list-item" data-destination={ addSlashToAddress(post.url, SITE) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
|
|
38
59
|
<article>
|
|
39
60
|
<div class="list-item-image">
|
|
40
61
|
{post.img && (
|
|
@@ -49,7 +70,7 @@ function getLoadingAttribute() {
|
|
|
49
70
|
</div>
|
|
50
71
|
<div class="list-item-content">
|
|
51
72
|
<h3>
|
|
52
|
-
<a href={ addSlashToAddress(post.url) }>{ post.frontmatter.title }</a>
|
|
73
|
+
<a href={ addSlashToAddress(post.url, SITE) }>{ post.frontmatter.title }</a>
|
|
53
74
|
</h3>
|
|
54
75
|
<AuthorsMini lang={ lang } frontmatter={ post.frontmatter as Frontmatter } />
|
|
55
76
|
</div>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { SITE, Frontmatter } from '@config';
|
|
3
3
|
import { Translations, Lang } from '@util/Languages';
|
|
4
|
-
import { formatDate, formatModifiedDate } from '
|
|
4
|
+
import { formatDate, formatModifiedDate, addSlashToAddress } from 'astro-accelerator-utils';
|
|
5
5
|
import { getAuthorList } from '@util/Authors';
|
|
6
|
-
import { addSlashToAddress } from '@util/Url';
|
|
7
6
|
import { getImageInfo } from '@util/custom-markdown.mjs';
|
|
8
7
|
|
|
9
8
|
// Properties
|
|
@@ -36,9 +35,9 @@ const contributors = authorList.writers.slice(1);
|
|
|
36
35
|
<div class="author-info">
|
|
37
36
|
<span>{ _(Translations.post.written_by) }
|
|
38
37
|
{author &&
|
|
39
|
-
<a href={ addSlashToAddress(author.url) + '1/' } itemprop="author">{ author.frontmatter.title }</a>
|
|
38
|
+
<a href={ addSlashToAddress(author.url, SITE) + '1/' } itemprop="author">{ author.frontmatter.title }</a>
|
|
40
39
|
}{contributors.map((writer) => (
|
|
41
|
-
<a href={ addSlashToAddress(writer.url) + '1/' } itemprop="contributor">{ writer.frontmatter.title }</a>
|
|
40
|
+
<a href={ addSlashToAddress(writer.url, SITE) + '1/' } itemprop="contributor">{ writer.frontmatter.title }</a>
|
|
42
41
|
))}.
|
|
43
42
|
<br /><time datetime={ frontmatter.pubDate.toString() } itemprop="datePublished">
|
|
44
43
|
{ formatDate(frontmatter, lang, SITE) }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { SITE, Frontmatter } from '@config';
|
|
3
3
|
import { Translations, Lang } from '@util/Languages';;
|
|
4
|
-
import { formatDate } from '
|
|
4
|
+
import { formatDate } from 'astro-accelerator-utils';
|
|
5
5
|
import { getAuthorList } from '@util/Authors';
|
|
6
6
|
|
|
7
7
|
// Properties
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import { SITE, Frontmatter } from '@config';
|
|
3
3
|
import { Translations, Lang } from '@util/Languages';
|
|
4
4
|
import { getBreadcrumbs } from '@util/Breadcrumbs';
|
|
5
|
-
import { addSlashToAddress } from '
|
|
5
|
+
import { addSlashToAddress } from 'astro-accelerator-utils';
|
|
6
6
|
|
|
7
7
|
// Properties
|
|
8
8
|
type Props = {
|
|
@@ -24,7 +24,7 @@ const navPages = await getBreadcrumbs(currentUrl);
|
|
|
24
24
|
{navPages.map((page, index) => (
|
|
25
25
|
<li property="itemListElement" typeof="ListItem">
|
|
26
26
|
<meta property="position" content={ index.toString() } />
|
|
27
|
-
<a property="item" typeof="WebPage" href={ addSlashToAddress(page.url) } aria-current={ page.ariaCurrent } rel={ page.rel }><span property="name">{ page.title }</span></a>
|
|
27
|
+
<a property="item" typeof="WebPage" href={ addSlashToAddress(page.url, SITE) } aria-current={ page.ariaCurrent } rel={ page.rel }><span property="name">{ page.title }</span></a>
|
|
28
28
|
</li>
|
|
29
29
|
))}
|
|
30
30
|
</ol>
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { SITE, Frontmatter } from '@config';
|
|
3
3
|
import { Translations, Lang } from '@util/Languages';
|
|
4
|
-
import {
|
|
5
|
-
import { addSlashToAddress } from '
|
|
6
|
-
import { isSearch } from '@util/PageTypeFilters';
|
|
4
|
+
import { fetchPages } from '@util/PageQueries';
|
|
5
|
+
import { addSlashToAddress, isSearch, getPages } from 'astro-accelerator-utils';
|
|
7
6
|
|
|
8
7
|
// Properties
|
|
9
8
|
type Props = {
|
|
@@ -17,7 +16,7 @@ const { lang } = Astro.props as Props;
|
|
|
17
16
|
const _ = Lang(lang);
|
|
18
17
|
|
|
19
18
|
// Logic
|
|
20
|
-
const search = (await getPages(isSearch))[0] ?? null;
|
|
19
|
+
const search = (await getPages(fetchPages, isSearch))[0] ?? null;
|
|
21
20
|
|
|
22
21
|
---
|
|
23
22
|
<header class="site-header">
|
|
@@ -31,7 +30,7 @@ const search = (await getPages(isSearch))[0] ?? null;
|
|
|
31
30
|
</svg></a>
|
|
32
31
|
<a href={ (SITE.subfolder ?? '') + '/' } class="site-title" translate="no">{ SITE.title }</a>
|
|
33
32
|
{search != null &&
|
|
34
|
-
<a href={ addSlashToAddress(search.url) } class="search-icon" title={ _(Translations.header.open_search) }><svg xmlns="http://www.w3.org/2000/svg"
|
|
33
|
+
<a href={ addSlashToAddress(search.url, SITE) } class="search-icon" title={ _(Translations.header.open_search) }><svg xmlns="http://www.w3.org/2000/svg"
|
|
35
34
|
width="40" height="40" viewBox="0 0 24 24" stroke-width="1"
|
|
36
35
|
fill="none" stroke-linecap="round" stroke-linejoin="round">
|
|
37
36
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { SITE } from '@config';
|
|
2
3
|
import type { NavPage } from '@util/NavigationTypes';
|
|
3
|
-
import { addSlashToAddress } from '
|
|
4
|
+
import { addSlashToAddress } from 'astro-accelerator-utils';
|
|
4
5
|
|
|
5
6
|
// Properties
|
|
6
7
|
type Props = {
|
|
@@ -11,7 +12,7 @@ const { lang, page } = Astro.props as Props;
|
|
|
11
12
|
---
|
|
12
13
|
{(page.children.length == 0) && (
|
|
13
14
|
<li>
|
|
14
|
-
<a href={ addSlashToAddress(page.url) } aria-current={ page.ariaCurrent } rel={ page.rel }>{ page.title }</a>
|
|
15
|
+
<a href={ addSlashToAddress(page.url, SITE) } aria-current={ page.ariaCurrent } rel={ page.rel }>{ page.title }</a>
|
|
15
16
|
</li>
|
|
16
17
|
)}
|
|
17
18
|
{(page.children.length > 0) && (
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
---
|
|
2
|
+
import { SITE } from '@config';
|
|
2
3
|
import type { Link } from '@util/PageLinks';
|
|
3
4
|
import type { MarkdownInstance, Page } from 'astro';
|
|
4
5
|
import { Translations, Lang } from '@util/Languages';
|
|
5
|
-
import { addSlashToAddress } from '
|
|
6
|
+
import { addSlashToAddress } from 'astro-accelerator-utils';
|
|
6
7
|
|
|
7
8
|
// Properties
|
|
8
9
|
type Props = {
|
|
@@ -20,12 +21,12 @@ const _ = Lang(lang);
|
|
|
20
21
|
---
|
|
21
22
|
<nav class="post-paging" aria-label={ _(Translations.aria.paging) }>
|
|
22
23
|
{page.url.prev
|
|
23
|
-
? <a href={ addSlashToAddress(page.url.prev) }>{ _(Translations.articles.previous) }</a>
|
|
24
|
+
? <a href={ addSlashToAddress(page.url.prev, SITE) }>{ _(Translations.articles.previous) }</a>
|
|
24
25
|
: <span>{ _(Translations.articles.previous) }</span>}
|
|
25
26
|
{pageLinks.map((link) => (
|
|
26
|
-
<a href={ addSlashToAddress(link.url) } aria-current={ link.ariaCurrent } class={ link.class }>{ link.title }</a>
|
|
27
|
+
<a href={ addSlashToAddress(link.url, SITE) } aria-current={ link.ariaCurrent } class={ link.class }>{ link.title }</a>
|
|
27
28
|
))}
|
|
28
29
|
{page.url.next
|
|
29
|
-
? <a href={ addSlashToAddress(page.url.next) }>{ _(Translations.articles.next) }</a>
|
|
30
|
+
? <a href={ addSlashToAddress(page.url.next, SITE) }>{ _(Translations.articles.next) }</a>
|
|
30
31
|
: <span>{ _(Translations.articles.next) }</span>}
|
|
31
32
|
</nav>
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import { SITE, Frontmatter } from '@config';
|
|
3
3
|
import type { MarkdownInstance } from 'astro';
|
|
4
|
-
import { addSlashToAddress } from '
|
|
4
|
+
import { addSlashToAddress, isListable, sortByPubDateDesc, getPages } from 'astro-accelerator-utils';
|
|
5
5
|
import { getImageInfo } from '@util/custom-markdown.mjs'
|
|
6
|
-
import {
|
|
7
|
-
import { isListable, sortByPubDateDesc } from '@util/PageTypeFilters';
|
|
6
|
+
import { fetchPages } from '@util/PageQueries';
|
|
8
7
|
|
|
9
8
|
import AuthorsMini from '@components/AuthorsMini.astro';
|
|
10
9
|
|
|
11
|
-
import { SITE } from '@config';
|
|
12
|
-
|
|
13
10
|
// Properties
|
|
14
11
|
type Props = {
|
|
15
12
|
lang: string;
|
|
@@ -23,7 +20,7 @@ let posts: MarkdownInstance<Record<string, any>>[] = [];
|
|
|
23
20
|
const parentCagory = (frontmatter.categories ?? [null])[0];
|
|
24
21
|
|
|
25
22
|
if (parentCagory != null) {
|
|
26
|
-
const allPages = await getPages(isListable)
|
|
23
|
+
const allPages = await getPages(fetchPages, isListable)
|
|
27
24
|
const allPosts = allPages
|
|
28
25
|
.filter(p => p.frontmatter.title != frontmatter.title && p.frontmatter.categories && p.frontmatter.categories.includes(parentCagory))
|
|
29
26
|
.sort(sortByPubDateDesc)
|
|
@@ -56,7 +53,7 @@ const articles = posts.map(p => {
|
|
|
56
53
|
{articles.length > 0 &&
|
|
57
54
|
<ul class="post-list anim-show-parent">
|
|
58
55
|
{articles.map((post) => (
|
|
59
|
-
<li class="list-item" data-destination={ addSlashToAddress(post.url) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
|
|
56
|
+
<li class="list-item" data-destination={ addSlashToAddress(post.url, SITE) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
|
|
60
57
|
<article>
|
|
61
58
|
<div class="list-item-image">
|
|
62
59
|
{post.img && (
|
|
@@ -71,7 +68,7 @@ const articles = posts.map(p => {
|
|
|
71
68
|
</div>
|
|
72
69
|
<div class="list-item-content">
|
|
73
70
|
<h3>
|
|
74
|
-
<a href={ addSlashToAddress(post.url) }>{ post.frontmatter.title }</a>
|
|
71
|
+
<a href={ addSlashToAddress(post.url, SITE) }>{ post.frontmatter.title }</a>
|
|
75
72
|
</h3>
|
|
76
73
|
<AuthorsMini lang={ lang } frontmatter={ post.frontmatter as Frontmatter } />
|
|
77
74
|
</div>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { SITE, Frontmatter } from '@config';
|
|
3
|
+
import { getPages } from 'astro-accelerator-utils';
|
|
3
4
|
import { Translations, Lang } from '@util/Languages';
|
|
4
|
-
import {
|
|
5
|
+
import { fetchPages } from '@util/PageQueries';
|
|
5
6
|
import Default from './Default.astro';
|
|
6
7
|
import ArticleList from '@components/ArticleList.astro';
|
|
7
8
|
|
|
@@ -17,7 +18,7 @@ const lang = frontmatter.lang ?? SITE.default.lang;
|
|
|
17
18
|
const _ = Lang(lang);
|
|
18
19
|
|
|
19
20
|
// Logic
|
|
20
|
-
const authorPages = await getPages(p => p.frontmatter.authors?.indexOf(frontmatter.id) > -1)
|
|
21
|
+
const authorPages = await getPages(fetchPages, p => p.frontmatter.authors?.indexOf(frontmatter.id) > -1)
|
|
21
22
|
---
|
|
22
23
|
<Default frontmatter={ frontmatter } headings={ headings }>
|
|
23
24
|
<slot />
|
|
@@ -27,7 +27,8 @@ const subtitle = frontmatter.subtitle
|
|
|
27
27
|
? await getInlineHtmlFrom(frontmatter.subtitle)
|
|
28
28
|
: null;
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const site_url = SITE.url;
|
|
31
|
+
const site_features = SITE.featureFlags;
|
|
31
32
|
---
|
|
32
33
|
<html dir={ textDirection } lang={ lang } class="initial">
|
|
33
34
|
<Head frontmatter={ frontmatter } headings={ headings } lang={ lang } />
|
|
@@ -56,7 +57,10 @@ const features = "<script>const site_url = '" + SITE.url + "'; const site_featur
|
|
|
56
57
|
</main>
|
|
57
58
|
</div>
|
|
58
59
|
<Footer frontmatter={ frontmatter } headings={ headings } lang={ lang } />
|
|
59
|
-
<
|
|
60
|
+
<script define:vars={{ site_url, site_features }}>
|
|
61
|
+
window.site_url = site_url;
|
|
62
|
+
window.site_features = site_features;
|
|
63
|
+
</script>
|
|
60
64
|
<script src={ SITE.subfolder + '/js/main.js' } type="module" async></script>
|
|
61
65
|
</body>
|
|
62
66
|
</html>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Frontmatter } from '@config';
|
|
2
2
|
import type { MarkdownInstance } from 'astro';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { isAuthor } from "
|
|
4
|
+
import { fetchPages } from "@util/PageQueries";
|
|
5
|
+
import { isAuthor, getPages } from "astro-accelerator-utils";
|
|
6
6
|
|
|
7
7
|
type BannerImage = { src: string; alt: string } | null;
|
|
8
8
|
type AuthorList = {
|
|
@@ -11,7 +11,7 @@ type AuthorList = {
|
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export async function getAuthors () {
|
|
14
|
-
const authors = await getPages(isAuthor);
|
|
14
|
+
const authors = await getPages(fetchPages, isAuthor);
|
|
15
15
|
return authors;
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { getPages } from '
|
|
1
|
+
import { getPages } from 'astro-accelerator-utils';
|
|
2
|
+
import { fetchPages } from '@util/PageQueries';
|
|
2
3
|
import { mapNavPage, setCurrentPage, popMatchingPage } from '@util/NavPage';
|
|
3
4
|
|
|
4
5
|
import type { NavPage } from '@util/NavigationTypes';
|
|
5
6
|
|
|
6
7
|
export async function getBreadcrumbs (currentUrl: URL) {
|
|
7
|
-
const allPages = await getPages();
|
|
8
|
+
const allPages = await getPages(fetchPages);
|
|
8
9
|
|
|
9
10
|
const pathParts = currentUrl.pathname.split('/');
|
|
10
11
|
const navPages: NavPage[] = [];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { menu } from 'src/data/footer';
|
|
3
3
|
import { Translations, Lang } from '@util/Languages';
|
|
4
4
|
import { SITE } from '@config';
|
|
5
|
-
import { getItem, setItem } from '
|
|
5
|
+
import { getItem, setItem } from 'astro-accelerator-utils';
|
|
6
6
|
import { setCurrentPage } from '@util/NavPage';
|
|
7
7
|
import { NavPage, isNavPage } from '@util/NavigationTypes';
|
|
8
8
|
import { getTaxonomy, taxonomyLinks } from '@util/Taxonomy';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { SITE } from '@config';
|
|
1
2
|
import type { MarkdownInstance } from 'astro';
|
|
2
3
|
import type { NavPage } from './NavigationTypes';
|
|
3
4
|
|
|
4
|
-
import { addSlashToAddress } from '
|
|
5
|
+
import { addSlashToAddress } from 'astro-accelerator-utils';
|
|
5
6
|
|
|
6
7
|
export function mapNavPage (page: MarkdownInstance<Record<string, any>>) {
|
|
7
8
|
|
|
@@ -14,7 +15,7 @@ export function mapNavPage (page: MarkdownInstance<Record<string, any>>) {
|
|
|
14
15
|
url += '/1/';
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
url = addSlashToAddress(url);
|
|
18
|
+
url = addSlashToAddress(url, SITE);
|
|
18
19
|
|
|
19
20
|
if (page.frontmatter.layout == 'src/layouts/Redirect.astro') {
|
|
20
21
|
// Skips past the redirect
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// Data file `navigation.ts`
|
|
2
2
|
import { menu } from 'src/data/navigation';
|
|
3
3
|
|
|
4
|
-
import { getItem, setItem } from '
|
|
5
|
-
import { showInMenu } from '@util/PageTypeFilters';
|
|
4
|
+
import { showInMenu, getItem, setItem, getPages } from 'astro-accelerator-utils';
|
|
6
5
|
import { mapNavPage, setCurrentPage } from '@util/NavPage';
|
|
7
6
|
import { NavPage, isNavPage } from '@util/NavigationTypes';
|
|
8
|
-
import { getTopLevelPages,
|
|
7
|
+
import { getTopLevelPages, fetchPages } from '@util/PageQueries';
|
|
9
8
|
|
|
10
9
|
export async function getMenu (currentUrl: URL) {
|
|
11
10
|
const key = 'Navigation__getMenu';
|
|
@@ -41,7 +40,7 @@ export async function getNavigation (currentUrl: URL) {
|
|
|
41
40
|
|
|
42
41
|
if (pageHierarchy == null) {
|
|
43
42
|
const topLevelPages = await getTopLevelPages(showInMenu);
|
|
44
|
-
const allPages = await getPages(showInMenu);
|
|
43
|
+
const allPages = await getPages(fetchPages, showInMenu);
|
|
45
44
|
|
|
46
45
|
pageHierarchy = topLevelPages
|
|
47
46
|
.map(mapNavPage)
|
|
@@ -1,33 +1,36 @@
|
|
|
1
1
|
import type { MarkdownInstance } from "astro";
|
|
2
2
|
import { SITE } from '@config';
|
|
3
|
-
import { getItem, setItem } from '
|
|
4
|
-
import { isAuthor } from '@util/PageTypeFilters';
|
|
3
|
+
import { isAuthor, getItem, setItem, PagePredicate, getPages } from 'astro-accelerator-utils';
|
|
5
4
|
|
|
6
|
-
export
|
|
5
|
+
export function fetchPages(): Record<string, any> {
|
|
6
|
+
return import.meta.glob("../../../pages/**/*.md", { eager: true });
|
|
7
|
+
}
|
|
7
8
|
|
|
8
|
-
export
|
|
9
|
-
const key = 'PageQueries__getPages';
|
|
10
|
-
let allPages: MarkdownInstance<Record<string,any>>[] = await getItem(key);
|
|
9
|
+
// export type PagePredicate = (value: MarkdownInstance<Record<string, any>>, index: number, array: MarkdownInstance<Record<string, any>>[]) => boolean;
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
await setItem(key, allPages);
|
|
16
|
-
}
|
|
11
|
+
// export async function getPages (fetchPages: () => Record<string, any>, filter?: PagePredicate | null): Promise<MarkdownInstance<Record<string,any>>[]> {
|
|
12
|
+
// const key = 'PageQueries__getPages';
|
|
13
|
+
// let allPages: MarkdownInstance<Record<string,any>>[] = await getItem(key);
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
// if (allPages == null) {
|
|
16
|
+
// const pageImportResult = fetchPages();
|
|
17
|
+
// allPages = Object.values(pageImportResult) as MarkdownInstance<Record<string,any>>[];
|
|
18
|
+
// await setItem(key, allPages);
|
|
19
|
+
// }
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
// if (filter == null) {
|
|
22
|
+
// return allPages;
|
|
23
|
+
// }
|
|
24
|
+
|
|
25
|
+
// return allPages.filter(filter);
|
|
26
|
+
// }
|
|
24
27
|
|
|
25
28
|
export async function getTopLevelPages (filter?: PagePredicate | null): Promise<MarkdownInstance<Record<string,any>>[]> {
|
|
26
29
|
const key = 'PageQueries__getTopLevelPages';
|
|
27
30
|
let allPages = await getItem(key);
|
|
28
31
|
|
|
29
32
|
if (allPages == null) {
|
|
30
|
-
allPages = await getPages();
|
|
33
|
+
allPages = await getPages(fetchPages);
|
|
31
34
|
|
|
32
35
|
const isRoot = SITE.subfolder.length == 0;
|
|
33
36
|
const expectedDepth = isRoot ? 1 : 2;
|
|
@@ -53,7 +56,7 @@ export async function getAuthorInfo (slug: string) {
|
|
|
53
56
|
let authorInfo = await getItem(cacheKey);
|
|
54
57
|
|
|
55
58
|
if (authorInfo == null) {
|
|
56
|
-
const allPages = await getPages();
|
|
59
|
+
const allPages = await getPages(fetchPages);
|
|
57
60
|
|
|
58
61
|
const author = allPages
|
|
59
62
|
.filter(isAuthor)
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Entry } from '@util/Languages';
|
|
2
2
|
import { Translations } from '@util/Languages';
|
|
3
3
|
import { SITE } from '@config';
|
|
4
|
-
import {
|
|
5
|
-
import { getItem, setItem } from '
|
|
6
|
-
import { addSlashToAddress } from '@util/Url';
|
|
4
|
+
import { fetchPages } from '@util/PageQueries';
|
|
5
|
+
import { addSlashToAddress, getItem, setItem, getPages } from 'astro-accelerator-utils';
|
|
7
6
|
|
|
8
7
|
type TaxonomyEntry = {
|
|
9
8
|
title: string;
|
|
@@ -39,10 +38,10 @@ export function taxonomyLinks(lang: (entry: Entry) => string) {
|
|
|
39
38
|
tag: tag,
|
|
40
39
|
category: category,
|
|
41
40
|
getCategoryLink: (category: string) => {
|
|
42
|
-
return addSlashToAddress(categoryLink + category.toLowerCase().replace(/ /g, '-') + '/1/');
|
|
41
|
+
return addSlashToAddress(categoryLink + category.toLowerCase().replace(/ /g, '-') + '/1/', SITE);
|
|
43
42
|
},
|
|
44
43
|
getTagLink: (tag: string) => {
|
|
45
|
-
return addSlashToAddress(tagLink + tag.toLowerCase().replace(/ /g, '-') + '/1/');
|
|
44
|
+
return addSlashToAddress(tagLink + tag.toLowerCase().replace(/ /g, '-') + '/1/', SITE);
|
|
46
45
|
}
|
|
47
46
|
};
|
|
48
47
|
|
|
@@ -54,7 +53,7 @@ export async function getTaxonomy (): Promise<Taxonomy> {
|
|
|
54
53
|
let taxonomy: Taxonomy = await getItem(cacheKey);
|
|
55
54
|
|
|
56
55
|
if (taxonomy == null) {
|
|
57
|
-
const allPages = await getPages();
|
|
56
|
+
const allPages = await getPages(fetchPages);
|
|
58
57
|
const tags: { [key: string]: number } = {};
|
|
59
58
|
const cats: { [key: string]: number } = {};
|
|
60
59
|
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import process from 'process';
|
|
4
|
-
|
|
5
|
-
export const maxAge = 200; //seconds
|
|
6
|
-
|
|
7
|
-
export async function getCachePath () {
|
|
8
|
-
const cachePath = path.join(process.cwd(), '.cache/');
|
|
9
|
-
await fs.promises.mkdir(cachePath, { recursive: true })
|
|
10
|
-
return cachePath;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function getItemPath (key: string) {
|
|
14
|
-
const cachePath = await getCachePath();
|
|
15
|
-
return path.join(cachePath, key + '.cache');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export async function getItem (key: string) {
|
|
19
|
-
const itemPath = await getItemPath(key);
|
|
20
|
-
try {
|
|
21
|
-
|
|
22
|
-
const { mtime } = await fs.promises.stat(itemPath);
|
|
23
|
-
|
|
24
|
-
var date_time = new Date();
|
|
25
|
-
let timeDifference = Math.abs((date_time.getTime() - mtime.getTime()) / 1000);
|
|
26
|
-
if (timeDifference < maxAge) {
|
|
27
|
-
console.log('Cache hit', key);
|
|
28
|
-
const content = fs.readFileSync(itemPath).toString();
|
|
29
|
-
return JSON.parse(content);
|
|
30
|
-
}
|
|
31
|
-
} catch{}
|
|
32
|
-
|
|
33
|
-
console.warn('Cache miss', key);
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export async function setItem (key: string, value: object) {
|
|
38
|
-
const itemPath = await getItemPath(key);
|
|
39
|
-
await fs.promises.writeFile(itemPath, JSON.stringify(value));
|
|
40
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Site } from '@config';
|
|
2
|
-
|
|
3
|
-
type FrontMatter = Record<string, any>;
|
|
4
|
-
|
|
5
|
-
export function formatDate (frontmatter: FrontMatter, lang: string, site: Site) {
|
|
6
|
-
const date = frontmatter.pubDate ?? '';
|
|
7
|
-
|
|
8
|
-
if (date) {
|
|
9
|
-
return new Date(date).toLocaleDateString(lang, site.dateOptions);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
return '';
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function formatModifiedDate (frontmatter: FrontMatter, lang: string, site: Site) {
|
|
16
|
-
const date = frontmatter.modDate ?? '';
|
|
17
|
-
|
|
18
|
-
if (date) {
|
|
19
|
-
return new Date(date).toLocaleDateString(lang, site.dateOptions);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return '';
|
|
23
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { MarkdownInstance } from 'astro';
|
|
2
|
-
|
|
3
|
-
export function showInSitemap (p: MarkdownInstance<Record<string, any>>) {
|
|
4
|
-
// User setting to remove from sitemap
|
|
5
|
-
if (typeof p.frontmatter.navSitemap !== 'undefined'
|
|
6
|
-
&& p.frontmatter.navSitemap == false) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
return isListable(p);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function showInSearch (p: MarkdownInstance<Record<string, any>>) {
|
|
14
|
-
// User setting to remove from search
|
|
15
|
-
if (typeof p.frontmatter.navSearch !== 'undefined'
|
|
16
|
-
&& p.frontmatter.navSearch == false) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return isListable(p);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function showInMenu (p: MarkdownInstance<Record<string, any>>) {
|
|
24
|
-
if (typeof p.frontmatter.navMenu !== 'undefined'
|
|
25
|
-
&& p.frontmatter.navMenu == false) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function isAuthor (p: MarkdownInstance<Record<string, any>>) {
|
|
33
|
-
if (p?.frontmatter?.layout?.indexOf('/Author.astro') > -1) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export function isSearch (p: MarkdownInstance<Record<string, any>>) {
|
|
41
|
-
if (p?.frontmatter?.layout?.indexOf('/Search.astro') > -1) {
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export function isListable (p: MarkdownInstance<Record<string, any>>) {
|
|
49
|
-
return p.url != null
|
|
50
|
-
&& p.url != ''
|
|
51
|
-
&& p.frontmatter.layout.includes('/Redirect.astro') !== true
|
|
52
|
-
&& Date.parse(p.frontmatter.pubDate) < Date.now()
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function sortByPubDate (a: MarkdownInstance<Record<string, any>>, b: MarkdownInstance<Record<string, any>>) {
|
|
56
|
-
return b.frontmatter.pubDate.localeCompare(a.frontmatter.pubDate);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function sortByPubDateDesc (a: MarkdownInstance<Record<string, any>>, b: MarkdownInstance<Record<string, any>>) {
|
|
60
|
-
return b.frontmatter.pubDate.localeCompare(a.frontmatter.pubDate);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function sortByModDate (a: MarkdownInstance<Record<string, any>>, b: MarkdownInstance<Record<string, any>>) {
|
|
64
|
-
const dateA = a.frontmatter.modDate || a.frontmatter.pubDate || '1970-01-01';
|
|
65
|
-
const dateB = b.frontmatter.modDate || b.frontmatter.pubDate || '1970-01-01';
|
|
66
|
-
return dateA.localeCompare(dateB);
|
|
67
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SITE } from '@config';
|
|
2
|
-
|
|
3
|
-
export function addSlashToUrl (url: URL) {
|
|
4
|
-
url.pathname += url.pathname.endsWith('/') ? '' : '/';
|
|
5
|
-
return url;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function addSlashToAddress (address: string | undefined) {
|
|
9
|
-
if (!address) {
|
|
10
|
-
address = '/';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (address.indexOf('://') > -1) {
|
|
14
|
-
return address;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const url = addSlashToUrl(new URL(address, SITE.url));
|
|
18
|
-
return url.pathname + url.search;
|
|
19
|
-
}
|