@docusaurus/plugin-content-blog 0.0.0-5632 → 0.0.0-5634

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 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 updated = blogPosts[0]?.metadata.date;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-5632",
3
+ "version": "0.0.0-5634",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -18,13 +18,13 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-5632",
22
- "@docusaurus/logger": "0.0.0-5632",
23
- "@docusaurus/mdx-loader": "0.0.0-5632",
24
- "@docusaurus/types": "0.0.0-5632",
25
- "@docusaurus/utils": "0.0.0-5632",
26
- "@docusaurus/utils-common": "0.0.0-5632",
27
- "@docusaurus/utils-validation": "0.0.0-5632",
21
+ "@docusaurus/core": "0.0.0-5634",
22
+ "@docusaurus/logger": "0.0.0-5634",
23
+ "@docusaurus/mdx-loader": "0.0.0-5634",
24
+ "@docusaurus/types": "0.0.0-5634",
25
+ "@docusaurus/utils": "0.0.0-5634",
26
+ "@docusaurus/utils-common": "0.0.0-5634",
27
+ "@docusaurus/utils-validation": "0.0.0-5634",
28
28
  "cheerio": "^1.0.0-rc.12",
29
29
  "feed": "^4.2.2",
30
30
  "fs-extra": "^11.1.1",
@@ -42,5 +42,5 @@
42
42
  "engines": {
43
43
  "node": ">=16.14"
44
44
  },
45
- "gitHead": "89bc98ec99d8d5d44e5b8503774f55ac0cb7d8d1"
45
+ "gitHead": "efc19dd4c4723eacdcfc3e4c2640a6fe2e45ff10"
46
46
  }
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 updated = blogPosts[0]?.metadata.date;
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 = {