@docusaurus/plugin-content-blog 2.0.0-beta.16 → 2.0.0-beta.17
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.js +4 -4
- package/lib/blogUtils.js +8 -9
- package/lib/feed.js +4 -6
- package/lib/index.js +5 -7
- package/package.json +9 -9
- package/src/authors.ts +1 -0
- package/src/feed.ts +1 -3
- package/src/plugin-content-blog.d.ts +1 -0
package/lib/authors.js
CHANGED
|
@@ -14,6 +14,7 @@ const AuthorsMapSchema = utils_validation_1.Joi.object().pattern(utils_validatio
|
|
|
14
14
|
url: utils_validation_1.URISchema,
|
|
15
15
|
imageURL: utils_validation_1.URISchema,
|
|
16
16
|
title: utils_validation_1.Joi.string(),
|
|
17
|
+
email: utils_validation_1.Joi.string(),
|
|
17
18
|
})
|
|
18
19
|
.rename('image_url', 'imageURL')
|
|
19
20
|
.or('name', 'imageURL')
|
|
@@ -34,11 +35,10 @@ exports.getAuthorsMap = getAuthorsMap;
|
|
|
34
35
|
// Legacy v1/early-v2 front matter fields
|
|
35
36
|
// We may want to deprecate those in favor of using only frontMatter.authors
|
|
36
37
|
function getFrontMatterAuthorLegacy(frontMatter) {
|
|
37
|
-
var _a, _b, _c;
|
|
38
38
|
const name = frontMatter.author;
|
|
39
|
-
const title =
|
|
40
|
-
const url =
|
|
41
|
-
const imageURL =
|
|
39
|
+
const title = frontMatter.author_title ?? frontMatter.authorTitle;
|
|
40
|
+
const url = frontMatter.author_url ?? frontMatter.authorURL;
|
|
41
|
+
const imageURL = frontMatter.author_image_url ?? frontMatter.authorImageURL;
|
|
42
42
|
if (name || title || url || imageURL) {
|
|
43
43
|
return {
|
|
44
44
|
name,
|
package/lib/blogUtils.js
CHANGED
|
@@ -8,14 +8,14 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.linkify = exports.generateBlogPosts = exports.parseBlogFileName = exports.getBlogTags = exports.paginateBlogPosts = exports.getSourceToPermalink = exports.truncate = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const fs_extra_1 =
|
|
12
|
-
const path_1 =
|
|
13
|
-
const reading_time_1 =
|
|
14
|
-
const lodash_1 =
|
|
11
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
12
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
13
|
+
const reading_time_1 = tslib_1.__importDefault(require("reading-time"));
|
|
14
|
+
const lodash_1 = 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");
|
|
18
|
-
const logger_1 =
|
|
18
|
+
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
|
|
19
19
|
function truncate(fileString, truncateMarker) {
|
|
20
20
|
return fileString.split(truncateMarker, 1).shift();
|
|
21
21
|
}
|
|
@@ -115,7 +115,6 @@ async function parseBlogPostMarkdownFile(blogSourceAbsolute) {
|
|
|
115
115
|
}
|
|
116
116
|
const defaultReadingTime = ({ content, options }) => (0, reading_time_1.default)(content, options).minutes;
|
|
117
117
|
async function processBlogSourceFile(blogSourceRelative, contentPaths, context, options, authorsMap) {
|
|
118
|
-
var _a, _b, _c, _d;
|
|
119
118
|
const { siteConfig: { baseUrl }, siteDir, i18n, } = context;
|
|
120
119
|
const { routeBasePath, tagsBasePath: tagsRouteBasePath, truncateMarker, showReadingTime, editUrl, } = options;
|
|
121
120
|
// Lookup in localized folder in priority
|
|
@@ -157,8 +156,8 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
|
|
|
157
156
|
}
|
|
158
157
|
const date = await getDate();
|
|
159
158
|
const formattedDate = formatBlogPostDate(i18n.currentLocale, date);
|
|
160
|
-
const title =
|
|
161
|
-
const description =
|
|
159
|
+
const title = frontMatter.title ?? contentTitle ?? parsedBlogFileName.text;
|
|
160
|
+
const description = frontMatter.description ?? excerpt ?? '';
|
|
162
161
|
const slug = frontMatter.slug || parsedBlogFileName.slug;
|
|
163
162
|
const permalink = (0, utils_1.normalizeUrl)([baseUrl, routeBasePath, slug]);
|
|
164
163
|
function getBlogEditUrl() {
|
|
@@ -208,7 +207,7 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
|
|
|
208
207
|
defaultReadingTime,
|
|
209
208
|
})
|
|
210
209
|
: undefined,
|
|
211
|
-
truncated:
|
|
210
|
+
truncated: truncateMarker?.test(content) || false,
|
|
212
211
|
authors,
|
|
213
212
|
frontMatter,
|
|
214
213
|
},
|
package/lib/feed.js
CHANGED
|
@@ -10,9 +10,9 @@ exports.createBlogFeedFiles = void 0;
|
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
11
|
const feed_1 = require("feed");
|
|
12
12
|
const utils_1 = require("@docusaurus/utils");
|
|
13
|
-
const cheerio_1 =
|
|
14
|
-
const path_1 =
|
|
15
|
-
const fs_extra_1 =
|
|
13
|
+
const cheerio_1 = tslib_1.__importDefault(require("cheerio"));
|
|
14
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
15
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
16
16
|
const utils_common_1 = require("@docusaurus/utils-common");
|
|
17
17
|
async function generateBlogFeed({ blogPosts, options, siteConfig, outDir, }) {
|
|
18
18
|
if (!blogPosts.length) {
|
|
@@ -33,9 +33,7 @@ async function generateBlogFeed({ blogPosts, options, siteConfig, outDir, }) {
|
|
|
33
33
|
copyright: feedOptions.copyright,
|
|
34
34
|
});
|
|
35
35
|
function toFeedAuthor(author) {
|
|
36
|
-
|
|
37
|
-
// RSS feed requires email to render authors
|
|
38
|
-
return { name: author.name, link: author.url };
|
|
36
|
+
return { name: author.name, link: author.url, email: author.email };
|
|
39
37
|
}
|
|
40
38
|
await (0, utils_1.mapAsyncSequential)(blogPosts, async (post) => {
|
|
41
39
|
const { id, metadata: { title: metadataTitle, permalink, date, description, authors, tags, }, } = post;
|
package/lib/index.js
CHANGED
|
@@ -8,15 +8,14 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.validateOptions = void 0;
|
|
10
10
|
const tslib_1 = require("tslib");
|
|
11
|
-
const path_1 =
|
|
12
|
-
const remark_admonitions_1 =
|
|
11
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
12
|
+
const remark_admonitions_1 = tslib_1.__importDefault(require("remark-admonitions"));
|
|
13
13
|
const utils_1 = require("@docusaurus/utils");
|
|
14
14
|
const translations_1 = require("./translations");
|
|
15
15
|
const pluginOptionSchema_1 = require("./pluginOptionSchema");
|
|
16
16
|
const blogUtils_1 = require("./blogUtils");
|
|
17
17
|
const feed_1 = require("./feed");
|
|
18
18
|
async function pluginContentBlog(context, options) {
|
|
19
|
-
var _a;
|
|
20
19
|
if (options.admonitions) {
|
|
21
20
|
options.remarkPlugins = options.remarkPlugins.concat([
|
|
22
21
|
[remark_admonitions_1.default, options.admonitions],
|
|
@@ -33,7 +32,7 @@ async function pluginContentBlog(context, options) {
|
|
|
33
32
|
pluginId: options.id,
|
|
34
33
|
}),
|
|
35
34
|
};
|
|
36
|
-
const pluginId =
|
|
35
|
+
const pluginId = options.id ?? utils_1.DEFAULT_PLUGIN_ID;
|
|
37
36
|
const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-blog');
|
|
38
37
|
const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
|
|
39
38
|
const aliasedSource = (source) => `~blog/${(0, utils_1.posixPath)(path_1.default.relative(pluginDataDirRoot, source))}`;
|
|
@@ -334,15 +333,14 @@ async function pluginContentBlog(context, options) {
|
|
|
334
333
|
});
|
|
335
334
|
},
|
|
336
335
|
injectHtmlTags({ content }) {
|
|
337
|
-
var _a, _b;
|
|
338
336
|
if (!content.blogPosts.length) {
|
|
339
337
|
return {};
|
|
340
338
|
}
|
|
341
|
-
if (!
|
|
339
|
+
if (!options.feedOptions?.type) {
|
|
342
340
|
return {};
|
|
343
341
|
}
|
|
344
342
|
const feedTypes = options.feedOptions.type;
|
|
345
|
-
const feedTitle =
|
|
343
|
+
const feedTitle = options.feedOptions.title ?? context.siteConfig.title;
|
|
346
344
|
const feedsConfig = {
|
|
347
345
|
rss: {
|
|
348
346
|
type: 'application/rss+xml',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-blog",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.17",
|
|
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": "2.0.0-beta.
|
|
22
|
-
"@docusaurus/logger": "2.0.0-beta.
|
|
23
|
-
"@docusaurus/mdx-loader": "2.0.0-beta.
|
|
24
|
-
"@docusaurus/utils": "2.0.0-beta.
|
|
25
|
-
"@docusaurus/utils-common": "2.0.0-beta.
|
|
26
|
-
"@docusaurus/utils-validation": "2.0.0-beta.
|
|
21
|
+
"@docusaurus/core": "2.0.0-beta.17",
|
|
22
|
+
"@docusaurus/logger": "2.0.0-beta.17",
|
|
23
|
+
"@docusaurus/mdx-loader": "2.0.0-beta.17",
|
|
24
|
+
"@docusaurus/utils": "2.0.0-beta.17",
|
|
25
|
+
"@docusaurus/utils-common": "2.0.0-beta.17",
|
|
26
|
+
"@docusaurus/utils-validation": "2.0.0-beta.17",
|
|
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": "2.0.0-beta.
|
|
38
|
+
"@docusaurus/types": "2.0.0-beta.17",
|
|
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": "0032c0b0480083227af2e1b4da2d3ee6ce992403"
|
|
49
49
|
}
|
package/src/authors.ts
CHANGED
package/src/feed.ts
CHANGED
|
@@ -57,9 +57,7 @@ async function generateBlogFeed({
|
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
function toFeedAuthor(author: Author): FeedAuthor {
|
|
60
|
-
|
|
61
|
-
// RSS feed requires email to render authors
|
|
62
|
-
return {name: author.name, link: author.url};
|
|
60
|
+
return {name: author.name, link: author.url, email: author.email};
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
await mapAsyncSequential(blogPosts, async (post) => {
|