astro-accelerator 5.9.16 → 5.9.18
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.
|
|
2
|
+
"version": "5.9.18",
|
|
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.
|
|
37
|
-
"astro": "^5.
|
|
38
|
-
"astro-accelerator-utils": "^0.3.
|
|
36
|
+
"@astrojs/mdx": "^4.3.3",
|
|
37
|
+
"astro": "^5.12.9",
|
|
38
|
+
"astro-accelerator-utils": "^0.3.50",
|
|
39
39
|
"cspell": "^8.19.4",
|
|
40
|
-
"csv": "^6.4.
|
|
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.
|
|
51
|
+
"@playwright/test": "^1.54.2"
|
|
52
52
|
},
|
|
53
53
|
"files": [
|
|
54
54
|
".npmrc",
|
|
@@ -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]
|
|
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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This javascript file comes from Astro Accelerator
|
|
3
|
+
* Edits will be overwritten if you change the file locally
|
|
4
|
+
*
|
|
5
|
+
* @format
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
import path from 'path';
|
|
10
|
+
|
|
11
|
+
const workingDirectory = process.cwd();
|
|
12
|
+
|
|
13
|
+
const imageSize = await import(
|
|
14
|
+
'file://' + path.join(workingDirectory, 'src/data/image-size.mjs')
|
|
15
|
+
);
|
|
16
|
+
const imageModule = await import(
|
|
17
|
+
'file://' + path.join(workingDirectory, 'src/data/images.mjs')
|
|
18
|
+
);
|
|
19
|
+
const size = imageSize.size;
|
|
20
|
+
const imagePaths = imageModule.imagePaths;
|
|
21
|
+
|
|
22
|
+
const imagePath = path.join('dist', imagePaths.src);
|
|
23
|
+
const outputPath = path.join('dist', imagePaths.dest);
|
|
24
|
+
const imageDirectory = path.join(workingDirectory, imagePath);
|
|
25
|
+
|
|
26
|
+
const filesToProcess = [];
|
|
27
|
+
|
|
28
|
+
function getDestinationFilePathless(source, s) {
|
|
29
|
+
let destination = path.join(
|
|
30
|
+
workingDirectory,
|
|
31
|
+
outputPath,
|
|
32
|
+
s.toString(),
|
|
33
|
+
source
|
|
34
|
+
);
|
|
35
|
+
destination = destination.replace(path.parse(destination).ext, '');
|
|
36
|
+
return destination;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function recurseFiles(directory) {
|
|
40
|
+
const f = await fs.promises.readdir(path.join(imageDirectory, directory), {
|
|
41
|
+
withFileTypes: true,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
for (const file of f) {
|
|
45
|
+
if (file.isDirectory()) {
|
|
46
|
+
const nextDirectory = path.join(directory, file.name);
|
|
47
|
+
await recurseFiles(nextDirectory);
|
|
48
|
+
} else {
|
|
49
|
+
const ext = path.parse(file.name).ext;
|
|
50
|
+
|
|
51
|
+
switch (ext) {
|
|
52
|
+
case '.jpg':
|
|
53
|
+
case '.jpeg':
|
|
54
|
+
case '.png':
|
|
55
|
+
case '.webp':
|
|
56
|
+
const sourcePath = path.join(directory, file.name);
|
|
57
|
+
|
|
58
|
+
const webP = sourcePath.replace(
|
|
59
|
+
/.jpg$|.jpeg$|.png$/,
|
|
60
|
+
'.webp'
|
|
61
|
+
);
|
|
62
|
+
const info = {
|
|
63
|
+
path: sourcePath,
|
|
64
|
+
webP: webP,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Only processes images where there is no json metadata file
|
|
68
|
+
const metaPath = path.join(
|
|
69
|
+
workingDirectory,
|
|
70
|
+
imagePath,
|
|
71
|
+
sourcePath + '.json'
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
if (fs.existsSync(metaPath)) {
|
|
76
|
+
const data = fs.readFileSync(metaPath, 'utf8');
|
|
77
|
+
const jsonData = JSON.parse(data);
|
|
78
|
+
const date90DaysAgo = new Date(
|
|
79
|
+
Date.now() - 14 /* <- days */ * 24 * 60 * 60 * 1000
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
//console.log('Checking:', metaPath);
|
|
83
|
+
|
|
84
|
+
if (jsonData.updated && new Date(jsonData.updated) < date90DaysAgo) {
|
|
85
|
+
console.log('Processing:', metaPath);
|
|
86
|
+
filesToProcess.push(info);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
await recurseFiles('');
|
|
97
|
+
|
|
98
|
+
for (const file of filesToProcess) {
|
|
99
|
+
const source = path.join(imageDirectory, file.path);
|
|
100
|
+
const destination = getDestinationFilePathless(file.path, 'x');
|
|
101
|
+
|
|
102
|
+
const ext = path.parse(source).ext;
|
|
103
|
+
|
|
104
|
+
// Delete original file
|
|
105
|
+
fs.unlinkSync(source);
|
|
106
|
+
|
|
107
|
+
// Delete the fallback file
|
|
108
|
+
switch (ext) {
|
|
109
|
+
case '.png':
|
|
110
|
+
fs.unlinkSync(destination + '.png');
|
|
111
|
+
break;
|
|
112
|
+
case '.jpg':
|
|
113
|
+
case '.jpeg':
|
|
114
|
+
fs.unlinkSync(destination + '.jpg');
|
|
115
|
+
break;
|
|
116
|
+
case '.webp':
|
|
117
|
+
fs.unlinkSync(destination + '.webp');
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const metaFile = source + '.json';
|
|
122
|
+
|
|
123
|
+
// Delete metadata file
|
|
124
|
+
fs.unlinkSync(metaFile);
|
|
125
|
+
|
|
126
|
+
// Delete resized images
|
|
127
|
+
for (const key in size) {
|
|
128
|
+
const resizeDestination = getDestinationFilePathless(
|
|
129
|
+
file.path,
|
|
130
|
+
size[key]
|
|
131
|
+
);
|
|
132
|
+
|
|
133
|
+
fs.unlinkSync(resizeDestination + '.webp');
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -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';
|