@docusaurus/plugin-content-blog 0.0.0-4449 → 0.0.0-4456

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
@@ -10,12 +10,13 @@ exports.getBlogPostAuthors = exports.getAuthorsMap = exports.validateAuthorsMap
10
10
  const utils_1 = require("@docusaurus/utils");
11
11
  const utils_validation_1 = require("@docusaurus/utils-validation");
12
12
  const AuthorsMapSchema = utils_validation_1.Joi.object().pattern(utils_validation_1.Joi.string(), utils_validation_1.Joi.object({
13
- name: utils_validation_1.Joi.string().required(),
13
+ name: utils_validation_1.Joi.string(),
14
14
  url: utils_validation_1.URISchema,
15
15
  imageURL: utils_validation_1.URISchema,
16
16
  title: utils_validation_1.Joi.string(),
17
17
  })
18
18
  .rename('image_url', 'imageURL')
19
+ .or('name', 'imageURL')
19
20
  .unknown()
20
21
  .required());
21
22
  function validateAuthorsMap(content) {
@@ -38,7 +39,6 @@ function getFrontMatterAuthorLegacy(frontMatter) {
38
39
  const title = (_a = frontMatter.author_title) !== null && _a !== void 0 ? _a : frontMatter.authorTitle;
39
40
  const url = (_b = frontMatter.author_url) !== null && _b !== void 0 ? _b : frontMatter.authorURL;
40
41
  const imageURL = (_c = frontMatter.author_image_url) !== null && _c !== void 0 ? _c : frontMatter.authorImageURL;
41
- // Shouldn't we require at least an author name?
42
42
  if (name || title || url || imageURL) {
43
43
  return {
44
44
  name,
@@ -15,7 +15,7 @@ const BlogPostFrontMatterAuthorSchema = utils_validation_1.JoiFrontMatter.object
15
15
  url: utils_validation_1.URISchema,
16
16
  imageURL: utils_validation_1.JoiFrontMatter.string(),
17
17
  })
18
- .or('key', 'name')
18
+ .or('key', 'name', 'imageURL')
19
19
  .rename('image_url', 'imageURL', { alias: true });
20
20
  const FrontMatterAuthorErrorMessage = '{{#label}} does not look like a valid blog post author. Please use an author key or an author object (with a key and/or name).';
21
21
  const BlogFrontMatterSchema = utils_validation_1.JoiFrontMatter.object({
package/lib/index.js CHANGED
@@ -135,21 +135,23 @@ async function pluginContentBlog(context, options) {
135
135
  const sidebarBlogPosts = options.blogSidebarCount === 'ALL'
136
136
  ? blogPosts
137
137
  : blogPosts.slice(0, options.blogSidebarCount);
138
- const archiveUrl = (0, utils_1.normalizeUrl)([
139
- baseUrl,
140
- routeBasePath,
141
- archiveBasePath,
142
- ]);
143
- // creates a blog archive route
144
- const archiveProp = await createData(`${(0, utils_1.docuHash)(archiveUrl)}.json`, JSON.stringify({ blogPosts }, null, 2));
145
- addRoute({
146
- path: archiveUrl,
147
- component: '@theme/BlogArchivePage',
148
- exact: true,
149
- modules: {
150
- archive: aliasedSource(archiveProp),
151
- },
152
- });
138
+ if (archiveBasePath) {
139
+ const archiveUrl = (0, utils_1.normalizeUrl)([
140
+ baseUrl,
141
+ routeBasePath,
142
+ archiveBasePath,
143
+ ]);
144
+ // creates a blog archive route
145
+ const archiveProp = await createData(`${(0, utils_1.docuHash)(archiveUrl)}.json`, JSON.stringify({ blogPosts }, null, 2));
146
+ addRoute({
147
+ path: archiveUrl,
148
+ component: '@theme/BlogArchivePage',
149
+ exact: true,
150
+ modules: {
151
+ archive: aliasedSource(archiveProp),
152
+ },
153
+ });
154
+ }
153
155
  // This prop is useful to provide the blog list sidebar
154
156
  const sidebarProp = await createData(
155
157
  // Note that this created data path must be in sync with
@@ -40,7 +40,9 @@ exports.DEFAULT_OPTIONS = {
40
40
  };
41
41
  exports.PluginOptionSchema = utils_validation_1.Joi.object({
42
42
  path: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.path),
43
- archiveBasePath: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.archiveBasePath),
43
+ archiveBasePath: utils_validation_1.Joi.string()
44
+ .default(exports.DEFAULT_OPTIONS.archiveBasePath)
45
+ .allow(null),
44
46
  routeBasePath: utils_validation_1.Joi.string()
45
47
  // '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
46
48
  // .allow('')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-4449",
3
+ "version": "0.0.0-4456",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-4449",
22
- "@docusaurus/logger": "0.0.0-4449",
23
- "@docusaurus/mdx-loader": "0.0.0-4449",
24
- "@docusaurus/utils": "0.0.0-4449",
25
- "@docusaurus/utils-validation": "0.0.0-4449",
21
+ "@docusaurus/core": "0.0.0-4456",
22
+ "@docusaurus/logger": "0.0.0-4456",
23
+ "@docusaurus/mdx-loader": "0.0.0-4456",
24
+ "@docusaurus/utils": "0.0.0-4456",
25
+ "@docusaurus/utils-validation": "0.0.0-4456",
26
26
  "escape-string-regexp": "^4.0.0",
27
27
  "feed": "^4.2.2",
28
28
  "fs-extra": "^10.0.0",
@@ -36,7 +36,7 @@
36
36
  "webpack": "^5.61.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@docusaurus/types": "0.0.0-4449"
39
+ "@docusaurus/types": "0.0.0-4456"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "react": "^16.8.4 || ^17.0.0",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=14"
47
47
  },
48
- "gitHead": "45c2cbd06d5b7b76e182d70bebdf2b0777b59d30"
48
+ "gitHead": "9cf25406f271f6c673c6f3cd58048b3c2994642b"
49
49
  }
package/src/authors.ts CHANGED
@@ -20,12 +20,13 @@ export type AuthorsMap = Record<string, Author>;
20
20
  const AuthorsMapSchema = Joi.object<AuthorsMap>().pattern(
21
21
  Joi.string(),
22
22
  Joi.object({
23
- name: Joi.string().required(),
23
+ name: Joi.string(),
24
24
  url: URISchema,
25
25
  imageURL: URISchema,
26
26
  title: Joi.string(),
27
27
  })
28
28
  .rename('image_url', 'imageURL')
29
+ .or('name', 'imageURL')
29
30
  .unknown()
30
31
  .required(),
31
32
  );
@@ -63,7 +64,6 @@ function getFrontMatterAuthorLegacy(
63
64
  const url = frontMatter.author_url ?? frontMatter.authorURL;
64
65
  const imageURL = frontMatter.author_image_url ?? frontMatter.authorImageURL;
65
66
 
66
- // Shouldn't we require at least an author name?
67
67
  if (name || title || url || imageURL) {
68
68
  return {
69
69
  name,
@@ -21,7 +21,7 @@ const BlogPostFrontMatterAuthorSchema = Joi.object({
21
21
  url: URISchema,
22
22
  imageURL: Joi.string(),
23
23
  })
24
- .or('key', 'name')
24
+ .or('key', 'name', 'imageURL')
25
25
  .rename('image_url', 'imageURL', {alias: true});
26
26
 
27
27
  const FrontMatterAuthorErrorMessage =
package/src/index.ts CHANGED
@@ -242,25 +242,26 @@ export default async function pluginContentBlog(
242
242
  ? blogPosts
243
243
  : blogPosts.slice(0, options.blogSidebarCount);
244
244
 
245
- const archiveUrl = normalizeUrl([
246
- baseUrl,
247
- routeBasePath,
248
- archiveBasePath,
249
- ]);
250
-
251
- // creates a blog archive route
252
- const archiveProp = await createData(
253
- `${docuHash(archiveUrl)}.json`,
254
- JSON.stringify({blogPosts}, null, 2),
255
- );
256
- addRoute({
257
- path: archiveUrl,
258
- component: '@theme/BlogArchivePage',
259
- exact: true,
260
- modules: {
261
- archive: aliasedSource(archiveProp),
262
- },
263
- });
245
+ if (archiveBasePath) {
246
+ const archiveUrl = normalizeUrl([
247
+ baseUrl,
248
+ routeBasePath,
249
+ archiveBasePath,
250
+ ]);
251
+ // creates a blog archive route
252
+ const archiveProp = await createData(
253
+ `${docuHash(archiveUrl)}.json`,
254
+ JSON.stringify({blogPosts}, null, 2),
255
+ );
256
+ addRoute({
257
+ path: archiveUrl,
258
+ component: '@theme/BlogArchivePage',
259
+ exact: true,
260
+ modules: {
261
+ archive: aliasedSource(archiveProp),
262
+ },
263
+ });
264
+ }
264
265
 
265
266
  // This prop is useful to provide the blog list sidebar
266
267
  const sidebarProp = await createData(
@@ -112,7 +112,7 @@ declare module '@docusaurus/plugin-content-blog' {
112
112
  path: string;
113
113
  routeBasePath: string;
114
114
  tagsBasePath: string;
115
- archiveBasePath: string;
115
+ archiveBasePath: string | null;
116
116
  include: string[];
117
117
  exclude: string[];
118
118
  postsPerPage: number | 'ALL';
@@ -47,7 +47,9 @@ export const DEFAULT_OPTIONS: PluginOptions = {
47
47
 
48
48
  export const PluginOptionSchema = Joi.object<PluginOptions>({
49
49
  path: Joi.string().default(DEFAULT_OPTIONS.path),
50
- archiveBasePath: Joi.string().default(DEFAULT_OPTIONS.archiveBasePath),
50
+ archiveBasePath: Joi.string()
51
+ .default(DEFAULT_OPTIONS.archiveBasePath)
52
+ .allow(null),
51
53
  routeBasePath: Joi.string()
52
54
  // '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
53
55
  // .allow('')