@docusaurus/plugin-content-blog 0.0.0-5044 → 0.0.0-5049

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 CHANGED
@@ -29,7 +29,11 @@ const AuthorsMapSchema = utils_validation_1.Joi.object()
29
29
  'object.base': "The authors map file should contain an object where each entry contains an author key and the corresponding author's data.",
30
30
  });
31
31
  function validateAuthorsMap(content) {
32
- return utils_validation_1.Joi.attempt(content, AuthorsMapSchema);
32
+ const { error, value } = AuthorsMapSchema.validate(content);
33
+ if (error) {
34
+ throw error;
35
+ }
36
+ return value;
33
37
  }
34
38
  exports.validateAuthorsMap = validateAuthorsMap;
35
39
  async function getAuthorsMap(params) {
package/lib/blogUtils.js CHANGED
@@ -161,7 +161,7 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
161
161
  const formattedDate = formatBlogPostDate(i18n.currentLocale, date, i18n.localeConfigs[i18n.currentLocale].calendar);
162
162
  const title = frontMatter.title ?? contentTitle ?? parsedBlogFileName.text;
163
163
  const description = frontMatter.description ?? excerpt ?? '';
164
- const slug = frontMatter.slug || parsedBlogFileName.slug;
164
+ const slug = frontMatter.slug ?? parsedBlogFileName.slug;
165
165
  const permalink = (0, utils_1.normalizeUrl)([baseUrl, routeBasePath, slug]);
166
166
  function getBlogEditUrl() {
167
167
  const blogPathRelative = path_1.default.relative(blogDirPath, path_1.default.resolve(blogSourceAbsolute));
@@ -210,7 +210,7 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
210
210
  defaultReadingTime,
211
211
  })
212
212
  : undefined,
213
- truncated: truncateMarker?.test(content) || false,
213
+ truncated: truncateMarker.test(content),
214
214
  authors,
215
215
  frontMatter,
216
216
  },
package/lib/index.js CHANGED
@@ -105,9 +105,6 @@ async function pluginContentBlog(context, options) {
105
105
  };
106
106
  },
107
107
  async contentLoaded({ content: blogContents, actions }) {
108
- if (!blogContents) {
109
- return;
110
- }
111
108
  const { blogListComponent, blogPostComponent, blogTagsListComponent, blogTagsPostsComponent, blogArchiveComponent, routeBasePath, archiveBasePath, } = options;
112
109
  const { addRoute, createData } = actions;
113
110
  const { blogSidebarTitle, blogPosts, blogListPaginated, blogTags, blogTagsListPath, } = blogContents;
@@ -334,10 +331,7 @@ async function pluginContentBlog(context, options) {
334
331
  });
335
332
  },
336
333
  injectHtmlTags({ content }) {
337
- if (!content.blogPosts.length) {
338
- return {};
339
- }
340
- if (!options.feedOptions?.type) {
334
+ if (!content.blogPosts.length || !options.feedOptions.type) {
341
335
  return {};
342
336
  }
343
337
  const feedTypes = options.feedOptions.type;
@@ -25,6 +25,6 @@ function markdownLoader(source) {
25
25
  if (truncated) {
26
26
  finalContent = (0, blogUtils_1.truncate)(finalContent, markdownLoaderOptions.truncateMarker);
27
27
  }
28
- return callback?.(null, finalContent);
28
+ return callback(null, finalContent);
29
29
  }
30
30
  exports.default = markdownLoader;
package/lib/options.d.ts CHANGED
@@ -7,4 +7,4 @@
7
7
  import type { PluginOptions, Options } from '@docusaurus/plugin-content-blog';
8
8
  import type { OptionValidationContext } from '@docusaurus/types';
9
9
  export declare const DEFAULT_OPTIONS: PluginOptions;
10
- export declare function validateOptions({ validate, options, }: OptionValidationContext<Options, PluginOptions>): PluginOptions;
10
+ export declare function validateOptions({ validate, options, }: OptionValidationContext<Options | undefined, PluginOptions>): PluginOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-5044",
3
+ "version": "0.0.0-5049",
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": "0.0.0-5044",
22
- "@docusaurus/logger": "0.0.0-5044",
23
- "@docusaurus/mdx-loader": "0.0.0-5044",
24
- "@docusaurus/utils": "0.0.0-5044",
25
- "@docusaurus/utils-common": "0.0.0-5044",
26
- "@docusaurus/utils-validation": "0.0.0-5044",
21
+ "@docusaurus/core": "0.0.0-5049",
22
+ "@docusaurus/logger": "0.0.0-5049",
23
+ "@docusaurus/mdx-loader": "0.0.0-5049",
24
+ "@docusaurus/utils": "0.0.0-5049",
25
+ "@docusaurus/utils-common": "0.0.0-5049",
26
+ "@docusaurus/utils-validation": "0.0.0-5049",
27
27
  "cheerio": "^1.0.0-rc.11",
28
28
  "feed": "^4.2.2",
29
29
  "fs-extra": "^10.1.0",
@@ -36,7 +36,7 @@
36
36
  "webpack": "^5.72.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@docusaurus/types": "0.0.0-5044",
39
+ "@docusaurus/types": "0.0.0-5049",
40
40
  "escape-string-regexp": "^4.0.0"
41
41
  },
42
42
  "peerDependencies": {
@@ -46,5 +46,5 @@
46
46
  "engines": {
47
47
  "node": ">=14"
48
48
  },
49
- "gitHead": "9ffd6ca265dc2af7ed5b96daf5ebf32708e899cf"
49
+ "gitHead": "527b2a01c46b67483327a1a6873fccf81bc19e2c"
50
50
  }
package/src/authors.ts CHANGED
@@ -44,7 +44,11 @@ const AuthorsMapSchema = Joi.object<AuthorsMap>()
44
44
  });
45
45
 
46
46
  export function validateAuthorsMap(content: unknown): AuthorsMap {
47
- return Joi.attempt(content, AuthorsMapSchema);
47
+ const {error, value} = AuthorsMapSchema.validate(content);
48
+ if (error) {
49
+ throw error;
50
+ }
51
+ return value;
48
52
  }
49
53
 
50
54
  export async function getAuthorsMap(params: {
package/src/blogUtils.ts CHANGED
@@ -264,7 +264,7 @@ async function processBlogSourceFile(
264
264
  const title = frontMatter.title ?? contentTitle ?? parsedBlogFileName.text;
265
265
  const description = frontMatter.description ?? excerpt ?? '';
266
266
 
267
- const slug = frontMatter.slug || parsedBlogFileName.slug;
267
+ const slug = frontMatter.slug ?? parsedBlogFileName.slug;
268
268
 
269
269
  const permalink = normalizeUrl([baseUrl, routeBasePath, slug]);
270
270
 
@@ -323,7 +323,7 @@ async function processBlogSourceFile(
323
323
  defaultReadingTime,
324
324
  })
325
325
  : undefined,
326
- truncated: truncateMarker?.test(content) || false,
326
+ truncated: truncateMarker.test(content),
327
327
  authors,
328
328
  frontMatter,
329
329
  },
package/src/index.ts CHANGED
@@ -176,10 +176,6 @@ export default async function pluginContentBlog(
176
176
  },
177
177
 
178
178
  async contentLoaded({content: blogContents, actions}) {
179
- if (!blogContents) {
180
- return;
181
- }
182
-
183
179
  const {
184
180
  blogListComponent,
185
181
  blogPostComponent,
@@ -500,11 +496,7 @@ export default async function pluginContentBlog(
500
496
  },
501
497
 
502
498
  injectHtmlTags({content}) {
503
- if (!content.blogPosts.length) {
504
- return {};
505
- }
506
-
507
- if (!options.feedOptions?.type) {
499
+ if (!content.blogPosts.length || !options.feedOptions.type) {
508
500
  return {};
509
501
  }
510
502
 
@@ -34,5 +34,5 @@ export default function markdownLoader(
34
34
  finalContent = truncate(finalContent, markdownLoaderOptions.truncateMarker);
35
35
  }
36
36
 
37
- return callback?.(null, finalContent);
37
+ return callback(null, finalContent);
38
38
  }
package/src/options.ts CHANGED
@@ -135,10 +135,7 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
135
135
  export function validateOptions({
136
136
  validate,
137
137
  options,
138
- }: OptionValidationContext<Options, PluginOptions>): PluginOptions {
139
- const validatedOptions = validate(
140
- PluginOptionSchema,
141
- options,
142
- ) as PluginOptions;
138
+ }: OptionValidationContext<Options | undefined, PluginOptions>): PluginOptions {
139
+ const validatedOptions = validate(PluginOptionSchema, options);
143
140
  return validatedOptions;
144
141
  }