@docusaurus/plugin-content-blog 0.0.0-4608 → 0.0.0-4609
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 +12 -15
- package/package.json +9 -9
- package/src/blogUtils.ts +13 -17
package/lib/blogUtils.js
CHANGED
|
@@ -11,7 +11,7 @@ const tslib_1 = require("tslib");
|
|
|
11
11
|
const fs_extra_1 = (0, tslib_1.__importDefault)(require("fs-extra"));
|
|
12
12
|
const path_1 = (0, tslib_1.__importDefault)(require("path"));
|
|
13
13
|
const reading_time_1 = (0, tslib_1.__importDefault)(require("reading-time"));
|
|
14
|
-
const lodash_1 = require("lodash");
|
|
14
|
+
const lodash_1 = (0, tslib_1.__importDefault)(require("lodash"));
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
const blogFrontMatter_1 = require("./blogFrontMatter");
|
|
17
17
|
const authors_1 = require("./authors");
|
|
@@ -21,7 +21,7 @@ function truncate(fileString, truncateMarker) {
|
|
|
21
21
|
}
|
|
22
22
|
exports.truncate = truncate;
|
|
23
23
|
function getSourceToPermalink(blogPosts) {
|
|
24
|
-
return (
|
|
24
|
+
return Object.fromEntries(blogPosts.map(({ metadata: { source, permalink } }) => [source, permalink]));
|
|
25
25
|
}
|
|
26
26
|
exports.getSourceToPermalink = getSourceToPermalink;
|
|
27
27
|
function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription, postsPerPageOption, }) {
|
|
@@ -55,19 +55,16 @@ function paginateBlogPosts({ blogPosts, basePageUrl, blogTitle, blogDescription,
|
|
|
55
55
|
exports.paginateBlogPosts = paginateBlogPosts;
|
|
56
56
|
function getBlogTags({ blogPosts, ...params }) {
|
|
57
57
|
const groups = (0, utils_1.groupTaggedItems)(blogPosts, (blogPost) => blogPost.metadata.tags);
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}),
|
|
69
|
-
};
|
|
70
|
-
});
|
|
58
|
+
return lodash_1.default.mapValues(groups, ({ tag, items: tagBlogPosts }) => ({
|
|
59
|
+
name: tag.label,
|
|
60
|
+
items: tagBlogPosts.map((item) => item.id),
|
|
61
|
+
permalink: tag.permalink,
|
|
62
|
+
pages: paginateBlogPosts({
|
|
63
|
+
blogPosts: tagBlogPosts,
|
|
64
|
+
basePageUrl: tag.permalink,
|
|
65
|
+
...params,
|
|
66
|
+
}),
|
|
67
|
+
}));
|
|
71
68
|
}
|
|
72
69
|
exports.getBlogTags = getBlogTags;
|
|
73
70
|
const DATE_FILENAME_REGEX = /^(?<folder>.*)(?<date>\d{4}[-/]\d{1,2}[-/]\d{1,2})[-/]?(?<text>.*?)(?:\/index)?.mdx?$/;
|
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-4609",
|
|
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-4609",
|
|
22
|
+
"@docusaurus/logger": "0.0.0-4609",
|
|
23
|
+
"@docusaurus/mdx-loader": "0.0.0-4609",
|
|
24
|
+
"@docusaurus/utils": "0.0.0-4609",
|
|
25
|
+
"@docusaurus/utils-common": "0.0.0-4609",
|
|
26
|
+
"@docusaurus/utils-validation": "0.0.0-4609",
|
|
27
27
|
"cheerio": "^1.0.0-rc.10",
|
|
28
28
|
"feed": "^4.2.2",
|
|
29
29
|
"fs-extra": "^10.0.0",
|
|
@@ -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-4609",
|
|
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": "398a24ae6b46221f1b07e23573affd1641861431"
|
|
49
49
|
}
|
package/src/blogUtils.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import readingTime from 'reading-time';
|
|
11
|
-
import
|
|
11
|
+
import _ from 'lodash';
|
|
12
12
|
import type {
|
|
13
13
|
BlogPost,
|
|
14
14
|
BlogContentPaths,
|
|
@@ -46,9 +46,8 @@ export function truncate(fileString: string, truncateMarker: RegExp): string {
|
|
|
46
46
|
export function getSourceToPermalink(
|
|
47
47
|
blogPosts: BlogPost[],
|
|
48
48
|
): Record<string, string> {
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
(v) => v.metadata.permalink,
|
|
49
|
+
return Object.fromEntries(
|
|
50
|
+
blogPosts.map(({metadata: {source, permalink}}) => [source, permalink]),
|
|
52
51
|
);
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -112,19 +111,16 @@ export function getBlogTags({
|
|
|
112
111
|
(blogPost) => blogPost.metadata.tags,
|
|
113
112
|
);
|
|
114
113
|
|
|
115
|
-
return mapValues(groups, (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}),
|
|
126
|
-
};
|
|
127
|
-
});
|
|
114
|
+
return _.mapValues(groups, ({tag, items: tagBlogPosts}) => ({
|
|
115
|
+
name: tag.label,
|
|
116
|
+
items: tagBlogPosts.map((item) => item.id),
|
|
117
|
+
permalink: tag.permalink,
|
|
118
|
+
pages: paginateBlogPosts({
|
|
119
|
+
blogPosts: tagBlogPosts,
|
|
120
|
+
basePageUrl: tag.permalink,
|
|
121
|
+
...params,
|
|
122
|
+
}),
|
|
123
|
+
}));
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
const DATE_FILENAME_REGEX =
|