astro-accelerator 4.0.0 → 4.0.2

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.
Files changed (61) hide show
  1. package/README.md +4 -0
  2. package/package.json +6 -6
  3. package/src/pages/search.json.ts +6 -9
  4. package/.npmrc +0 -2
  5. package/public/css/main.css +0 -1189
  6. package/public/css/vars.css +0 -89
  7. package/public/icons/android-chrome-192x192.png +0 -0
  8. package/public/icons/android-chrome-512x512.png +0 -0
  9. package/public/icons/apple-touch-icon.png +0 -0
  10. package/public/icons/favicon-16x16.png +0 -0
  11. package/public/icons/favicon-32x32.png +0 -0
  12. package/public/icons/favicon.ico +0 -0
  13. package/public/js/main.js +0 -66
  14. package/public/js/modules/animation.js +0 -69
  15. package/public/js/modules/click-blocks.js +0 -42
  16. package/public/js/modules/code-blocks.js +0 -59
  17. package/public/js/modules/detail-tabs.js +0 -194
  18. package/public/js/modules/events.js +0 -19
  19. package/public/js/modules/external-links.js +0 -20
  20. package/public/js/modules/figures.js +0 -28
  21. package/public/js/modules/focus.js +0 -76
  22. package/public/js/modules/headers.js +0 -21
  23. package/public/js/modules/input-type.js +0 -53
  24. package/public/js/modules/nav-mobile.js +0 -159
  25. package/public/js/modules/nav-sticky.js +0 -56
  26. package/public/js/modules/query.js +0 -41
  27. package/public/js/modules/resizing.js +0 -43
  28. package/public/js/modules/search-dialog.js +0 -69
  29. package/public/js/modules/share.js +0 -31
  30. package/public/js/modules/string.js +0 -77
  31. package/public/js/modules/toc.js +0 -82
  32. package/public/js/modules/youtube.js +0 -44
  33. package/public/js/search.js +0 -615
  34. package/src/themes/accelerator/components/ArticleList.astro +0 -90
  35. package/src/themes/accelerator/components/Authors.astro +0 -65
  36. package/src/themes/accelerator/components/AuthorsMini.astro +0 -41
  37. package/src/themes/accelerator/components/Breadcrumbs.astro +0 -53
  38. package/src/themes/accelerator/components/Copyright.astro +0 -28
  39. package/src/themes/accelerator/components/Footer.astro +0 -37
  40. package/src/themes/accelerator/components/FooterItem.astro +0 -31
  41. package/src/themes/accelerator/components/Header.astro +0 -46
  42. package/src/themes/accelerator/components/HtmlHead.astro +0 -60
  43. package/src/themes/accelerator/components/Navigation.astro +0 -34
  44. package/src/themes/accelerator/components/NavigationBar.astro +0 -33
  45. package/src/themes/accelerator/components/NavigationItem.astro +0 -40
  46. package/src/themes/accelerator/components/PagingLinks.astro +0 -36
  47. package/src/themes/accelerator/components/RecentlyUpdated.astro +0 -38
  48. package/src/themes/accelerator/components/Related.astro +0 -87
  49. package/src/themes/accelerator/components/SkipLinks.astro +0 -29
  50. package/src/themes/accelerator/components/TableOfContents.astro +0 -46
  51. package/src/themes/accelerator/components/Taxonomy.astro +0 -53
  52. package/src/themes/accelerator/layouts/Author.astro +0 -27
  53. package/src/themes/accelerator/layouts/Default.astro +0 -83
  54. package/src/themes/accelerator/layouts/Redirect.astro +0 -29
  55. package/src/themes/accelerator/layouts/Search.astro +0 -48
  56. package/src/themes/accelerator/utilities/Languages.ts +0 -21
  57. package/src/themes/accelerator/utilities/custom-markdown.mjs +0 -142
  58. package/src/themes/accelerator/utilities/default-layout.mjs +0 -7
  59. package/src/themes/accelerator/utilities/img.mjs +0 -142
  60. package/src/themes/accelerator/utilities/language.json +0 -117
  61. package/src/themes/accelerator/utilities/stats.mjs +0 -44
@@ -1,65 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE } from '@config';
5
- import { Translations, Lang } from '@util/Languages';
6
- import { getImageInfo } from '@util/custom-markdown.mjs';
7
-
8
- const accelerator = new Accelerator(SITE);
9
- const stats = new accelerator.statistics('accelerator/components/Authors.astro');
10
- stats.start();
11
-
12
- // Properties
13
- type Props = {
14
- lang: string;
15
- frontmatter: Frontmatter;
16
- };
17
- const { lang, frontmatter } = Astro.props satisfies Props;
18
-
19
- // Language
20
- const _ = Lang(lang);
21
-
22
- // Logic
23
- const authorList = accelerator.authors.forPost(frontmatter);
24
-
25
- // Get image info
26
- const authorImage = authorList?.image?.src
27
- ? getImageInfo(authorList.image.src, 'author-image', SITE.images.authorSize)
28
- : null;
29
-
30
- stats.stop();
31
- ---
32
- {authorList.writers.length > 0 &&
33
- <div class="post-meta">
34
- {authorImage &&
35
- <img
36
- srcset={ authorImage.srcset }
37
- sizes={ authorImage.sizes }
38
- src={ authorImage.src }
39
- alt={ authorList?.image?.alt }
40
- class={ authorImage.class }
41
- width={ authorImage.metadata?.width }
42
- height={ authorImage.metadata?.height }
43
- />
44
- }
45
- <div class="author-info">
46
- <span class="author-list">{ _(Translations.post.written_by) + ' ' }
47
- {authorList.mainAuthor &&
48
- <span itemprop="author" itemscope itemtype="https://schema.org/Person"><a href={ accelerator.urlFormatter.formatAddress(authorList.mainAuthor.url) + '1/' } itemprop="url"><span itemprop="name">{ authorList.mainAuthor.frontmatter.title }</span></a></span>
49
- }{authorList.contributors.map((writer) => (
50
- <span>, </span><span itemprop="contributor" itemscope itemtype="https://schema.org/Person"><a href={ accelerator.urlFormatter.formatAddress(writer.url) + '1/' } itemprop="url"><span itemprop="name">{ writer.frontmatter.title }</span></a></span>
51
- ))}
52
- <br /><time datetime={ frontmatter.pubDate.toString() } itemprop="datePublished">
53
- { accelerator.dateFormatter.formatDate(frontmatter.pubDate, lang) }
54
- </time>
55
- {frontmatter.modDate &&
56
- <br /><time datetime={ frontmatter.modDate.toString() } itemprop="dateModified">
57
- { _(Translations.post.last_modified) + ' ' + accelerator.dateFormatter.formatDate(frontmatter.modDate, lang) }
58
- </time>
59
- }{authorList.mainAuthor &&
60
- <p>{ authorList.mainAuthor.frontmatter.description }</p>
61
- }
62
- </span>
63
- </div>
64
- </div>
65
- }
@@ -1,41 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE } from '@config';
5
- import { Translations, Lang } from '@util/Languages';;
6
-
7
- const accelerator = new Accelerator(SITE);
8
- const stats = new accelerator.statistics('accelerator/components/AuthorsMini.astro');
9
- stats.start();
10
-
11
- // Properties
12
- type Props = {
13
- lang: string;
14
- frontmatter: Frontmatter;
15
- };
16
- const { lang, frontmatter } = Astro.props satisfies Props;
17
-
18
- // Language
19
- const _ = Lang(lang);
20
-
21
- // Logic
22
- const authorList = accelerator.authors.forPost(frontmatter);
23
-
24
- stats.stop();
25
- ---
26
- {authorList.writers.length > 0 &&
27
- <div class="post-meta">
28
- <div class="author-info">
29
- <span>{ _(Translations.post.written_by) + ' ' }
30
- {authorList.mainAuthor &&
31
- <span>{ authorList.mainAuthor.frontmatter.title }</span>
32
- }{authorList.contributors.map((writer) => (
33
- <span>, </span><span>{ writer.frontmatter.title }</span>
34
- ))}<br />
35
- <time datetime={ frontmatter.pubDate.toString() }>
36
- { accelerator.dateFormatter.formatDate(frontmatter.pubDate, lang) }
37
- </time>
38
- </span>
39
- </div>
40
- </div>
41
- }
@@ -1,53 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE } from '@config';
5
- import { Translations, Lang } from '@util/Languages';
6
-
7
- const accelerator = new Accelerator(SITE);
8
- const stats = new accelerator.statistics('accelerator/components/Breadcrumbs.astro');
9
- stats.start();
10
-
11
- // Properties
12
- type Props = {
13
- lang: string;
14
- frontmatter: Frontmatter
15
- headings: { depth: number; slug: string; text: string; }[];
16
- breadcrumbs?: { url: string; title: string; ariaCurrent?: string; }[] | null;
17
- };
18
- const { lang, breadcrumbs } = Astro.props satisfies Props;
19
-
20
- // Language
21
- const _ = Lang(lang);
22
-
23
- // Logic
24
- const currentUrl = new URL(Astro.request.url);
25
- const navPages = accelerator.navigation.breadcrumbs(currentUrl, SITE.subfolder, breadcrumbs?.length ?? 0);
26
-
27
- for (let i = 0; i < navPages.length; i++) {
28
- navPages[i].title = navPages[i].section || navPages[i].title;
29
- }
30
-
31
- // The last breadcrumb should use the full name
32
- //navPages[navPages.length -1].title = navPages[navPages.length -1].fullTitle;
33
-
34
- let metaIndex = navPages.length;
35
-
36
- stats.stop();
37
- ---
38
- <nav class="site-breadcrumbs" aria-label={ _(Translations.aria.breadcrumbs) }>
39
- <ol vocab="http://schema.org/" typeof="BreadcrumbList">
40
- {navPages.map((page, index) => (
41
- <li property="itemListElement" typeof="ListItem">
42
- <meta property="position" content={ index.toString() } />
43
- <a property="item" typeof="WebPage" href={ accelerator.urlFormatter.formatAddress(page.url) } aria-current={ page.ariaCurrent } rel={ page.rel }><span property="name">{ page.title }</span></a>
44
- </li>
45
- ))}
46
- {breadcrumbs && breadcrumbs.map( (crumb) => (
47
- <li property="itemListElement" typeof="ListItem">
48
- <meta property="position" content={ (metaIndex++).toString() } />
49
- <a property="item" typeof="WebPage" href={ accelerator.urlFormatter.formatAddress(crumb.url) } aria-current={ crumb.ariaCurrent }><span property="name">{ crumb.title }</span></a>
50
- </li>
51
- ))}
52
- </ol>
53
- </nav>
@@ -1,28 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE } from '@config';
5
- import { Translations, Lang } from '@util/Languages';
6
-
7
- const accelerator = new Accelerator(SITE);
8
- const stats = new accelerator.statistics('accelerator/components/Copyright.astro');
9
- stats.start();
10
-
11
- // Properties
12
- type Props = {
13
- lang: string;
14
- frontmatter: Frontmatter
15
- headings: { depth: number; slug: string; text: string; }[];
16
- };
17
- const { lang } = Astro.props satisfies Props;
18
-
19
- // Language
20
- const _ = Lang(lang);
21
-
22
- // Logic
23
- stats.stop();
24
- ---
25
- <p>{ _(Translations.footer.copyright) } &copy; { new Date().getFullYear() + ' ' + SITE.owner }</p>
26
- <nav aria-label={ _(Translations.aria.back_to_top) }>
27
- <a href="#site-top">{ _(Translations.skiplinks.skip_to_top) }</a>
28
- </nav>
@@ -1,37 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE } from '@config';
5
- import { Translations, Lang } from '@util/Languages';
6
- import { menu } from 'src/data/footer';
7
- import FooterItem from '@components/FooterItem.astro';
8
-
9
- const accelerator = new Accelerator(SITE);
10
- const stats = new accelerator.statistics('accelerator/components/Footer.astro');
11
- stats.start();
12
-
13
- // Properties
14
- type Props = {
15
- lang: string;
16
- frontmatter: Frontmatter
17
- headings: { depth: number; slug: string; text: string; }[];
18
- };
19
- const { lang } = Astro.props satisfies Props;
20
-
21
- // Language
22
- const _ = Lang(lang);
23
-
24
- // Logic
25
- const currentUrl = new URL(Astro.request.url);
26
- const pages = accelerator.navigation.footer(currentUrl, _, Translations, SITE.subfolder, menu);
27
-
28
- stats.stop();
29
- ---
30
- <footer class="site-footer" id="site-footer">
31
- <div class="footer-columns">
32
- {pages.map((page) => (
33
- <FooterItem lang={ lang } page={ page } />
34
- ))}
35
- </div>
36
- <slot />
37
- </footer>
@@ -1,31 +0,0 @@
1
- ---
2
- import type { NavPage } from 'astro-accelerator-utils/types/NavPage';
3
- import { Accelerator } from 'astro-accelerator-utils';
4
- import { SITE } from '@config';
5
-
6
- const accelerator = new Accelerator(SITE);
7
- const stats = new accelerator.statistics('accelerator/components/FooterItem.astro');
8
- stats.start();
9
-
10
- // Properties
11
- type Props = {
12
- lang: string;
13
- page: NavPage
14
- };
15
- const { lang, page } = Astro.props satisfies Props;
16
-
17
- // Logic
18
- stats.stop();
19
- ---
20
- {page.children.length > 0 && (
21
- <div class="footer-column">
22
- <h2><Fragment set:html={page.title} /></h2>
23
- <ul>
24
- { page.children.sort((a, b) => a.order - b.order).map((child) => (
25
- <li>
26
- <a href={ child.url } aria-current={ child.ariaCurrent } rel={ child.rel }>{ child.title }</a>
27
- </li>
28
- ))}
29
- </ul>
30
- </div>
31
- )}
@@ -1,46 +0,0 @@
1
- ---
2
- import { PostFiltering, Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE } from '@config';
5
- import { Translations, Lang } from '@util/Languages';
6
-
7
- const accelerator = new Accelerator(SITE);
8
- const stats = new accelerator.statistics('accelerator/components/Header.astro');
9
- stats.start();
10
-
11
- // Properties
12
- type Props = {
13
- lang: string;
14
- frontmatter: Frontmatter
15
- headings: { depth: number; slug: string; text: string; }[];
16
- };
17
- const { lang } = Astro.props satisfies Props;
18
-
19
- // Language
20
- const _ = Lang(lang);
21
-
22
- // Logic
23
- const search = accelerator.posts.all().filter(PostFiltering.isSearch).shift() ?? null;
24
-
25
- stats.stop();
26
- ---
27
- <header class="site-header">
28
- <a href="#site-nav" data-navigationid="site-nav" class="navigation-icon" title={ _(Translations.header.toggle_menu) }><svg xmlns="http://www.w3.org/2000/svg"
29
- width="40" height="40" viewBox="0 0 24 24" stroke-width="1.5"
30
- fill="none" stroke-linecap="round" stroke-linejoin="round">
31
- <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
32
- <line x1="4" y1="6" x2="20" y2="6" />
33
- <line x1="4" y1="12" x2="20" y2="12" />
34
- <line x1="4" y1="18" x2="20" y2="18" />
35
- </svg></a>
36
- <a href={ (SITE.subfolder ?? '') + '/' } class="site-title" translate="no">{ SITE.title }</a>
37
- {search != null &&
38
- <a href={ accelerator.urlFormatter.formatAddress(search.url) } class="search-icon" title={ _(Translations.header.toggle_search) }><svg xmlns="http://www.w3.org/2000/svg"
39
- width="40" height="40" viewBox="0 0 24 24" stroke-width="1"
40
- fill="none" stroke-linecap="round" stroke-linejoin="round">
41
- <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
42
- <circle cx="10" cy="10" r="7" />
43
- <line x1="21" y1="21" x2="15" y2="15" />
44
- </svg></a>
45
- }
46
- </header>
@@ -1,60 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE, OPEN_GRAPH, HEADER_SCRIPTS } from '@config';
5
-
6
- const accelerator = new Accelerator(SITE);
7
- const stats = new accelerator.statistics('accelerator/components/HtmlHead.astro');
8
- stats.start();
9
-
10
- // Properties
11
- type Props = {
12
- lang: string;
13
- frontmatter: Frontmatter
14
- headings: { depth: number; slug: string; text: string; }[];
15
- };
16
- const { frontmatter } = Astro.props;
17
-
18
- // Logic
19
- const imageSrc = frontmatter.bannerImage?.src ?? OPEN_GRAPH.image.src;
20
- const imageAlt = frontmatter.bannerImage?.alt ?? OPEN_GRAPH.image.alt;
21
- const robots = frontmatter.robots ?? 'index, follow';
22
- const canonicalImageSrc = new URL(imageSrc, Astro.site);
23
- const canonicalURL = accelerator.urlFormatter.formatUrl(new URL(Astro.url.pathname, Astro.site + SITE.subfolder));
24
- const socialTitle = await accelerator.markdown.getTextFrom(frontmatter.title);
25
- const title = `${ socialTitle } ${ ((frontmatter.titleAdditional) ? ` ${frontmatter.titleAdditional}` : '') } | ${ SITE.title }`;
26
-
27
- stats.stop();
28
- ---
29
- <head>
30
- <meta charset="utf-8" />
31
- <title>{ title }</title>
32
- <meta name="robots" content={ 'max-image-preview:large, ' + robots } />
33
- <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
34
- <meta name="format-detection" content="telephone=no" />
35
- <meta name="keywords" content={ frontmatter.keywords } />
36
- <meta name="description" content={ frontmatter.description } />
37
- <meta name="theme-color" content={ SITE.themeColor } />
38
- <link rel="stylesheet" href={ SITE.subfolder + '/css/vars.css' } />
39
- <link rel="stylesheet" href={ SITE.subfolder + '/css/main.css' } />
40
- <link rel="canonical" href={ canonicalURL } />
41
- {SITE.feedUrl &&
42
- <link rel="alternate" type="application/atom+xml" title={ SITE.title } href={ SITE.feedUrl } />
43
- }
44
- <link rel="alternate" href={ SITE.subfolder + '/sitemap.xml' } type="application/rss+xml" />
45
- <link rel="shortcut icon" href={ SITE.subfolder + '/icons/favicon.ico' } type="image/x-icon" />
46
- <link rel="apple-touch-icon" href={ SITE.subfolder + '/icons/apple-touch-icon.png' } />
47
- <meta property="og:type" content="website" />
48
- <meta property="og:url" content={ canonicalURL } />
49
- <meta property="og:title" content={ socialTitle } />
50
- <meta property="og:description" content={ frontmatter.description } />
51
- <meta property="og:image" content={ canonicalImageSrc } />
52
- <meta property="og:image:alt" content={ imageAlt } />
53
- <meta name="twitter:card" content="summary_large_image" />
54
- <meta name="twitter:title" content={ socialTitle } />
55
- <meta name="twitter:description" content={ frontmatter.description } />
56
- <meta name="twitter:image" content={ canonicalImageSrc } />
57
- <meta name="twitter:image:alt" content={ imageAlt } />
58
- <meta name="view-transition" content="same-origin" />
59
- <Fragment set:html={ HEADER_SCRIPTS }></Fragment>
60
- </head>
@@ -1,34 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import { Translations, Lang } from '@util/Languages';
4
- import NavigationItem from '@components/NavigationItem.astro';
5
- import { SITE } from '@config';
6
- import { menu } from '@data/navigation';
7
-
8
- const accelerator = new Accelerator(SITE);
9
- const stats = new accelerator.statistics('accelerator/components/Navigation.astro');
10
- stats.start();
11
-
12
- // Properties
13
- type Props = {
14
- lang: string;
15
- };
16
- const { lang } = Astro.props satisfies Props;
17
-
18
- // Language
19
- const _ = Lang(lang);
20
-
21
- // Logic
22
- const currentUrl = new URL(Astro.request.url);
23
- const pages = accelerator.navigation.menu(currentUrl, SITE.subfolder, menu);
24
-
25
- stats.stop();
26
- ---
27
- <nav class="site-nav" id="site-nav" aria-label={ _(Translations.aria.site_navigation) }>
28
- <h2 class="site-nav-title">{ _(Translations.navigation.title) }</h2>
29
- <ul>
30
- {pages.sort((a, b) => a.order - b.order).map((page) => (
31
- <NavigationItem lang={ lang } page={ page } />
32
- ))}
33
- </ul>
34
- </nav>
@@ -1,33 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import { Translations, Lang } from '@util/Languages';
4
- import { SITE } from '@config';
5
- import { menu } from '@data/navigation';
6
-
7
- const accelerator = new Accelerator(SITE);
8
- const stats = new accelerator.statistics('accelerator/components/NavigationBar.astro');
9
- stats.start();
10
-
11
- // Properties
12
- type Props = {
13
- lang: string;
14
- };
15
- const { lang } = Astro.props satisfies Props;
16
-
17
- // Language
18
- const _ = Lang(lang);
19
-
20
- // Logic
21
- const currentUrl = new URL(Astro.request.url);
22
- const pages = accelerator.navigation.menu(currentUrl, SITE.subfolder, menu);
23
-
24
- stats.stop();
25
- ---
26
- <nav class="site-nav-bar" id="site-nav" aria-label={ _(Translations.aria.site_navigation) }>
27
- <h2 class="site-nav-title">{ _(Translations.navigation.title) }</h2>
28
- <ul>
29
- {pages.sort((a, b) => a.order - b.order).map((page) => (
30
- <li><a href={ page.url }>{ page.title }</a></li>
31
- ))}
32
- </ul>
33
- </nav>
@@ -1,40 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { NavPage } from 'astro-accelerator-utils/types/NavPage';
4
- import { SITE } from '@config';
5
-
6
- const accelerator = new Accelerator(SITE);
7
- const stats = new accelerator.statistics('accelerator/components/NavigationItem.astro');
8
- stats.start();
9
-
10
- // Properties
11
- type Props = {
12
- lang: string;
13
- page: NavPage
14
- };
15
- const { lang, page } = Astro.props satisfies Props;
16
-
17
- // Logic
18
- const linkTitle = (page.title === page.fullTitle)
19
- ? null
20
- : page.fullTitle;
21
-
22
- stats.stop();
23
- ---
24
- {(page.children.length == 0) && (
25
- <li>
26
- <a href={ accelerator.urlFormatter.formatAddress(page.url) } aria-current={ page.ariaCurrent } rel={ page.rel } title={ linkTitle }>{ page.title }</a>
27
- </li>
28
- )}
29
- {(page.children.length > 0) && (
30
- <li class="has-children">
31
- <details class="sub-nav" open={ page.isOpen }>
32
- <summary><span>{ page.section }</span></summary>
33
- <ul>
34
- { page.children.sort((a, b) => a.order - b.order).map((page) => (
35
- <Astro.self lang={ lang } page={ page } />
36
- ))}
37
- </ul>
38
- </details>
39
- </li>
40
- )}
@@ -1,36 +0,0 @@
1
- ---
2
- import { Accelerator } from 'astro-accelerator-utils';
3
- import type { Link } from 'astro-accelerator-utils/lib/v1/paging.mjs';
4
- import { SITE } from '@config';
5
- import type { MarkdownInstance, Page } from 'astro';
6
- import { Translations, Lang } from '@util/Languages';
7
-
8
- const accelerator = new Accelerator(SITE);
9
- const stats = new accelerator.statistics('accelerator/components/PagingLinks.astro');
10
- stats.start();
11
-
12
- // Properties
13
- type Props = {
14
- lang: string;
15
- page: Page<MarkdownInstance<Record<string, any>>>,
16
- pageLinks: Link[],
17
- };
18
- const { lang, page, pageLinks } = Astro.props satisfies Props;
19
-
20
- // Language
21
- const _ = Lang(lang);
22
-
23
- // Logic
24
- stats.stop();
25
- ---
26
- <nav class="post-paging" aria-label={ _(Translations.aria.paging) }>
27
- {page.url.prev
28
- ? <a href={ accelerator.urlFormatter.formatAddress(page.url.prev) }>{ _(Translations.articles.previous) }</a>
29
- : <span>{ _(Translations.articles.previous) }</span>}
30
- {pageLinks.map((link) => (
31
- <a href={ accelerator.urlFormatter.formatAddress(link.url) } aria-current={ link.ariaCurrent } class={ link.class }>{ link.title }</a>
32
- ))}
33
- {page.url.next
34
- ? <a href={ accelerator.urlFormatter.formatAddress(page.url.next) }>{ _(Translations.articles.next) }</a>
35
- : <span>{ _(Translations.articles.next) }</span>}
36
- </nav>
@@ -1,38 +0,0 @@
1
- ---
2
- import { PostOrdering, PostFiltering, Accelerator } from 'astro-accelerator-utils';
3
- import { SITE } from '@config';
4
-
5
- const accelerator = new Accelerator(SITE);
6
- const stats = new accelerator.statistics('accelerator/components/RecentlyUpdated.astro');
7
- stats.start();
8
-
9
- // Properties
10
- type Props = {
11
- lang: string;
12
- count: number;
13
- };
14
- const { lang, count } = Astro.props satisfies Props;
15
-
16
- // Logic
17
- const allPages = accelerator.posts.all();
18
- const pageCount = allPages.length;
19
- const pages = allPages
20
- .filter(PostFiltering.hasModDate)
21
- .filter(PostFiltering.isListable)
22
- .sort(PostOrdering.sortByModDateDesc)
23
- .slice(0, Math.min(count, pageCount));
24
-
25
- console.log('Recent Pages: ' + pageCount);
26
-
27
- stats.stop();
28
- ---
29
- <ul class="recent-updates">
30
- {pages.map((post) => (
31
- <li data-destination={ accelerator.urlFormatter.formatAddress(post.url) }>
32
- <a href={ accelerator.urlFormatter.formatAddress(post.url) }>{ accelerator.markdown.getTextFrom(post.frontmatter.title) }</a>
33
- <time datetime={ post.frontmatter.modDate.toString() }>
34
- { accelerator.dateFormatter.formatDate(post.frontmatter.modDate, lang) }
35
- </time>
36
- </li>
37
- ))}
38
- </ul>
@@ -1,87 +0,0 @@
1
- ---
2
- import { PostFiltering, PostOrdering, Accelerator } from 'astro-accelerator-utils';
3
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
4
- import { SITE } from '@config';
5
- import type { MarkdownInstance } from 'astro';
6
- import { getImageInfo } from '@util/custom-markdown.mjs'
7
-
8
- import AuthorsMini from '@components/AuthorsMini.astro';
9
-
10
- const accelerator = new Accelerator(SITE);
11
- const stats = new accelerator.statistics('accelerator/components/Related.astro');
12
- stats.start();
13
-
14
- // Properties
15
- type Props = {
16
- lang: string;
17
- frontmatter: Frontmatter
18
- headings: { depth: number; slug: string; text: string; }[];
19
- };
20
- const { lang, frontmatter, headings } = Astro.props satisfies Props;
21
-
22
- // Logic
23
- let relatedPosts: MarkdownInstance<Record<string, any>>[] = [];
24
- const parentCagory = (frontmatter.categories ?? [null])[0];
25
-
26
- if (parentCagory != null) {
27
- const allPages = accelerator.posts.all().filter(PostFiltering.isListable);
28
- const allPosts = allPages
29
- .filter(p => p.frontmatter.title != frontmatter.title && p.frontmatter.categories && p.frontmatter.categories.includes(parentCagory))
30
- .sort(PostOrdering.sortByPubDateDesc)
31
-
32
- // One "Most Recent" Post
33
- if (allPosts.length > 0) {
34
- relatedPosts.push(allPosts[0])
35
- }
36
-
37
- const olderPost = allPosts.slice(1).filter(p => p.frontmatter.pubDate < frontmatter.pubDate)
38
-
39
- // One "Older than current" Post
40
- if (olderPost.length > 0) {
41
- relatedPosts.push(olderPost[0])
42
- } else if (allPosts.length > 1) {
43
- relatedPosts.push(allPosts[1])
44
- }
45
- }
46
-
47
- const articles = relatedPosts.map(p => {
48
- return {
49
- url: p.url,
50
- frontmatter: p.frontmatter,
51
- img: p.frontmatter.bannerImage
52
- ? getImageInfo(p.frontmatter.bannerImage.src, '', SITE.images.listerSize)
53
- : null
54
- };
55
- });
56
-
57
- stats.stop();
58
- ---
59
- {articles.length > 0 &&
60
- <ul class="post-list anim-show-parent">
61
- {articles.map((post) => (
62
- <li class="list-item" data-destination={ accelerator.urlFormatter.formatAddress(post.url) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
63
- <article>
64
- <div class="list-item-image">
65
- {post.img && (
66
- <img
67
- srcset={ post.img.srcset }
68
- sizes={ post.img.sizes }
69
- src={ post.img.src }
70
- alt={ post.frontmatter.bannerImage.alt }
71
- class={ post.img.class }
72
- width={ post.img.metadata?.width }
73
- height={ post.img.metadata?.height }
74
- loading="lazy" />
75
- )}
76
- </div>
77
- <div class="list-item-content">
78
- <h3>
79
- <a href={ accelerator.urlFormatter.formatAddress(post.url) }>{ post.frontmatter.title }</a>
80
- </h3>
81
- <AuthorsMini lang={ lang } frontmatter={ post.frontmatter as Frontmatter } />
82
- </div>
83
- </article>
84
- </li>
85
- ))}
86
- </ul>
87
- }
@@ -1,29 +0,0 @@
1
- ---
2
- import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
3
- import { Translations, Lang } from '@util/Languages';
4
- import { Accelerator } from 'astro-accelerator-utils';
5
- import { SITE } from '@config';
6
-
7
- const accelerator = new Accelerator(SITE);
8
- const stats = new accelerator.statistics('accelerator/components/SkipLinks.astro');
9
- stats.start();
10
-
11
- // Properties
12
- type Props = {
13
- lang: string;
14
- frontmatter: Frontmatter
15
- headings: { depth: number; slug: string; text: string; }[];
16
- };
17
- const { lang } = Astro.props satisfies Props;
18
-
19
- // Language
20
- const _ = Lang(lang);
21
-
22
- // Logic
23
- stats.stop();
24
- ---
25
- <nav class="skip-links" aria-label={ _(Translations.aria.skiplinks) } id="site-top">
26
- <a href="#site-nav">{ _(Translations.skiplinks.skip_to_navigation) }</a>
27
- <a href="#site-main">{ _(Translations.skiplinks.skip_to_content) }</a>
28
- <a href="#site-footer">{ _(Translations.skiplinks.skip_to_footer) }</a>
29
- </nav>