astro-accelerator 0.0.64 → 0.0.66

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/astro.config.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import mdx from '@astrojs/mdx';
1
2
  import remarkDirective from 'remark-directive';
2
3
  import { defineConfig } from 'astro/config';
3
4
  import { attributeMarkdown, wrapTables } from '/src/themes/accelerator/utilities/custom-markdown.mjs';
@@ -5,6 +6,7 @@ import { attributeMarkdown, wrapTables } from '/src/themes/accelerator/utilities
5
6
  // https://astro.build/config
6
7
  export default defineConfig({
7
8
  site: 'https://astro.stevefenton.co.uk',
9
+ integrations: [mdx()],
8
10
  markdown: {
9
11
  remarkPlugins: [
10
12
  remarkDirective,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.64",
2
+ "version": "0.0.66",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -24,9 +24,10 @@
24
24
  "dts": "tsc ./tests/locate-content.js ./tests/locate-navigation.js ./tests/locate-search.js --allowJs --declaration --emitDeclarationOnly"
25
25
  },
26
26
  "dependencies": {
27
+ "@astrojs/mdx": "^0.17.0",
27
28
  "@squoosh/lib": "^0.4.0",
28
- "astro": "^2.0.1",
29
- "astro-accelerator-utils": "^0.2.20",
29
+ "astro": "^2.0.13",
30
+ "astro-accelerator-utils": "^0.2.23",
30
31
  "hast-util-from-selector": "^2.0.1",
31
32
  "remark-directive": "^2.0.1"
32
33
  },
package/src/config.ts CHANGED
@@ -3,6 +3,7 @@ import type { Site } from "astro-accelerator-utils/types/Site";
3
3
  const SITE: Site = {
4
4
  owner: 'Steve Fenton',
5
5
  url: 'https://astro.stevefenton.co.uk',
6
+ useTrailingUrlSlash: true,
6
7
  feedUrl: '/articles/feed.xml',
7
8
  title: 'Astro Accelerator',
8
9
  description: 'An Astro quick start project.',
@@ -37,7 +37,7 @@ const _ = Lang(lang);
37
37
  const accelerator = new Accelerator(SITE);
38
38
 
39
39
  export async function getData() {
40
- const sourcePosts = await Astro.glob('./**/*.md') as MarkdownInstance[];
40
+ const sourcePosts = await Astro.glob('./**/*.md', './**/*.mdx') as MarkdownInstance[];
41
41
  const posts = sourcePosts
42
42
  .filter(PostFiltering.isListable)
43
43
  .sort(PostOrdering.sortByPubDateDesc);
@@ -57,7 +57,7 @@ export async function getStaticPaths({ paginate }: any) {
57
57
  const pageLinks = accelerator.paging.links(SITE.pageLinks, page.lastPage, page.currentPage, page.url.current);
58
58
  ---
59
59
  <Default frontmatter={ frontmatter } headings={ headings }>
60
- <h2>{ _(Translations.articles.page_title).replace('{n}', page.currentPage.toString())}</h2>
60
+ <h2>{ _(Translations.articles.page_title).replace('{n}', page.currentPage.toString()) }</h2>
61
61
  <ArticleList lang={ lang } posts={ page.data } />
62
62
  <PagingLinks lang={ lang } page={ page } pageLinks={ pageLinks } />
63
63
  </Default>
@@ -6,7 +6,7 @@ import { Accelerator, PostFiltering } from 'astro-accelerator-utils';
6
6
 
7
7
  async function getData() {
8
8
  //@ts-ignore
9
- const allArticles = import.meta.glob('./**/*.md');
9
+ const allArticles = import.meta.glob('./**/*.md', './**/*.mdx');
10
10
 
11
11
  const accelerator = new Accelerator(SITE);
12
12
 
@@ -34,7 +34,7 @@ async function getData() {
34
34
  <entry>
35
35
  <title>${a.frontmatter.title ?? ''}</title>
36
36
  <link href="${ SITE.url + a.url }" />
37
- <id>${ SITE.url + accelerator.urlFormatter.addSlashToAddress(a.url) }</id>
37
+ <id>${ SITE.url + accelerator.urlFormatter.formatAddress(a.url) }</id>
38
38
  <published>${ a.frontmatter.pubDate }</published>
39
39
  <updated>${ a.frontmatter.pubDate ?? a.frontmatter.pubDate }</updated>
40
40
  <summary>${ a.frontmatter.description ?? '' }</summary>
@@ -55,7 +55,7 @@ type AuthorData = {
55
55
  }
56
56
 
57
57
  export async function getData() {
58
- const sourcePosts = await Astro.glob('../../**/*.md') satisfies MarkdownInstance[];
58
+ const sourcePosts = await Astro.glob(['../../**/*.md', '../../**/*.mdx']) satisfies MarkdownInstance[];
59
59
  const data: AuthorData = { posts: [], authors: []};
60
60
 
61
61
  data.posts = sourcePosts
@@ -98,7 +98,7 @@ const pageLinks = accelerator.paging.links(SITE.pageLinks, page.lastPage, page.c
98
98
  ---
99
99
  <Default frontmatter={ authorFrontmatter } headings={ headings }>
100
100
  <Fragment set:html={ authorText } />
101
- <h2>{ _(Translations.articles.page_title).replace('{n}', page.currentPage.toString())}</h2>
101
+ <h2>{ _(Translations.articles.page_title).replace('{n}', page.currentPage.toString()) }</h2>
102
102
  <ArticleList lang={ lang } posts={ page.data } />
103
103
  <PagingLinks lang={ lang } page={ page } pageLinks={ pageLinks } />
104
104
  </Default>
@@ -47,7 +47,7 @@ type CategoryData = {
47
47
 
48
48
  export async function getData() {
49
49
  // TODO: Replace with call to Posts.all()
50
- const sourcePosts = await Astro.glob('../../**/*.md') as MarkdownInstance[];
50
+ const sourcePosts = await Astro.glob(['../../**/*.md', '../../**/*.mdx']) as MarkdownInstance[];
51
51
 
52
52
  const data: CategoryData = { posts: [], categories: []};
53
53
 
@@ -28,7 +28,7 @@ const pages = missingBanner.sort(PostOrdering.sortByPubDateDesc).slice(0, Math.m
28
28
  </thead>
29
29
  {pages.map(p =>
30
30
  <tr>
31
- <td><a href={ accelerator.urlFormatter.addSlashToAddress(p.url) }>{ p.frontmatter.title }</a></td>
31
+ <td><a href={ accelerator.urlFormatter.formatAddress(p.url) }>{ p.frontmatter.title }</a></td>
32
32
  <td>{ p.frontmatter.pubDate }</td>
33
33
  <td>{ p.frontmatter.modDate }</td>
34
34
  </tr>
@@ -28,7 +28,7 @@ const pages = missingMeta.sort(PostOrdering.sortByPubDateDesc).slice(0, Math.min
28
28
  </thead>
29
29
  {pages.map(p =>
30
30
  <tr>
31
- <td><a href={ accelerator.urlFormatter.addSlashToAddress(p.url) }>{ p.frontmatter.title }</a></td>
31
+ <td><a href={ accelerator.urlFormatter.formatAddress(p.url) }>{ p.frontmatter.title }</a></td>
32
32
  <td>{ p.frontmatter.pubDate }</td>
33
33
  <td>{ p.frontmatter.modDate }</td>
34
34
  </tr>
@@ -28,7 +28,7 @@ const pages = missingMeta.slice(0, Math.min(50, pageCount));
28
28
  </thead>
29
29
  {pages.map(p =>
30
30
  <tr>
31
- <td><a href={ accelerator.urlFormatter.addSlashToAddress(p.url) }>{ p.frontmatter.title }</a></td>
31
+ <td><a href={ accelerator.urlFormatter.formatAddress(p.url) }>{ p.frontmatter.title }</a></td>
32
32
  <td>{ p.frontmatter.pubDate }</td>
33
33
  <td>{ p.frontmatter.modDate }</td>
34
34
  </tr>
@@ -29,7 +29,7 @@ const pages = allPages.sort(PostOrdering.sortByModDate).slice(0, Math.min(50, pa
29
29
  <tr>
30
30
  <td>
31
31
  {PostFiltering.isListable(p) && (
32
- <a href={ accelerator.urlFormatter.addSlashToAddress(p.url) }>{ p.frontmatter.title }</a>
32
+ <a href={ accelerator.urlFormatter.formatAddress(p.url) }>{ p.frontmatter.title }</a>
33
33
  )}
34
34
  {PostFiltering.isListable(p) == false && (
35
35
  <span>{ p.frontmatter.title }</span>
@@ -6,7 +6,7 @@ import { SITE } from '@config';
6
6
 
7
7
  const getData = async () => {
8
8
  //@ts-ignore
9
- const allPages = import.meta.glob('./**/*.md');
9
+ const allPages = import.meta.glob(['./**/*.md'), './**/*.mdx')]);
10
10
  const items = [];
11
11
 
12
12
  const accelerator = new Accelerator(SITE);
@@ -34,7 +34,7 @@ const getData = async () => {
34
34
  }),
35
35
  description: page.frontmatter.description ?? '',
36
36
  tags: page.frontmatter.tags ?? [],
37
- url: SITE.url + accelerator.urlFormatter.addSlashToAddress(url),
37
+ url: SITE.url + accelerator.urlFormatter.formatAddress(url),
38
38
  date: page.frontmatter.pubDate ?? ''
39
39
  });
40
40
  }
@@ -6,7 +6,7 @@ import { PostFiltering, Accelerator } from 'astro-accelerator-utils';
6
6
 
7
7
  async function getData() {
8
8
  //@ts-ignore
9
- const allPages = import.meta.glob('./**/*.md');
9
+ const allPages = import.meta.glob('./**/*.md', './**/*.mdx');
10
10
 
11
11
  const accelerator = new Accelerator(SITE);
12
12
  let pages = [];
@@ -15,7 +15,7 @@ async function getData() {
15
15
  const article: any = await allPages[path]();
16
16
  const addToSitemap = PostFiltering.showInSitemap(article);
17
17
 
18
- let url = accelerator.urlFormatter.addSlashToAddress(article.url);
18
+ let url = accelerator.urlFormatter.formatAddress(article.url);
19
19
 
20
20
  if (article.frontmatter.layout == 'src/layouts/Author.astro') {
21
21
  url += '1/';
@@ -46,7 +46,7 @@ type CacheData = {
46
46
  }
47
47
 
48
48
  export async function getData() {
49
- const sourcePosts = await Astro.glob('../../**/*.md') satisfies MarkdownInstance[];
49
+ const sourcePosts = await Astro.glob(['../../**/*.md', '../../**/*.mdx']) satisfies MarkdownInstance[];
50
50
 
51
51
  const data: CacheData = { posts: [], tags: []};
52
52
 
@@ -113,7 +113,7 @@ if (page.url.current != pageLinks[0].url) {
113
113
  }
114
114
  ---
115
115
  <Default frontmatter={ frontmatter } headings={ headings } breadcrumbs={ breadcrumbs }>
116
- <h2>{ _(Translations.articles.page_title).replace('{n}', page.currentPage.toString())}</h2>
116
+ <h2>{ _(Translations.articles.page_title).replace('{n}', page.currentPage.toString()) }</h2>
117
117
  <ArticleList lang={ lang } posts={ page.data } />
118
118
  <PagingLinks lang={ lang } page={ page } pageLinks={ pageLinks } />
119
119
  </Default>
@@ -59,7 +59,7 @@ function getLoadingAttribute() {
59
59
  ---
60
60
  <ul class="post-list anim-show-parent">
61
61
  {articles.map((post) => (
62
- <li class="list-item" data-destination={ accelerator.urlFormatter.addSlashToAddress(post.url) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
62
+ <li class="list-item" data-destination={ accelerator.urlFormatter.formatAddress(post.url) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
63
63
  <article>
64
64
  <div class="list-item-image">
65
65
  {post.img && (
@@ -76,7 +76,7 @@ function getLoadingAttribute() {
76
76
  </div>
77
77
  <div class="list-item-content">
78
78
  <h3>
79
- <a href={ accelerator.urlFormatter.addSlashToAddress(post.url) }>{ post.title }</a>
79
+ <a href={ accelerator.urlFormatter.formatAddress(post.url) }>{ post.title }</a>
80
80
  </h3>
81
81
  <AuthorsMini lang={ lang } frontmatter={ post.frontmatter satisfies Frontmatter } />
82
82
  </div>
@@ -41,9 +41,9 @@ const authorImage = authorList?.image?.src
41
41
  <div class="author-info">
42
42
  <span class="author-list">{ _(Translations.post.written_by) }
43
43
  {authorList.mainAuthor &&
44
- <span itemprop="author" itemscope itemtype="https://schema.org/Person"><a href={ accelerator.urlFormatter.addSlashToAddress(authorList.mainAuthor.url) + '1/' } itemprop="url"><span itemprop="name">{ authorList.mainAuthor.frontmatter.title }</span></a></span>
44
+ <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>
45
45
  }{authorList.contributors.map((writer) => (
46
- <span>, </span><span itemprop="contributor" itemscope itemtype="https://schema.org/Person"><a href={ accelerator.urlFormatter.addSlashToAddress(writer.url) + '1/' } itemprop="url"><span itemprop="name">{ writer.frontmatter.title }</span></a></span>
46
+ <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>
47
47
  ))}
48
48
  <br /><time datetime={ frontmatter.pubDate.toString() } itemprop="datePublished">
49
49
  { accelerator.dateFormatter.formatDate(frontmatter.pubDate, lang) }
@@ -28,13 +28,13 @@ let metaIndex = navPages.length;
28
28
  {navPages.map((page, index) => (
29
29
  <li property="itemListElement" typeof="ListItem">
30
30
  <meta property="position" content={ index.toString() } />
31
- <a property="item" typeof="WebPage" href={ accelerator.urlFormatter.addSlashToAddress(page.url) } aria-current={ page.ariaCurrent } rel={ page.rel }><span property="name">{ page.title }</span></a>
31
+ <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>
32
32
  </li>
33
33
  ))}
34
34
  {breadcrumbs && breadcrumbs.map( (crumb) => (
35
35
  <li property="itemListElement" typeof="ListItem">
36
36
  <meta property="position" content={ (metaIndex++).toString() } />
37
- <a property="item" typeof="WebPage" href={ accelerator.urlFormatter.addSlashToAddress(crumb.url) } aria-current={ crumb.ariaCurrent }><span property="name">{ crumb.title }</span></a>
37
+ <a property="item" typeof="WebPage" href={ accelerator.urlFormatter.formatAddress(crumb.url) } aria-current={ crumb.ariaCurrent }><span property="name">{ crumb.title }</span></a>
38
38
  </li>
39
39
  ))}
40
40
  </ol>
@@ -31,7 +31,7 @@ const search = accelerator.posts.all().filter(PostFiltering.isSearch).shift() ??
31
31
  </svg></a>
32
32
  <a href={ (SITE.subfolder ?? '') + '/' } class="site-title" translate="no">{ SITE.title }</a>
33
33
  {search != null &&
34
- <a href={ accelerator.urlFormatter.addSlashToAddress(search.url) } class="search-icon" title={ _(Translations.header.open_search) }><svg xmlns="http://www.w3.org/2000/svg"
34
+ <a href={ accelerator.urlFormatter.formatAddress(search.url) } class="search-icon" title={ _(Translations.header.open_search) }><svg xmlns="http://www.w3.org/2000/svg"
35
35
  width="40" height="40" viewBox="0 0 24 24" stroke-width="1"
36
36
  fill="none" stroke-linecap="round" stroke-linejoin="round">
37
37
  <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
@@ -18,7 +18,7 @@ const imageSrc = frontmatter.bannerImage?.src ?? OPEN_GRAPH.image.src;
18
18
  const imageAlt = frontmatter.bannerImage?.alt ?? OPEN_GRAPH.image.alt;
19
19
  const robots = frontmatter.robots ?? 'index, follow';
20
20
  const canonicalImageSrc = new URL(imageSrc, Astro.site);
21
- const canonicalURL = accelerator.urlFormatter.addSlashToUrl(new URL(Astro.url.pathname, Astro.site + SITE.subfolder));
21
+ const canonicalURL = accelerator.urlFormatter.formatUrl(new URL(Astro.url.pathname, Astro.site + SITE.subfolder));
22
22
  const socialTitle = await accelerator.markdown.getTextFrom(frontmatter.title);
23
23
  const title = `${ socialTitle } ${ ((frontmatter.titleAdditional) ? ` ${frontmatter.titleAdditional}` : '') } | ${ SITE.title }`;
24
24
  ---
@@ -15,7 +15,7 @@ const accelerator = new Accelerator(SITE);
15
15
  ---
16
16
  {(page.children.length == 0) && (
17
17
  <li>
18
- <a href={ accelerator.urlFormatter.addSlashToAddress(page.url) } aria-current={ page.ariaCurrent } rel={ page.rel }>{ page.title }</a>
18
+ <a href={ accelerator.urlFormatter.formatAddress(page.url) } aria-current={ page.ariaCurrent } rel={ page.rel }>{ page.title }</a>
19
19
  </li>
20
20
  )}
21
21
  {(page.children.length > 0) && (
@@ -21,12 +21,12 @@ const accelerator = new Accelerator(SITE);
21
21
  ---
22
22
  <nav class="post-paging" aria-label={ _(Translations.aria.paging) }>
23
23
  {page.url.prev
24
- ? <a href={ accelerator.urlFormatter.addSlashToAddress(page.url.prev) }>{ _(Translations.articles.previous) }</a>
24
+ ? <a href={ accelerator.urlFormatter.formatAddress(page.url.prev) }>{ _(Translations.articles.previous) }</a>
25
25
  : <span>{ _(Translations.articles.previous) }</span>}
26
26
  {pageLinks.map((link) => (
27
- <a href={ accelerator.urlFormatter.addSlashToAddress(link.url) } aria-current={ link.ariaCurrent } class={ link.class }>{ link.title }</a>
27
+ <a href={ accelerator.urlFormatter.formatAddress(link.url) } aria-current={ link.ariaCurrent } class={ link.class }>{ link.title }</a>
28
28
  ))}
29
29
  {page.url.next
30
- ? <a href={ accelerator.urlFormatter.addSlashToAddress(page.url.next) }>{ _(Translations.articles.next) }</a>
30
+ ? <a href={ accelerator.urlFormatter.formatAddress(page.url.next) }>{ _(Translations.articles.next) }</a>
31
31
  : <span>{ _(Translations.articles.next) }</span>}
32
32
  </nav>
@@ -55,7 +55,7 @@ const articles = relatedPosts.map(p => {
55
55
  {articles.length > 0 &&
56
56
  <ul class="post-list anim-show-parent">
57
57
  {articles.map((post) => (
58
- <li class="list-item" data-destination={ accelerator.urlFormatter.addSlashToAddress(post.url) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
58
+ <li class="list-item" data-destination={ accelerator.urlFormatter.formatAddress(post.url) } data-image={ (post.frontmatter.bannerImage?.src.length > 0).toString() }>
59
59
  <article>
60
60
  <div class="list-item-image">
61
61
  {post.img && (
@@ -72,7 +72,7 @@ const articles = relatedPosts.map(p => {
72
72
  </div>
73
73
  <div class="list-item-content">
74
74
  <h3>
75
- <a href={ accelerator.urlFormatter.addSlashToAddress(post.url) }>{ post.frontmatter.title }</a>
75
+ <a href={ accelerator.urlFormatter.formatAddress(post.url) }>{ post.frontmatter.title }</a>
76
76
  </h3>
77
77
  <AuthorsMini lang={ lang } frontmatter={ post.frontmatter satisfies Frontmatter } />
78
78
  </div>
@@ -1,6 +1,8 @@
1
1
  ---
2
2
  import type { Frontmatter } from 'astro-accelerator-utils/types/Frontmatter';
3
+ import { SITE } from '@config';
3
4
  import { Translations, Lang } from '@util/Languages';
5
+ import { Accelerator } from 'astro-accelerator-utils';
4
6
 
5
7
  // Properties
6
8
  type Props = {
@@ -16,7 +16,7 @@ const lang = frontmatter.lang ?? SITE.default.lang;
16
16
  const accelerator = new Accelerator(SITE);
17
17
  const redirectFrontmatter = {
18
18
  ...frontmatter,
19
- redirect: accelerator.urlFormatter.addSlashToAddress(Astro.request.url) + '1/'
19
+ redirect: accelerator.urlFormatter.formatAddress(Astro.request.url) + '1/'
20
20
  };
21
21
  ---
22
22
  <Redirect frontmatter={ redirectFrontmatter } headings={ headings } />
@@ -22,6 +22,8 @@ type Props = {
22
22
  }
23
23
  const { frontmatter, headings, breadcrumbs } = Astro.props satisfies Props;
24
24
 
25
+ console.log(headings);
26
+
25
27
  const lang = frontmatter.lang ?? SITE.default.lang;
26
28
  const textDirection = frontmatter.dir ?? SITE.default.dir;
27
29