astro-accelerator 5.9.15 → 5.9.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.9.15",
2
+ "version": "5.9.17",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -33,11 +33,11 @@
33
33
  "dts": "tsc ./tests/locate-content.js ./tests/locate-navigation.js ./tests/locate-search.js --allowJs --declaration --emitDeclarationOnly"
34
34
  },
35
35
  "dependencies": {
36
- "@astrojs/mdx": "^4.3.0",
37
- "astro": "^5.11.0",
38
- "astro-accelerator-utils": "^0.3.48",
36
+ "@astrojs/mdx": "^4.3.3",
37
+ "astro": "^5.12.8",
38
+ "astro-accelerator-utils": "^0.3.49",
39
39
  "cspell": "^8.19.4",
40
- "csv": "^6.4.0",
40
+ "csv": "^6.4.1",
41
41
  "glob": "^11.0.3",
42
42
  "hast-util-from-selector": "^3.0.1",
43
43
  "html-to-text": "^9.0.5",
@@ -48,7 +48,7 @@
48
48
  "sharp": "^0.33.5"
49
49
  },
50
50
  "devDependencies": {
51
- "@playwright/test": "^1.54.0"
51
+ "@playwright/test": "^1.54.2"
52
52
  },
53
53
  "files": [
54
54
  ".npmrc",
@@ -61,6 +61,7 @@
61
61
  "src/pages/404.md",
62
62
  "src/pages/index.md",
63
63
  "src/pages/search.md",
64
+ "src/pages/rss.xml.ts",
64
65
  "src/pages/articles/*.astro",
65
66
  "src/pages/articles/*.ts",
66
67
  "src/pages/authors/**/*.astro",
@@ -79,6 +79,12 @@ export async function getData() {
79
79
  }
80
80
  });
81
81
  });
82
+
83
+ sourcePosts.filter(PostFiltering.isAuthor).forEach((p) => {
84
+ if (!data.authors.includes(p.frontmatter.id)) {
85
+ data.authors.push(p.frontmatter.id);
86
+ }
87
+ });
82
88
 
83
89
  return data;
84
90
  }
@@ -93,7 +99,7 @@ export async function getStaticPaths({ paginate }: any) {
93
99
  });
94
100
  return paginate(filtered, {
95
101
  params: { author: a.toLowerCase() },
96
- props: { pubDate: filtered[0].frontmatter.pubDate },
102
+ props: { pubDate: filtered[0]?.frontmatter.pubDate ?? new Date() },
97
103
  pageSize: SITE.pageSize
98
104
  });
99
105
  }).flat();
@@ -146,4 +152,4 @@ stats.stop();
146
152
  </div>
147
153
  <ArticleList lang={ lang } posts={ page.data } />
148
154
  <PagingLinks lang={ lang } page={ page } pageLinks={ pageLinks } />
149
- </Default>
155
+ </Default>
@@ -0,0 +1,113 @@
1
+ /** @format */
2
+
3
+ // warning: This file is overwritten by Astro Accelerator
4
+
5
+ // Generates an ATOM feed across the whole site with full content
6
+ import { SITE } from '@config';
7
+ import {
8
+ Accelerator,
9
+ PostFiltering,
10
+ PostOrdering,
11
+ } from 'astro-accelerator-utils';
12
+ import type { MarkdownInstance } from 'astro-accelerator-utils/types/Astro';
13
+
14
+ type Frontmatter = MarkdownInstance['frontmatter'];
15
+
16
+ async function getData() {
17
+ //@ts-ignore
18
+ const allArticles = import.meta.glob(['./**/*.md', './**/*.mdx']);
19
+
20
+ const accelerator = new Accelerator(SITE);
21
+ const stats = new accelerator.statistics('pages/articles/feed.xml');
22
+ stats.start();
23
+
24
+ let articles: MarkdownInstance[] = [];
25
+ const authors = accelerator.posts.all().filter(PostFiltering.isAuthor);
26
+ const contentItems: { [index: string]: string } = {};
27
+
28
+ for (const path in allArticles) {
29
+ const article: any = await allArticles[path]();
30
+
31
+ const filtered = [article]
32
+ .filter(PostFiltering.isListable)
33
+ .filter(PostFiltering.notAuthor)
34
+ .filter(PostFiltering.notSearch);
35
+
36
+ if (filtered.length === 0) {
37
+ continue;
38
+ }
39
+
40
+ if (typeof article.compiledContent !== 'function') {
41
+ continue;
42
+ }
43
+
44
+ const content = await article.compiledContent();
45
+ contentItems[article.url] = content;
46
+
47
+ article.frontmatter.title = await accelerator.markdown.getTextFrom(
48
+ article.frontmatter?.title
49
+ );
50
+
51
+ articles.push({
52
+ url: article.url,
53
+ frontmatter: article.frontmatter,
54
+ } as MarkdownInstance);
55
+ }
56
+
57
+ function getAuthorName(frontmatter: Frontmatter): string {
58
+ if (frontmatter.authors && frontmatter.authors.length > 0) {
59
+ const author = authors.filter(
60
+ (a) => a.frontmatter.id == frontmatter.authors?.[0]
61
+ )[0];
62
+
63
+ if (author?.frontmatter?.title) {
64
+ return author.frontmatter.title + ', Octopus Deploy';
65
+ }
66
+ }
67
+
68
+ return 'Octopus Deploy';
69
+ }
70
+
71
+ const limit = SITE.rssLimit ?? 20;
72
+ const items = articles
73
+ .sort(PostOrdering.sortByModDateDesc)
74
+ .slice(0, limit)
75
+ .map(
76
+ (a) => `
77
+ <entry>
78
+ <title>${a.frontmatter.title ?? ''}</title>
79
+ <link href="${SITE.url + a.url}" />
80
+ <id>${SITE.url + accelerator.urlFormatter.formatAddress(a.url)}</id>
81
+ <published>${a.frontmatter.pubDate}</published>
82
+ <updated>${a.frontmatter.modDate ?? a.frontmatter.pubDate}</updated>
83
+ <summary>${a.frontmatter.description ?? ''}</summary>
84
+ <author>
85
+ <name>${getAuthorName(a.frontmatter)}</name>
86
+ </author>
87
+ <content type="html"><![CDATA[${contentItems[a.url] ?? ''}]]></content>
88
+ </entry>`
89
+ );
90
+
91
+ stats.stop();
92
+
93
+ return new Response(
94
+ `<?xml version="1.0" encoding="utf-8"?>
95
+ <feed xmlns="http://www.w3.org/2005/Atom">
96
+ <title>${SITE.title}</title>
97
+ <subtitle>${SITE.description}</subtitle>
98
+ <link href="${SITE.url}${SITE.feedUrl}" rel="self" />
99
+ <link href="${SITE.url}" />
100
+ <id>${SITE.url}${SITE.feedUrl}</id>
101
+ <updated>${articles[0].frontmatter.pubDate}</updated>
102
+ ${items.join('')}
103
+ </feed>`,
104
+ {
105
+ status: 200,
106
+ headers: {
107
+ 'Content-Type': 'application/xml',
108
+ },
109
+ }
110
+ );
111
+ }
112
+
113
+ export const GET = getData;
@@ -88,19 +88,22 @@ async function recurseFiles(directory) {
88
88
  if (!fs.existsSync(metaPath)) {
89
89
  console.log('Processing:', metaPath);
90
90
  filesToProcess.push(info);
91
+ } else {
92
+ const data = fs.readFileSync(metaPath, 'utf8');
93
+ const jsonData = JSON.parse(data);
94
+ const date90DaysAgo = new Date(
95
+ Date.now() - 90 * 24 * 60 * 60 * 1000
96
+ );
97
+
98
+ if (
99
+ !jsonData.updated ||
100
+ new Date(jsonData.updated) < date90DaysAgo
101
+ ) {
102
+ console.log('Processing:', metaPath);
103
+ filesToProcess.push(info);
104
+ }
91
105
  }
92
106
 
93
- // The code below uses modified dates (and will update more images than the above)
94
- // const fullPath = path.join(imageDirectory, info.path);
95
- // const modified = fs.statSync(fullPath).mtime;
96
-
97
- // const destinationModified = fs.existsSync(fullDestination)
98
- // ? fs.statSync(fullDestination).mtime
99
- // : new Date(0);
100
-
101
- // if (destinationModified < modified) {
102
- // filesToProcess.push(info);
103
- // }
104
107
  break;
105
108
  }
106
109
  }
@@ -141,6 +144,7 @@ for (const file of filesToProcess) {
141
144
  width: info.width,
142
145
  height: info.height,
143
146
  sizeInBytes: info.size,
147
+ updated: new Date().toISOString(),
144
148
  };
145
149
 
146
150
  const metaFile = source + '.json';