@docusaurus/plugin-content-blog 0.0.0-4679 → 0.0.0-4680
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 -1
- package/lib/translations.js +7 -4
- package/package.json +9 -9
- package/src/blogUtils.ts +4 -4
- package/src/index.ts +2 -2
- package/src/translations.ts +9 -4
package/lib/blogUtils.js
CHANGED
|
@@ -76,7 +76,7 @@ function parseBlogFileName(blogSourceRelative) {
|
|
|
76
76
|
const date = new Date(`${dateString}Z`);
|
|
77
77
|
const slugDate = dateString.replace(/-/g, '/');
|
|
78
78
|
const slug = `/${slugDate}/${folder}${text}`;
|
|
79
|
-
return { date, text, slug };
|
|
79
|
+
return { date, text: text, slug };
|
|
80
80
|
}
|
|
81
81
|
const text = blogSourceRelative.replace(/(?:\/index)?\.mdx?$/, '');
|
|
82
82
|
const slug = `/${text}`;
|
package/lib/translations.js
CHANGED
|
@@ -14,8 +14,8 @@ function translateListPage(blogListPaginated, translations) {
|
|
|
14
14
|
items,
|
|
15
15
|
metadata: {
|
|
16
16
|
...metadata,
|
|
17
|
-
blogTitle: translations.title.
|
|
18
|
-
blogDescription: translations.description.
|
|
17
|
+
blogTitle: translations.title?.message ?? page.metadata.blogTitle,
|
|
18
|
+
blogDescription: translations.description?.message ?? page.metadata.blogDescription,
|
|
19
19
|
},
|
|
20
20
|
};
|
|
21
21
|
});
|
|
@@ -43,10 +43,13 @@ function getTranslationFiles(options) {
|
|
|
43
43
|
}
|
|
44
44
|
exports.getTranslationFiles = getTranslationFiles;
|
|
45
45
|
function translateContent(content, translationFiles) {
|
|
46
|
-
|
|
46
|
+
if (translationFiles.length === 0) {
|
|
47
|
+
return content;
|
|
48
|
+
}
|
|
49
|
+
const { content: optionsTranslations } = translationFiles[0];
|
|
47
50
|
return {
|
|
48
51
|
...content,
|
|
49
|
-
blogSidebarTitle: optionsTranslations['sidebar.title'].
|
|
52
|
+
blogSidebarTitle: optionsTranslations['sidebar.title']?.message ?? content.blogSidebarTitle,
|
|
50
53
|
blogListPaginated: translateListPage(content.blogListPaginated, optionsTranslations),
|
|
51
54
|
};
|
|
52
55
|
}
|
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-4680",
|
|
4
4
|
"description": "Blog plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-blog.d.ts",
|
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/logger": "0.0.0-
|
|
23
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
24
|
-
"@docusaurus/utils": "0.0.0-
|
|
25
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
26
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
21
|
+
"@docusaurus/core": "0.0.0-4680",
|
|
22
|
+
"@docusaurus/logger": "0.0.0-4680",
|
|
23
|
+
"@docusaurus/mdx-loader": "0.0.0-4680",
|
|
24
|
+
"@docusaurus/utils": "0.0.0-4680",
|
|
25
|
+
"@docusaurus/utils-common": "0.0.0-4680",
|
|
26
|
+
"@docusaurus/utils-validation": "0.0.0-4680",
|
|
27
27
|
"cheerio": "^1.0.0-rc.10",
|
|
28
28
|
"feed": "^4.2.2",
|
|
29
29
|
"fs-extra": "^10.0.1",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"webpack": "^5.69.1"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@docusaurus/types": "0.0.0-
|
|
38
|
+
"@docusaurus/types": "0.0.0-4680",
|
|
39
39
|
"escape-string-regexp": "^4.0.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=14"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "367835b86a28dea97e2addba03291438a5f813f8"
|
|
49
49
|
}
|
package/src/blogUtils.ts
CHANGED
|
@@ -139,10 +139,10 @@ export function parseBlogFileName(
|
|
|
139
139
|
if (dateFilenameMatch) {
|
|
140
140
|
const {folder, text, date: dateString} = dateFilenameMatch.groups!;
|
|
141
141
|
// Always treat dates as UTC by adding the `Z`
|
|
142
|
-
const date = new Date(`${dateString}Z`);
|
|
143
|
-
const slugDate = dateString
|
|
144
|
-
const slug = `/${slugDate}/${folder}${text}`;
|
|
145
|
-
return {date, text
|
|
142
|
+
const date = new Date(`${dateString!}Z`);
|
|
143
|
+
const slugDate = dateString!.replace(/-/g, '/');
|
|
144
|
+
const slug = `/${slugDate}/${folder!}${text!}`;
|
|
145
|
+
return {date, text: text!, slug};
|
|
146
146
|
}
|
|
147
147
|
const text = blogSourceRelative.replace(/(?:\/index)?\.mdx?$/, '');
|
|
148
148
|
const slug = `/${text}`;
|
package/src/index.ts
CHANGED
|
@@ -307,7 +307,7 @@ export default async function pluginContentBlog(
|
|
|
307
307
|
({
|
|
308
308
|
content: {
|
|
309
309
|
__import: true,
|
|
310
|
-
path: blogItemsToMetadata[postID]
|
|
310
|
+
path: blogItemsToMetadata[postID]!.source,
|
|
311
311
|
query: {
|
|
312
312
|
truncated: true,
|
|
313
313
|
},
|
|
@@ -359,7 +359,7 @@ export default async function pluginContentBlog(
|
|
|
359
359
|
modules: {
|
|
360
360
|
sidebar: aliasedSource(sidebarProp),
|
|
361
361
|
items: items.map((postID) => {
|
|
362
|
-
const blogPostMetadata = blogItemsToMetadata[postID]
|
|
362
|
+
const blogPostMetadata = blogItemsToMetadata[postID]!;
|
|
363
363
|
return {
|
|
364
364
|
content: {
|
|
365
365
|
__import: true,
|
package/src/translations.ts
CHANGED
|
@@ -19,8 +19,9 @@ function translateListPage(
|
|
|
19
19
|
items,
|
|
20
20
|
metadata: {
|
|
21
21
|
...metadata,
|
|
22
|
-
blogTitle: translations.title.
|
|
23
|
-
blogDescription:
|
|
22
|
+
blogTitle: translations.title?.message ?? page.metadata.blogTitle,
|
|
23
|
+
blogDescription:
|
|
24
|
+
translations.description?.message ?? page.metadata.blogDescription,
|
|
24
25
|
},
|
|
25
26
|
};
|
|
26
27
|
});
|
|
@@ -52,10 +53,14 @@ export function translateContent(
|
|
|
52
53
|
content: BlogContent,
|
|
53
54
|
translationFiles: TranslationFiles,
|
|
54
55
|
): BlogContent {
|
|
55
|
-
|
|
56
|
+
if (translationFiles.length === 0) {
|
|
57
|
+
return content;
|
|
58
|
+
}
|
|
59
|
+
const {content: optionsTranslations} = translationFiles[0]!;
|
|
56
60
|
return {
|
|
57
61
|
...content,
|
|
58
|
-
blogSidebarTitle:
|
|
62
|
+
blogSidebarTitle:
|
|
63
|
+
optionsTranslations['sidebar.title']?.message ?? content.blogSidebarTitle,
|
|
59
64
|
blogListPaginated: translateListPage(
|
|
60
65
|
content.blogListPaginated,
|
|
61
66
|
optionsTranslations,
|