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

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
@@ -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/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-6444",
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-6444",
35
+ "@docusaurus/logger": "3.9.2-canary-6444",
36
+ "@docusaurus/mdx-loader": "3.9.2-canary-6444",
37
+ "@docusaurus/theme-common": "3.9.2-canary-6444",
38
+ "@docusaurus/types": "3.9.2-canary-6444",
39
+ "@docusaurus/utils": "3.9.2-canary-6444",
40
+ "@docusaurus/utils-common": "3.9.2-canary-6444",
41
+ "@docusaurus/utils-validation": "3.9.2-canary-6444",
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": "9cdcad8d8b49a44944612ec735b8957cfd11bd40"
66
66
  }
package/src/index.ts CHANGED
@@ -25,7 +25,6 @@ import {getTagsFilePathsToWatch} from '@docusaurus/utils-validation';
25
25
  import {createMDXLoaderItem} from '@docusaurus/mdx-loader';
26
26
  import {
27
27
  getBlogTags,
28
- paginateBlogPosts,
29
28
  shouldBeListed,
30
29
  applyProcessBlogPosts,
31
30
  generateBlogPosts,
@@ -45,7 +44,6 @@ import type {
45
44
  Assets,
46
45
  BlogTags,
47
46
  BlogContent,
48
- BlogPaginated,
49
47
  } from '@docusaurus/plugin-content-blog';
50
48
  import type {RuleSetRule, RuleSetUseItem} from 'webpack';
51
49
 
@@ -260,9 +258,10 @@ export default async function pluginContentBlog(
260
258
 
261
259
  if (!blogPosts.length) {
262
260
  return {
261
+ blogTitle,
262
+ blogDescription,
263
263
  blogSidebarTitle,
264
264
  blogPosts: [],
265
- blogListPaginated: [],
266
265
  blogTags: {},
267
266
  blogTagsListPath,
268
267
  authorsMap,
@@ -291,15 +290,6 @@ export default async function pluginContentBlog(
291
290
  }
292
291
  });
293
292
 
294
- const blogListPaginated: BlogPaginated[] = paginateBlogPosts({
295
- blogPosts: listedBlogPosts,
296
- blogTitle,
297
- blogDescription,
298
- postsPerPageOption,
299
- basePageUrl: baseBlogUrl,
300
- pageBasePath,
301
- });
302
-
303
293
  const blogTags: BlogTags = getBlogTags({
304
294
  blogPosts,
305
295
  postsPerPageOption,
@@ -309,9 +299,10 @@ export default async function pluginContentBlog(
309
299
  });
310
300
 
311
301
  return {
302
+ blogTitle,
303
+ blogDescription,
312
304
  blogSidebarTitle,
313
305
  blogPosts,
314
- blogListPaginated,
315
306
  blogTags,
316
307
  blogTagsListPath,
317
308
  authorsMap,
@@ -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
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
  }