@docusaurus/plugin-content-blog 0.0.0-5846 → 0.0.0-5848
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/lib/blogUtils.js +1 -18
- package/package.json +9 -9
- package/src/blogUtils.ts +2 -26
- package/src/plugin-content-blog.d.ts +0 -5
package/lib/blogUtils.js
CHANGED
|
@@ -96,21 +96,6 @@ function parseBlogFileName(blogSourceRelative) {
|
|
|
96
96
|
return { date: undefined, text, slug };
|
|
97
97
|
}
|
|
98
98
|
exports.parseBlogFileName = parseBlogFileName;
|
|
99
|
-
function formatBlogPostDate(locale, date, calendar) {
|
|
100
|
-
try {
|
|
101
|
-
return new Intl.DateTimeFormat(locale, {
|
|
102
|
-
day: 'numeric',
|
|
103
|
-
month: 'long',
|
|
104
|
-
year: 'numeric',
|
|
105
|
-
timeZone: 'UTC',
|
|
106
|
-
calendar,
|
|
107
|
-
}).format(date);
|
|
108
|
-
}
|
|
109
|
-
catch (err) {
|
|
110
|
-
logger_1.default.error `Can't format blog post date "${String(date)}"`;
|
|
111
|
-
throw err;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
99
|
async function parseBlogPostMarkdownFile({ filePath, parseFrontMatter, }) {
|
|
115
100
|
const fileContent = await fs_extra_1.default.readFile(filePath, 'utf-8');
|
|
116
101
|
try {
|
|
@@ -165,7 +150,7 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
|
|
|
165
150
|
return parsedBlogFileName.date;
|
|
166
151
|
}
|
|
167
152
|
try {
|
|
168
|
-
const result = (0, utils_1.getFileCommitDate)(blogSourceAbsolute, {
|
|
153
|
+
const result = await (0, utils_1.getFileCommitDate)(blogSourceAbsolute, {
|
|
169
154
|
age: 'oldest',
|
|
170
155
|
includeAuthor: false,
|
|
171
156
|
});
|
|
@@ -177,7 +162,6 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
|
|
|
177
162
|
}
|
|
178
163
|
}
|
|
179
164
|
const date = await getDate();
|
|
180
|
-
const formattedDate = formatBlogPostDate(i18n.currentLocale, date, i18n.localeConfigs[i18n.currentLocale].calendar);
|
|
181
165
|
const title = frontMatter.title ?? contentTitle ?? parsedBlogFileName.text;
|
|
182
166
|
const description = frontMatter.description ?? excerpt ?? '';
|
|
183
167
|
const slug = frontMatter.slug ?? parsedBlogFileName.slug;
|
|
@@ -220,7 +204,6 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
|
|
|
220
204
|
title,
|
|
221
205
|
description,
|
|
222
206
|
date,
|
|
223
|
-
formattedDate,
|
|
224
207
|
tags: (0, utils_1.normalizeFrontMatterTags)(tagsBasePath, frontMatter.tags),
|
|
225
208
|
readingTime: showReadingTime
|
|
226
209
|
? options.readingTime({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-blog",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5848",
|
|
4
4
|
"description": "Blog plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-blog.d.ts",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
},
|
|
32
32
|
"license": "MIT",
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@docusaurus/core": "0.0.0-
|
|
35
|
-
"@docusaurus/logger": "0.0.0-
|
|
36
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
37
|
-
"@docusaurus/types": "0.0.0-
|
|
38
|
-
"@docusaurus/utils": "0.0.0-
|
|
39
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
40
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
34
|
+
"@docusaurus/core": "0.0.0-5848",
|
|
35
|
+
"@docusaurus/logger": "0.0.0-5848",
|
|
36
|
+
"@docusaurus/mdx-loader": "0.0.0-5848",
|
|
37
|
+
"@docusaurus/types": "0.0.0-5848",
|
|
38
|
+
"@docusaurus/utils": "0.0.0-5848",
|
|
39
|
+
"@docusaurus/utils-common": "0.0.0-5848",
|
|
40
|
+
"@docusaurus/utils-validation": "0.0.0-5848",
|
|
41
41
|
"cheerio": "^1.0.0-rc.12",
|
|
42
42
|
"feed": "^4.2.2",
|
|
43
43
|
"fs-extra": "^11.1.1",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"engines": {
|
|
57
57
|
"node": ">=18.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "e96ac1a4796aa654d6a6c200f785fb4059619718"
|
|
60
60
|
}
|
package/src/blogUtils.ts
CHANGED
|
@@ -164,25 +164,6 @@ export function parseBlogFileName(
|
|
|
164
164
|
return {date: undefined, text, slug};
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
function formatBlogPostDate(
|
|
168
|
-
locale: string,
|
|
169
|
-
date: Date,
|
|
170
|
-
calendar: string,
|
|
171
|
-
): string {
|
|
172
|
-
try {
|
|
173
|
-
return new Intl.DateTimeFormat(locale, {
|
|
174
|
-
day: 'numeric',
|
|
175
|
-
month: 'long',
|
|
176
|
-
year: 'numeric',
|
|
177
|
-
timeZone: 'UTC',
|
|
178
|
-
calendar,
|
|
179
|
-
}).format(date);
|
|
180
|
-
} catch (err) {
|
|
181
|
-
logger.error`Can't format blog post date "${String(date)}"`;
|
|
182
|
-
throw err;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
167
|
async function parseBlogPostMarkdownFile({
|
|
187
168
|
filePath,
|
|
188
169
|
parseFrontMatter,
|
|
@@ -277,10 +258,11 @@ async function processBlogSourceFile(
|
|
|
277
258
|
}
|
|
278
259
|
|
|
279
260
|
try {
|
|
280
|
-
const result = getFileCommitDate(blogSourceAbsolute, {
|
|
261
|
+
const result = await getFileCommitDate(blogSourceAbsolute, {
|
|
281
262
|
age: 'oldest',
|
|
282
263
|
includeAuthor: false,
|
|
283
264
|
});
|
|
265
|
+
|
|
284
266
|
return result.date;
|
|
285
267
|
} catch (err) {
|
|
286
268
|
logger.warn(err);
|
|
@@ -289,11 +271,6 @@ async function processBlogSourceFile(
|
|
|
289
271
|
}
|
|
290
272
|
|
|
291
273
|
const date = await getDate();
|
|
292
|
-
const formattedDate = formatBlogPostDate(
|
|
293
|
-
i18n.currentLocale,
|
|
294
|
-
date,
|
|
295
|
-
i18n.localeConfigs[i18n.currentLocale]!.calendar,
|
|
296
|
-
);
|
|
297
274
|
|
|
298
275
|
const title = frontMatter.title ?? contentTitle ?? parsedBlogFileName.text;
|
|
299
276
|
const description = frontMatter.description ?? excerpt ?? '';
|
|
@@ -348,7 +325,6 @@ async function processBlogSourceFile(
|
|
|
348
325
|
title,
|
|
349
326
|
description,
|
|
350
327
|
date,
|
|
351
|
-
formattedDate,
|
|
352
328
|
tags: normalizeFrontMatterTags(tagsBasePath, frontMatter.tags),
|
|
353
329
|
readingTime: showReadingTime
|
|
354
330
|
? options.readingTime({
|
|
@@ -192,11 +192,6 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the
|
|
|
192
192
|
* into a string.
|
|
193
193
|
*/
|
|
194
194
|
readonly date: Date;
|
|
195
|
-
/**
|
|
196
|
-
* Publish date formatted according to the locale, so that the client can
|
|
197
|
-
* render the date regardless of the existence of `Intl.DateTimeFormat`.
|
|
198
|
-
*/
|
|
199
|
-
readonly formattedDate: string;
|
|
200
195
|
/** Full link including base URL. */
|
|
201
196
|
readonly permalink: string;
|
|
202
197
|
/**
|