@docusaurus/plugin-content-blog 0.0.0-5633 → 0.0.0-5635
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/feed.js +5 -2
- package/lib/options.js +4 -1
- package/package.json +11 -10
- package/src/feed.ts +7 -2
- package/src/options.ts +4 -1
- package/src/plugin-content-blog.d.ts +2 -0
package/lib/feed.js
CHANGED
|
@@ -22,7 +22,10 @@ async function generateBlogFeed({ blogPosts, options, siteConfig, outDir, locale
|
|
|
22
22
|
const { feedOptions, routeBasePath } = options;
|
|
23
23
|
const { url: siteUrl, baseUrl, title, favicon } = siteConfig;
|
|
24
24
|
const blogBaseUrl = (0, utils_1.normalizeUrl)([siteUrl, baseUrl, routeBasePath]);
|
|
25
|
-
const
|
|
25
|
+
const blogPostsForFeed = feedOptions.limit === false || feedOptions.limit === null
|
|
26
|
+
? blogPosts
|
|
27
|
+
: blogPosts.slice(0, feedOptions.limit);
|
|
28
|
+
const updated = blogPostsForFeed[0]?.metadata.date;
|
|
26
29
|
const feed = new feed_1.Feed({
|
|
27
30
|
id: blogBaseUrl,
|
|
28
31
|
title: feedOptions.title ?? `${title} Blog`,
|
|
@@ -35,7 +38,7 @@ async function generateBlogFeed({ blogPosts, options, siteConfig, outDir, locale
|
|
|
35
38
|
});
|
|
36
39
|
const createFeedItems = options.feedOptions.createFeedItems ?? defaultCreateFeedItems;
|
|
37
40
|
const feedItems = await createFeedItems({
|
|
38
|
-
blogPosts,
|
|
41
|
+
blogPosts: blogPostsForFeed,
|
|
39
42
|
siteConfig,
|
|
40
43
|
outDir,
|
|
41
44
|
defaultCreateFeedItems,
|
package/lib/options.js
CHANGED
|
@@ -10,7 +10,7 @@ exports.validateOptions = exports.DEFAULT_OPTIONS = void 0;
|
|
|
10
10
|
const utils_validation_1 = require("@docusaurus/utils-validation");
|
|
11
11
|
const utils_1 = require("@docusaurus/utils");
|
|
12
12
|
exports.DEFAULT_OPTIONS = {
|
|
13
|
-
feedOptions: { type: ['rss', 'atom'], copyright: '' },
|
|
13
|
+
feedOptions: { type: ['rss', 'atom'], copyright: '', limit: 20 },
|
|
14
14
|
beforeDefaultRehypePlugins: [],
|
|
15
15
|
beforeDefaultRemarkPlugins: [],
|
|
16
16
|
admonitions: true,
|
|
@@ -92,6 +92,9 @@ const PluginOptionSchema = utils_validation_1.Joi.object({
|
|
|
92
92
|
}),
|
|
93
93
|
language: utils_validation_1.Joi.string(),
|
|
94
94
|
createFeedItems: utils_validation_1.Joi.function(),
|
|
95
|
+
limit: utils_validation_1.Joi.alternatives()
|
|
96
|
+
.try(utils_validation_1.Joi.number(), utils_validation_1.Joi.valid(null), utils_validation_1.Joi.valid(false))
|
|
97
|
+
.default(exports.DEFAULT_OPTIONS.feedOptions.limit),
|
|
95
98
|
}).default(exports.DEFAULT_OPTIONS.feedOptions),
|
|
96
99
|
authorsMapPath: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.authorsMapPath),
|
|
97
100
|
readingTime: utils_validation_1.Joi.function().default(() => exports.DEFAULT_OPTIONS.readingTime),
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@docusaurus/plugin-content-blog",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-5635",
|
|
4
4
|
"description": "Blog plugin for Docusaurus.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "src/plugin-content-blog.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc",
|
|
9
|
-
"watch": "tsc --watch"
|
|
9
|
+
"watch": "tsc --watch",
|
|
10
|
+
"test:generate-build-snap": "yarn docusaurus build src/__tests__/__fixtures__/website --out-dir build-snap && yarn rimraf src/__tests__/__fixtures__/website/.docusaurus && yarn rimraf src/__tests__/__fixtures__/website/build-snap/assets && git add src/__tests__/__fixtures__/website/build-snap"
|
|
10
11
|
},
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
@@ -18,13 +19,13 @@
|
|
|
18
19
|
},
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"dependencies": {
|
|
21
|
-
"@docusaurus/core": "0.0.0-
|
|
22
|
-
"@docusaurus/logger": "0.0.0-
|
|
23
|
-
"@docusaurus/mdx-loader": "0.0.0-
|
|
24
|
-
"@docusaurus/types": "0.0.0-
|
|
25
|
-
"@docusaurus/utils": "0.0.0-
|
|
26
|
-
"@docusaurus/utils-common": "0.0.0-
|
|
27
|
-
"@docusaurus/utils-validation": "0.0.0-
|
|
22
|
+
"@docusaurus/core": "0.0.0-5635",
|
|
23
|
+
"@docusaurus/logger": "0.0.0-5635",
|
|
24
|
+
"@docusaurus/mdx-loader": "0.0.0-5635",
|
|
25
|
+
"@docusaurus/types": "0.0.0-5635",
|
|
26
|
+
"@docusaurus/utils": "0.0.0-5635",
|
|
27
|
+
"@docusaurus/utils-common": "0.0.0-5635",
|
|
28
|
+
"@docusaurus/utils-validation": "0.0.0-5635",
|
|
28
29
|
"cheerio": "^1.0.0-rc.12",
|
|
29
30
|
"feed": "^4.2.2",
|
|
30
31
|
"fs-extra": "^11.1.1",
|
|
@@ -42,5 +43,5 @@
|
|
|
42
43
|
"engines": {
|
|
43
44
|
"node": ">=16.14"
|
|
44
45
|
},
|
|
45
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "b9b37df155d491fa570c242f7c151c7b5e4fb7e6"
|
|
46
47
|
}
|
package/src/feed.ts
CHANGED
|
@@ -42,7 +42,12 @@ async function generateBlogFeed({
|
|
|
42
42
|
const {url: siteUrl, baseUrl, title, favicon} = siteConfig;
|
|
43
43
|
const blogBaseUrl = normalizeUrl([siteUrl, baseUrl, routeBasePath]);
|
|
44
44
|
|
|
45
|
-
const
|
|
45
|
+
const blogPostsForFeed =
|
|
46
|
+
feedOptions.limit === false || feedOptions.limit === null
|
|
47
|
+
? blogPosts
|
|
48
|
+
: blogPosts.slice(0, feedOptions.limit);
|
|
49
|
+
|
|
50
|
+
const updated = blogPostsForFeed[0]?.metadata.date;
|
|
46
51
|
|
|
47
52
|
const feed = new Feed({
|
|
48
53
|
id: blogBaseUrl,
|
|
@@ -59,7 +64,7 @@ async function generateBlogFeed({
|
|
|
59
64
|
options.feedOptions.createFeedItems ?? defaultCreateFeedItems;
|
|
60
65
|
|
|
61
66
|
const feedItems = await createFeedItems({
|
|
62
|
-
blogPosts,
|
|
67
|
+
blogPosts: blogPostsForFeed,
|
|
63
68
|
siteConfig,
|
|
64
69
|
outDir,
|
|
65
70
|
defaultCreateFeedItems,
|
package/src/options.ts
CHANGED
|
@@ -22,7 +22,7 @@ import type {
|
|
|
22
22
|
import type {OptionValidationContext} from '@docusaurus/types';
|
|
23
23
|
|
|
24
24
|
export const DEFAULT_OPTIONS: PluginOptions = {
|
|
25
|
-
feedOptions: {type: ['rss', 'atom'], copyright: ''},
|
|
25
|
+
feedOptions: {type: ['rss', 'atom'], copyright: '', limit: 20},
|
|
26
26
|
beforeDefaultRehypePlugins: [],
|
|
27
27
|
beforeDefaultRemarkPlugins: [],
|
|
28
28
|
admonitions: true,
|
|
@@ -123,6 +123,9 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
|
|
|
123
123
|
}),
|
|
124
124
|
language: Joi.string(),
|
|
125
125
|
createFeedItems: Joi.function(),
|
|
126
|
+
limit: Joi.alternatives()
|
|
127
|
+
.try(Joi.number(), Joi.valid(null), Joi.valid(false))
|
|
128
|
+
.default(DEFAULT_OPTIONS.feedOptions.limit),
|
|
126
129
|
}).default(DEFAULT_OPTIONS.feedOptions),
|
|
127
130
|
authorsMapPath: Joi.string().default(DEFAULT_OPTIONS.authorsMapPath),
|
|
128
131
|
readingTime: Joi.function().default(() => DEFAULT_OPTIONS.readingTime),
|
|
@@ -272,6 +272,8 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the
|
|
|
272
272
|
language?: string;
|
|
273
273
|
/** Allow control over the construction of BlogFeedItems */
|
|
274
274
|
createFeedItems?: CreateFeedItemsFn;
|
|
275
|
+
/** Limits the feed to the specified number of posts, false|null for all */
|
|
276
|
+
limit?: number | false | null;
|
|
275
277
|
};
|
|
276
278
|
|
|
277
279
|
type DefaultCreateFeedItemsParams = {
|