@docusaurus/plugin-content-blog 0.0.0-6060 → 0.0.0-6062
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/authors.d.ts +4 -0
- package/lib/authors.js +14 -1
- package/lib/authorsMap.d.ts +1 -0
- package/lib/authorsMap.js +5 -3
- package/lib/index.js +1 -0
- package/package.json +10 -10
- package/src/authors.ts +28 -4
- package/src/authorsMap.ts +10 -3
- package/src/index.ts +1 -0
package/lib/authors.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ type AuthorsParam = {
|
|
|
10
10
|
authorsMap: AuthorsMap | undefined;
|
|
11
11
|
baseUrl: string;
|
|
12
12
|
};
|
|
13
|
+
export declare function normalizeImageUrl({ imageURL, baseUrl, }: {
|
|
14
|
+
imageURL: string | undefined;
|
|
15
|
+
baseUrl: string;
|
|
16
|
+
}): string | undefined;
|
|
13
17
|
export declare function getBlogPostAuthors(params: AuthorsParam): Author[];
|
|
14
18
|
/**
|
|
15
19
|
* Group blog posts by author key
|
package/lib/authors.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.normalizeImageUrl = normalizeImageUrl;
|
|
9
10
|
exports.getBlogPostAuthors = getBlogPostAuthors;
|
|
10
11
|
exports.groupBlogPostsByAuthorKey = groupBlogPostsByAuthorKey;
|
|
11
12
|
const tslib_1 = require("tslib");
|
|
@@ -16,6 +17,17 @@ function normalizeImageUrl({ imageURL, baseUrl, }) {
|
|
|
16
17
|
? (0, utils_1.normalizeUrl)([baseUrl, imageURL])
|
|
17
18
|
: imageURL;
|
|
18
19
|
}
|
|
20
|
+
function normalizeAuthorUrl({ author, baseUrl, }) {
|
|
21
|
+
if (author.key) {
|
|
22
|
+
// Ensures invariant: global authors should have already been normalized
|
|
23
|
+
if (author.imageURL?.startsWith('/') &&
|
|
24
|
+
!author.imageURL.startsWith(baseUrl)) {
|
|
25
|
+
throw new Error(`Docusaurus internal bug: global authors image ${author.imageURL} should start with the expected baseUrl=${baseUrl}`);
|
|
26
|
+
}
|
|
27
|
+
return author.imageURL;
|
|
28
|
+
}
|
|
29
|
+
return normalizeImageUrl({ imageURL: author.imageURL, baseUrl });
|
|
30
|
+
}
|
|
19
31
|
// Legacy v1/early-v2 front matter fields
|
|
20
32
|
// We may want to deprecate those in favor of using only frontMatter.authors
|
|
21
33
|
// TODO Docusaurus v4: remove this legacy front matter
|
|
@@ -88,7 +100,8 @@ ${Object.keys(authorsMap)
|
|
|
88
100
|
...author,
|
|
89
101
|
key: author.key ?? null,
|
|
90
102
|
page: author.page ?? null,
|
|
91
|
-
|
|
103
|
+
// global author images have already been normalized
|
|
104
|
+
imageURL: normalizeAuthorUrl({ author, baseUrl }),
|
|
92
105
|
};
|
|
93
106
|
}
|
|
94
107
|
}
|
package/lib/authorsMap.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export declare function getAuthorsMap(params: {
|
|
|
18
18
|
authorsMapPath: string;
|
|
19
19
|
authorsBaseRoutePath: string;
|
|
20
20
|
contentPaths: BlogContentPaths;
|
|
21
|
+
baseUrl: string;
|
|
21
22
|
}): Promise<AuthorsMap | undefined>;
|
|
22
23
|
export declare function validateAuthorsMap(content: unknown): AuthorsMapInput;
|
|
23
24
|
export {};
|
package/lib/authorsMap.js
CHANGED
|
@@ -15,6 +15,7 @@ const lodash_1 = tslib_1.__importDefault(require("lodash"));
|
|
|
15
15
|
const utils_1 = require("@docusaurus/utils");
|
|
16
16
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
17
17
|
const authorsSocials_1 = require("./authorsSocials");
|
|
18
|
+
const authors_1 = require("./authors");
|
|
18
19
|
const AuthorPageSchema = utils_validation_1.Joi.object({
|
|
19
20
|
permalink: utils_validation_1.Joi.string().required(),
|
|
20
21
|
});
|
|
@@ -63,7 +64,7 @@ function checkAuthorsMapPermalinkCollisions(authorsMap) {
|
|
|
63
64
|
throw new Error(`The following permalinks are duplicated:\n${errorMessage}`);
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
function normalizeAuthor({ authorsBaseRoutePath, authorKey, author, }) {
|
|
67
|
+
function normalizeAuthor({ authorsBaseRoutePath, authorKey, baseUrl, author, }) {
|
|
67
68
|
function getAuthorPage() {
|
|
68
69
|
if (!author.page) {
|
|
69
70
|
return null;
|
|
@@ -77,12 +78,13 @@ function normalizeAuthor({ authorsBaseRoutePath, authorKey, author, }) {
|
|
|
77
78
|
...author,
|
|
78
79
|
key: authorKey,
|
|
79
80
|
page: getAuthorPage(),
|
|
81
|
+
imageURL: (0, authors_1.normalizeImageUrl)({ imageURL: author.imageURL, baseUrl }),
|
|
80
82
|
socials: author.socials ? (0, authorsSocials_1.normalizeSocials)(author.socials) : undefined,
|
|
81
83
|
};
|
|
82
84
|
}
|
|
83
|
-
function normalizeAuthorsMap({ authorsBaseRoutePath, authorsMapInput, }) {
|
|
85
|
+
function normalizeAuthorsMap({ authorsBaseRoutePath, authorsMapInput, baseUrl, }) {
|
|
84
86
|
return lodash_1.default.mapValues(authorsMapInput, (author, authorKey) => {
|
|
85
|
-
return normalizeAuthor({ authorsBaseRoutePath, authorKey, author });
|
|
87
|
+
return normalizeAuthor({ authorsBaseRoutePath, authorKey, author, baseUrl });
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
90
|
function validateAuthorsMapInput(content) {
|
package/lib/index.js
CHANGED
|
@@ -168,6 +168,7 @@ async function pluginContentBlog(context, options) {
|
|
|
168
168
|
routeBasePath,
|
|
169
169
|
authorsBasePath,
|
|
170
170
|
]),
|
|
171
|
+
baseUrl,
|
|
171
172
|
});
|
|
172
173
|
(0, authorsMap_1.checkAuthorsMapPermalinkCollisions)(authorsMap);
|
|
173
174
|
let blogPosts = await (0, blogUtils_1.generateBlogPosts)(contentPaths, context, options, authorsMap);
|
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-6062",
|
|
4
4
|
"description": "Blog plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-blog.d.ts",
|
|
@@ -31,14 +31,14 @@
|
|
|
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/theme-common": "0.0.0-
|
|
38
|
-
"@docusaurus/types": "0.0.0-
|
|
39
|
-
"@docusaurus/utils": "0.0.0-
|
|
40
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
41
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
34
|
+
"@docusaurus/core": "0.0.0-6062",
|
|
35
|
+
"@docusaurus/logger": "0.0.0-6062",
|
|
36
|
+
"@docusaurus/mdx-loader": "0.0.0-6062",
|
|
37
|
+
"@docusaurus/theme-common": "0.0.0-6062",
|
|
38
|
+
"@docusaurus/types": "0.0.0-6062",
|
|
39
|
+
"@docusaurus/utils": "0.0.0-6062",
|
|
40
|
+
"@docusaurus/utils-common": "0.0.0-6062",
|
|
41
|
+
"@docusaurus/utils-validation": "0.0.0-6062",
|
|
42
42
|
"cheerio": "1.0.0-rc.12",
|
|
43
43
|
"feed": "^4.2.2",
|
|
44
44
|
"fs-extra": "^11.1.1",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"@total-typescript/shoehorn": "^0.1.2",
|
|
63
63
|
"tree-node-cli": "^1.6.0"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "f32caf7a9bd354b43ea373b232021955fb95af2d"
|
|
66
66
|
}
|
package/src/authors.ts
CHANGED
|
@@ -21,18 +21,41 @@ type AuthorsParam = {
|
|
|
21
21
|
baseUrl: string;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
function normalizeImageUrl({
|
|
24
|
+
export function normalizeImageUrl({
|
|
25
25
|
imageURL,
|
|
26
26
|
baseUrl,
|
|
27
27
|
}: {
|
|
28
28
|
imageURL: string | undefined;
|
|
29
29
|
baseUrl: string;
|
|
30
|
-
}) {
|
|
30
|
+
}): string | undefined {
|
|
31
31
|
return imageURL?.startsWith('/')
|
|
32
32
|
? normalizeUrl([baseUrl, imageURL])
|
|
33
33
|
: imageURL;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
function normalizeAuthorUrl({
|
|
37
|
+
author,
|
|
38
|
+
baseUrl,
|
|
39
|
+
}: {
|
|
40
|
+
author: Author;
|
|
41
|
+
baseUrl: string;
|
|
42
|
+
}): string | undefined {
|
|
43
|
+
if (author.key) {
|
|
44
|
+
// Ensures invariant: global authors should have already been normalized
|
|
45
|
+
if (
|
|
46
|
+
author.imageURL?.startsWith('/') &&
|
|
47
|
+
!author.imageURL.startsWith(baseUrl)
|
|
48
|
+
) {
|
|
49
|
+
throw new Error(
|
|
50
|
+
`Docusaurus internal bug: global authors image ${author.imageURL} should start with the expected baseUrl=${baseUrl}`,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return author.imageURL;
|
|
55
|
+
}
|
|
56
|
+
return normalizeImageUrl({imageURL: author.imageURL, baseUrl});
|
|
57
|
+
}
|
|
58
|
+
|
|
36
59
|
// Legacy v1/early-v2 front matter fields
|
|
37
60
|
// We may want to deprecate those in favor of using only frontMatter.authors
|
|
38
61
|
// TODO Docusaurus v4: remove this legacy front matter
|
|
@@ -116,13 +139,14 @@ ${Object.keys(authorsMap)
|
|
|
116
139
|
// Author def from authorsMap can be locally overridden by front matter
|
|
117
140
|
...getAuthorsMapAuthor(frontMatterAuthor.key),
|
|
118
141
|
...frontMatterAuthor,
|
|
119
|
-
};
|
|
142
|
+
} as Author;
|
|
120
143
|
|
|
121
144
|
return {
|
|
122
145
|
...author,
|
|
123
146
|
key: author.key ?? null,
|
|
124
147
|
page: author.page ?? null,
|
|
125
|
-
|
|
148
|
+
// global author images have already been normalized
|
|
149
|
+
imageURL: normalizeAuthorUrl({author, baseUrl}),
|
|
126
150
|
};
|
|
127
151
|
}
|
|
128
152
|
}
|
package/src/authorsMap.ts
CHANGED
|
@@ -9,12 +9,13 @@ import _ from 'lodash';
|
|
|
9
9
|
import {readDataFile, normalizeUrl} from '@docusaurus/utils';
|
|
10
10
|
import {Joi, URISchema} from '@docusaurus/utils-validation';
|
|
11
11
|
import {AuthorSocialsSchema, normalizeSocials} from './authorsSocials';
|
|
12
|
+
import {normalizeImageUrl} from './authors';
|
|
12
13
|
import type {BlogContentPaths} from './types';
|
|
13
14
|
import type {
|
|
14
|
-
Author,
|
|
15
15
|
AuthorAttributes,
|
|
16
16
|
AuthorPage,
|
|
17
17
|
AuthorsMap,
|
|
18
|
+
AuthorWithKey,
|
|
18
19
|
} from '@docusaurus/plugin-content-blog';
|
|
19
20
|
|
|
20
21
|
type AuthorInput = AuthorAttributes & {
|
|
@@ -93,12 +94,14 @@ export function checkAuthorsMapPermalinkCollisions(
|
|
|
93
94
|
function normalizeAuthor({
|
|
94
95
|
authorsBaseRoutePath,
|
|
95
96
|
authorKey,
|
|
97
|
+
baseUrl,
|
|
96
98
|
author,
|
|
97
99
|
}: {
|
|
98
100
|
authorsBaseRoutePath: string;
|
|
99
101
|
authorKey: string;
|
|
102
|
+
baseUrl: string;
|
|
100
103
|
author: AuthorInput;
|
|
101
|
-
}):
|
|
104
|
+
}): AuthorWithKey {
|
|
102
105
|
function getAuthorPage(): AuthorPage | null {
|
|
103
106
|
if (!author.page) {
|
|
104
107
|
return null;
|
|
@@ -114,6 +117,7 @@ function normalizeAuthor({
|
|
|
114
117
|
...author,
|
|
115
118
|
key: authorKey,
|
|
116
119
|
page: getAuthorPage(),
|
|
120
|
+
imageURL: normalizeImageUrl({imageURL: author.imageURL, baseUrl}),
|
|
117
121
|
socials: author.socials ? normalizeSocials(author.socials) : undefined,
|
|
118
122
|
};
|
|
119
123
|
}
|
|
@@ -121,12 +125,14 @@ function normalizeAuthor({
|
|
|
121
125
|
function normalizeAuthorsMap({
|
|
122
126
|
authorsBaseRoutePath,
|
|
123
127
|
authorsMapInput,
|
|
128
|
+
baseUrl,
|
|
124
129
|
}: {
|
|
125
130
|
authorsBaseRoutePath: string;
|
|
126
131
|
authorsMapInput: AuthorsMapInput;
|
|
132
|
+
baseUrl: string;
|
|
127
133
|
}): AuthorsMap {
|
|
128
134
|
return _.mapValues(authorsMapInput, (author, authorKey) => {
|
|
129
|
-
return normalizeAuthor({authorsBaseRoutePath, authorKey, author});
|
|
135
|
+
return normalizeAuthor({authorsBaseRoutePath, authorKey, author, baseUrl});
|
|
130
136
|
});
|
|
131
137
|
}
|
|
132
138
|
|
|
@@ -153,6 +159,7 @@ export async function getAuthorsMap(params: {
|
|
|
153
159
|
authorsMapPath: string;
|
|
154
160
|
authorsBaseRoutePath: string;
|
|
155
161
|
contentPaths: BlogContentPaths;
|
|
162
|
+
baseUrl: string;
|
|
156
163
|
}): Promise<AuthorsMap | undefined> {
|
|
157
164
|
const authorsMapInput = await getAuthorsMapInput(params);
|
|
158
165
|
if (!authorsMapInput) {
|