@docusaurus/plugin-content-blog 3.9.2-canary-6443 → 3.9.2-canary-6445

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/index.js CHANGED
@@ -41,7 +41,7 @@ async function pluginContentBlog(context, options) {
41
41
  })
42
42
  : undefined,
43
43
  };
44
- const pluginId = options.id ?? utils_1.DEFAULT_PLUGIN_ID;
44
+ const pluginId = options.id;
45
45
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, PluginName);
46
46
  const dataDir = path_1.default.join(pluginDataDirRoot, pluginId);
47
47
  // TODO Docusaurus v4 breaking change
@@ -164,9 +164,10 @@ async function pluginContentBlog(context, options) {
164
164
  const listedBlogPosts = blogPosts.filter(blogUtils_1.shouldBeListed);
165
165
  if (!blogPosts.length) {
166
166
  return {
167
+ blogTitle,
168
+ blogDescription,
167
169
  blogSidebarTitle,
168
170
  blogPosts: [],
169
- blogListPaginated: [],
170
171
  blogTags: {},
171
172
  blogTagsListPath,
172
173
  authorsMap,
@@ -191,14 +192,6 @@ async function pluginContentBlog(context, options) {
191
192
  };
192
193
  }
193
194
  });
194
- const blogListPaginated = (0, blogUtils_1.paginateBlogPosts)({
195
- blogPosts: listedBlogPosts,
196
- blogTitle,
197
- blogDescription,
198
- postsPerPageOption,
199
- basePageUrl: baseBlogUrl,
200
- pageBasePath,
201
- });
202
195
  const blogTags = (0, blogUtils_1.getBlogTags)({
203
196
  blogPosts,
204
197
  postsPerPageOption,
@@ -207,9 +200,10 @@ async function pluginContentBlog(context, options) {
207
200
  pageBasePath,
208
201
  });
209
202
  return {
203
+ blogTitle,
204
+ blogDescription,
210
205
  blogSidebarTitle,
211
206
  blogPosts,
212
- blogListPaginated,
213
207
  blogTags,
214
208
  blogTagsListPath,
215
209
  authorsMap,
package/lib/options.js CHANGED
@@ -13,6 +13,7 @@ const path_1 = tslib_1.__importDefault(require("path"));
13
13
  const utils_validation_1 = require("@docusaurus/utils-validation");
14
14
  const utils_1 = require("@docusaurus/utils");
15
15
  exports.DEFAULT_OPTIONS = {
16
+ id: utils_1.DEFAULT_PLUGIN_ID,
16
17
  feedOptions: {
17
18
  type: ['rss', 'atom'],
18
19
  copyright: '',
package/lib/routes.js CHANGED
@@ -19,15 +19,12 @@ async function createAllRoutes(param) {
19
19
  routes.forEach(param.actions.addRoute);
20
20
  }
21
21
  async function buildAllRoutes({ baseUrl, content, actions, options, aliasedSource, }) {
22
- const { blogListComponent, blogPostComponent, blogTagsListComponent, blogAuthorsListComponent, blogAuthorsPostsComponent, blogTagsPostsComponent, blogArchiveComponent, routeBasePath, archiveBasePath, blogTitle, authorsBasePath, postsPerPage, blogDescription, } = options;
22
+ const { blogListComponent, blogPostComponent, blogTagsListComponent, blogAuthorsListComponent, blogAuthorsPostsComponent, blogTagsPostsComponent, blogArchiveComponent, routeBasePath, archiveBasePath, authorsBasePath, postsPerPage, pageBasePath, } = options;
23
23
  const pluginId = options.id;
24
24
  const { createData } = actions;
25
- const { blogSidebarTitle, blogPosts, blogListPaginated, blogTags, blogTagsListPath, authorsMap, } = content;
26
- const authorsListPath = (0, utils_1.normalizeUrl)([
27
- baseUrl,
28
- routeBasePath,
29
- authorsBasePath,
30
- ]);
25
+ const { blogTitle, blogDescription, blogSidebarTitle, blogPosts, blogTags, blogTagsListPath, authorsMap, } = content;
26
+ const blogBasePath = (0, utils_1.normalizeUrl)([baseUrl, routeBasePath]);
27
+ const authorsListPath = (0, utils_1.normalizeUrl)([blogBasePath, authorsBasePath]);
31
28
  const listedBlogPosts = blogPosts.filter(blogUtils_1.shouldBeListed);
32
29
  const blogPostsById = lodash_1.default.keyBy(blogPosts, (post) => post.id);
33
30
  function getBlogPostById(id) {
@@ -50,7 +47,7 @@ async function buildAllRoutes({ baseUrl, content, actions, options, aliasedSourc
50
47
  }
51
48
  async function createBlogMetadataModule() {
52
49
  const blogMetadata = {
53
- blogBasePath: (0, utils_1.normalizeUrl)([baseUrl, routeBasePath]),
50
+ blogBasePath,
54
51
  blogTitle,
55
52
  authorsListPath,
56
53
  };
@@ -81,7 +78,7 @@ async function buildAllRoutes({ baseUrl, content, actions, options, aliasedSourc
81
78
  if (archiveBasePath && listedBlogPosts.length) {
82
79
  return [
83
80
  {
84
- path: (0, utils_1.normalizeUrl)([baseUrl, routeBasePath, archiveBasePath]),
81
+ path: (0, utils_1.normalizeUrl)([blogBasePath, archiveBasePath]),
85
82
  component: blogArchiveComponent,
86
83
  exact: true,
87
84
  props: {
@@ -124,6 +121,14 @@ async function buildAllRoutes({ baseUrl, content, actions, options, aliasedSourc
124
121
  return blogPosts.map(createBlogPostRoute);
125
122
  }
126
123
  function createBlogPostsPaginatedRoutes() {
124
+ const blogListPaginated = (0, blogUtils_1.paginateBlogPosts)({
125
+ blogPosts: listedBlogPosts,
126
+ blogTitle,
127
+ blogDescription,
128
+ postsPerPageOption: postsPerPage,
129
+ basePageUrl: blogBasePath,
130
+ pageBasePath,
131
+ });
127
132
  return blogListPaginated.map((paginated) => {
128
133
  return {
129
134
  path: paginated.metadata.permalink,
@@ -8,19 +8,6 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.getTranslationFiles = getTranslationFiles;
10
10
  exports.translateContent = translateContent;
11
- function translateListPage(blogListPaginated, translations) {
12
- return blogListPaginated.map((page) => {
13
- const { items, metadata } = page;
14
- return {
15
- items,
16
- metadata: {
17
- ...metadata,
18
- blogTitle: translations.title?.message ?? page.metadata.blogTitle,
19
- blogDescription: translations.description?.message ?? page.metadata.blogDescription,
20
- },
21
- };
22
- });
23
- }
24
11
  function getTranslationFiles(options) {
25
12
  return [
26
13
  {
@@ -43,10 +30,11 @@ function getTranslationFiles(options) {
43
30
  ];
44
31
  }
45
32
  function translateContent(content, translationFiles) {
46
- const { content: optionsTranslations } = translationFiles[0];
33
+ const { content: translations } = translationFiles[0];
47
34
  return {
48
35
  ...content,
49
- blogSidebarTitle: optionsTranslations['sidebar.title']?.message ?? content.blogSidebarTitle,
50
- blogListPaginated: translateListPage(content.blogListPaginated, optionsTranslations),
36
+ blogTitle: translations.title?.message ?? content.blogTitle,
37
+ blogDescription: translations.description?.message ?? content.blogDescription,
38
+ blogSidebarTitle: translations['sidebar.title']?.message ?? content.blogSidebarTitle,
51
39
  };
52
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "3.9.2-canary-6443",
3
+ "version": "3.9.2-canary-6445",
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": "3.9.2-canary-6443",
35
- "@docusaurus/logger": "3.9.2-canary-6443",
36
- "@docusaurus/mdx-loader": "3.9.2-canary-6443",
37
- "@docusaurus/theme-common": "3.9.2-canary-6443",
38
- "@docusaurus/types": "3.9.2-canary-6443",
39
- "@docusaurus/utils": "3.9.2-canary-6443",
40
- "@docusaurus/utils-common": "3.9.2-canary-6443",
41
- "@docusaurus/utils-validation": "3.9.2-canary-6443",
34
+ "@docusaurus/core": "3.9.2-canary-6445",
35
+ "@docusaurus/logger": "3.9.2-canary-6445",
36
+ "@docusaurus/mdx-loader": "3.9.2-canary-6445",
37
+ "@docusaurus/theme-common": "3.9.2-canary-6445",
38
+ "@docusaurus/types": "3.9.2-canary-6445",
39
+ "@docusaurus/utils": "3.9.2-canary-6445",
40
+ "@docusaurus/utils-common": "3.9.2-canary-6445",
41
+ "@docusaurus/utils-validation": "3.9.2-canary-6445",
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": "a25dde30cfb44b2e621d62c4a58e371e3d9c96bf"
65
+ "gitHead": "ce0bfb61b6924d2bb866fa96ff27a73d93af235e"
66
66
  }
package/src/index.ts CHANGED
@@ -17,7 +17,6 @@ import {
17
17
  createAbsoluteFilePathMatcher,
18
18
  getContentPathList,
19
19
  getDataFilePath,
20
- DEFAULT_PLUGIN_ID,
21
20
  resolveMarkdownLinkPathname,
22
21
  getLocaleConfig,
23
22
  } from '@docusaurus/utils';
@@ -25,7 +24,6 @@ import {getTagsFilePathsToWatch} from '@docusaurus/utils-validation';
25
24
  import {createMDXLoaderItem} from '@docusaurus/mdx-loader';
26
25
  import {
27
26
  getBlogTags,
28
- paginateBlogPosts,
29
27
  shouldBeListed,
30
28
  applyProcessBlogPosts,
31
29
  generateBlogPosts,
@@ -45,7 +43,6 @@ import type {
45
43
  Assets,
46
44
  BlogTags,
47
45
  BlogContent,
48
- BlogPaginated,
49
46
  } from '@docusaurus/plugin-content-blog';
50
47
  import type {RuleSetRule, RuleSetUseItem} from 'webpack';
51
48
 
@@ -85,7 +82,7 @@ export default async function pluginContentBlog(
85
82
  })
86
83
  : undefined,
87
84
  };
88
- const pluginId = options.id ?? DEFAULT_PLUGIN_ID;
85
+ const pluginId = options.id;
89
86
 
90
87
  const pluginDataDirRoot = path.join(generatedFilesDir, PluginName);
91
88
  const dataDir = path.join(pluginDataDirRoot, pluginId);
@@ -260,9 +257,10 @@ export default async function pluginContentBlog(
260
257
 
261
258
  if (!blogPosts.length) {
262
259
  return {
260
+ blogTitle,
261
+ blogDescription,
263
262
  blogSidebarTitle,
264
263
  blogPosts: [],
265
- blogListPaginated: [],
266
264
  blogTags: {},
267
265
  blogTagsListPath,
268
266
  authorsMap,
@@ -291,15 +289,6 @@ export default async function pluginContentBlog(
291
289
  }
292
290
  });
293
291
 
294
- const blogListPaginated: BlogPaginated[] = paginateBlogPosts({
295
- blogPosts: listedBlogPosts,
296
- blogTitle,
297
- blogDescription,
298
- postsPerPageOption,
299
- basePageUrl: baseBlogUrl,
300
- pageBasePath,
301
- });
302
-
303
292
  const blogTags: BlogTags = getBlogTags({
304
293
  blogPosts,
305
294
  postsPerPageOption,
@@ -309,9 +298,10 @@ export default async function pluginContentBlog(
309
298
  });
310
299
 
311
300
  return {
301
+ blogTitle,
302
+ blogDescription,
312
303
  blogSidebarTitle,
313
304
  blogPosts,
314
- blogListPaginated,
315
305
  blogTags,
316
306
  blogTagsListPath,
317
307
  authorsMap,
package/src/options.ts CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  RouteBasePathSchema,
16
16
  URISchema,
17
17
  } from '@docusaurus/utils-validation';
18
- import {GlobExcludeDefault} from '@docusaurus/utils';
18
+ import {DEFAULT_PLUGIN_ID, GlobExcludeDefault} from '@docusaurus/utils';
19
19
  import type {
20
20
  PluginOptions,
21
21
  Options,
@@ -25,6 +25,7 @@ import type {
25
25
  import type {OptionValidationContext} from '@docusaurus/types';
26
26
 
27
27
  export const DEFAULT_OPTIONS: PluginOptions = {
28
+ id: DEFAULT_PLUGIN_ID,
28
29
  feedOptions: {
29
30
  type: ['rss', 'atom'],
30
31
  copyright: '',
@@ -431,7 +431,7 @@ declare module '@docusaurus/plugin-content-blog' {
431
431
  export type PluginOptions = MDXOptions &
432
432
  TagsPluginOptions & {
433
433
  /** Plugin ID. */
434
- id?: string;
434
+ id: string;
435
435
  /**
436
436
  * Path to the blog content directory on the file system, relative to site
437
437
  * directory.
@@ -583,9 +583,10 @@ declare module '@docusaurus/plugin-content-blog' {
583
583
  export type AuthorsMap = {[authorKey: string]: AuthorWithKey};
584
584
 
585
585
  export type BlogContent = {
586
- blogSidebarTitle: string;
586
+ blogTitle: string; // for translation purposes
587
+ blogDescription: string; // for translation purposes
588
+ blogSidebarTitle: string; // for translation purposes
587
589
  blogPosts: BlogPost[];
588
- blogListPaginated: BlogPaginated[];
589
590
  blogTags: BlogTags;
590
591
  blogTagsListPath: string;
591
592
  authorsMap?: AuthorsMap;
package/src/routes.ts CHANGED
@@ -67,27 +67,24 @@ export async function buildAllRoutes({
67
67
  blogArchiveComponent,
68
68
  routeBasePath,
69
69
  archiveBasePath,
70
- blogTitle,
71
70
  authorsBasePath,
72
71
  postsPerPage,
73
- blogDescription,
72
+ pageBasePath,
74
73
  } = options;
75
- const pluginId = options.id!;
74
+ const pluginId = options.id;
76
75
  const {createData} = actions;
77
76
  const {
77
+ blogTitle,
78
+ blogDescription,
78
79
  blogSidebarTitle,
79
80
  blogPosts,
80
- blogListPaginated,
81
81
  blogTags,
82
82
  blogTagsListPath,
83
83
  authorsMap,
84
84
  } = content;
85
85
 
86
- const authorsListPath = normalizeUrl([
87
- baseUrl,
88
- routeBasePath,
89
- authorsBasePath,
90
- ]);
86
+ const blogBasePath = normalizeUrl([baseUrl, routeBasePath]);
87
+ const authorsListPath = normalizeUrl([blogBasePath, authorsBasePath]);
91
88
 
92
89
  const listedBlogPosts = blogPosts.filter(shouldBeListed);
93
90
 
@@ -119,7 +116,7 @@ export async function buildAllRoutes({
119
116
 
120
117
  async function createBlogMetadataModule() {
121
118
  const blogMetadata: BlogMetadata = {
122
- blogBasePath: normalizeUrl([baseUrl, routeBasePath]),
119
+ blogBasePath,
123
120
  blogTitle,
124
121
  authorsListPath,
125
122
  };
@@ -156,7 +153,7 @@ export async function buildAllRoutes({
156
153
  if (archiveBasePath && listedBlogPosts.length) {
157
154
  return [
158
155
  {
159
- path: normalizeUrl([baseUrl, routeBasePath, archiveBasePath]),
156
+ path: normalizeUrl([blogBasePath, archiveBasePath]),
160
157
  component: blogArchiveComponent,
161
158
  exact: true,
162
159
  props: {
@@ -210,6 +207,15 @@ export async function buildAllRoutes({
210
207
  }
211
208
 
212
209
  function createBlogPostsPaginatedRoutes(): RouteConfig[] {
210
+ const blogListPaginated = paginateBlogPosts({
211
+ blogPosts: listedBlogPosts,
212
+ blogTitle,
213
+ blogDescription,
214
+ postsPerPageOption: postsPerPage,
215
+ basePageUrl: blogBasePath,
216
+ pageBasePath,
217
+ });
218
+
213
219
  return blogListPaginated.map((paginated) => {
214
220
  return {
215
221
  path: paginated.metadata.permalink,
@@ -5,30 +5,8 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import type {TranslationFileContent, TranslationFile} from '@docusaurus/types';
9
- import type {
10
- PluginOptions,
11
- BlogContent,
12
- BlogPaginated,
13
- } from '@docusaurus/plugin-content-blog';
14
-
15
- function translateListPage(
16
- blogListPaginated: BlogPaginated[],
17
- translations: TranslationFileContent,
18
- ) {
19
- return blogListPaginated.map((page) => {
20
- const {items, metadata} = page;
21
- return {
22
- items,
23
- metadata: {
24
- ...metadata,
25
- blogTitle: translations.title?.message ?? page.metadata.blogTitle,
26
- blogDescription:
27
- translations.description?.message ?? page.metadata.blogDescription,
28
- },
29
- };
30
- });
31
- }
8
+ import type {TranslationFile} from '@docusaurus/types';
9
+ import type {PluginOptions, BlogContent} from '@docusaurus/plugin-content-blog';
32
10
 
33
11
  export function getTranslationFiles(options: PluginOptions): TranslationFile[] {
34
12
  return [
@@ -56,14 +34,13 @@ export function translateContent(
56
34
  content: BlogContent,
57
35
  translationFiles: TranslationFile[],
58
36
  ): BlogContent {
59
- const {content: optionsTranslations} = translationFiles[0]!;
37
+ const {content: translations} = translationFiles[0]!;
60
38
  return {
61
39
  ...content,
40
+ blogTitle: translations.title?.message ?? content.blogTitle,
41
+ blogDescription:
42
+ translations.description?.message ?? content.blogDescription,
62
43
  blogSidebarTitle:
63
- optionsTranslations['sidebar.title']?.message ?? content.blogSidebarTitle,
64
- blogListPaginated: translateListPage(
65
- content.blogListPaginated,
66
- optionsTranslations,
67
- ),
44
+ translations['sidebar.title']?.message ?? content.blogSidebarTitle,
68
45
  };
69
46
  }