@docusaurus/plugin-content-blog 0.0.0-5865 → 0.0.0-5868

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/blogUtils.js CHANGED
@@ -127,6 +127,7 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
127
127
  parseFrontMatter,
128
128
  });
129
129
  const aliasedSource = (0, utils_1.aliasedSitePath)(blogSourceAbsolute, siteDir);
130
+ const lastUpdate = await (0, utils_1.readLastUpdateData)(blogSourceAbsolute, options, frontMatter.last_update);
130
131
  const draft = (0, utils_1.isDraft)({ frontMatter });
131
132
  const unlisted = (0, utils_1.isUnlisted)({ frontMatter });
132
133
  if (draft) {
@@ -216,6 +217,8 @@ async function processBlogSourceFile(blogSourceRelative, contentPaths, context,
216
217
  authors,
217
218
  frontMatter,
218
219
  unlisted,
220
+ lastUpdatedAt: lastUpdate.lastUpdatedAt,
221
+ lastUpdatedBy: lastUpdate.lastUpdatedBy,
219
222
  },
220
223
  content,
221
224
  };
@@ -1,9 +1,3 @@
1
- /**
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
1
  import type { BlogPostFrontMatter } from '@docusaurus/plugin-content-blog';
8
2
  export declare function validateBlogPostFrontMatter(frontMatter: {
9
3
  [key: string]: unknown;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateBlogPostFrontMatter = void 0;
2
4
  /**
3
5
  * Copyright (c) Facebook, Inc. and its affiliates.
4
6
  *
5
7
  * This source code is licensed under the MIT license found in the
6
8
  * LICENSE file in the root directory of this source tree.
7
9
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.validateBlogPostFrontMatter = void 0;
10
10
  const utils_validation_1 = require("@docusaurus/utils-validation");
11
11
  const BlogPostFrontMatterAuthorSchema = utils_validation_1.JoiFrontMatter.object({
12
12
  key: utils_validation_1.JoiFrontMatter.string(),
@@ -52,6 +52,7 @@ const BlogFrontMatterSchema = utils_validation_1.JoiFrontMatter.object({
52
52
  keywords: utils_validation_1.JoiFrontMatter.array().items(utils_validation_1.JoiFrontMatter.string().required()),
53
53
  hide_table_of_contents: utils_validation_1.JoiFrontMatter.boolean(),
54
54
  ...utils_validation_1.FrontMatterTOCHeadingLevels,
55
+ last_update: utils_validation_1.FrontMatterLastUpdateSchema,
55
56
  })
56
57
  .messages({
57
58
  'deprecate.error': '{#label} blog frontMatter field is deprecated. Please use {#alternative} instead.',
package/lib/options.js CHANGED
@@ -39,6 +39,8 @@ exports.DEFAULT_OPTIONS = {
39
39
  authorsMapPath: 'authors.yml',
40
40
  readingTime: ({ content, defaultReadingTime }) => defaultReadingTime({ content }),
41
41
  sortPosts: 'descending',
42
+ showLastUpdateTime: false,
43
+ showLastUpdateAuthor: false,
42
44
  processBlogPosts: async () => undefined,
43
45
  };
44
46
  const PluginOptionSchema = utils_validation_1.Joi.object({
@@ -104,6 +106,8 @@ const PluginOptionSchema = utils_validation_1.Joi.object({
104
106
  sortPosts: utils_validation_1.Joi.string()
105
107
  .valid('descending', 'ascending')
106
108
  .default(exports.DEFAULT_OPTIONS.sortPosts),
109
+ showLastUpdateTime: utils_validation_1.Joi.bool().default(exports.DEFAULT_OPTIONS.showLastUpdateTime),
110
+ showLastUpdateAuthor: utils_validation_1.Joi.bool().default(exports.DEFAULT_OPTIONS.showLastUpdateAuthor),
107
111
  processBlogPosts: utils_validation_1.Joi.function()
108
112
  .optional()
109
113
  .default(() => exports.DEFAULT_OPTIONS.processBlogPosts),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-blog",
3
- "version": "0.0.0-5865",
3
+ "version": "0.0.0-5868",
4
4
  "description": "Blog plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-blog.d.ts",
@@ -31,13 +31,13 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "dependencies": {
34
- "@docusaurus/core": "0.0.0-5865",
35
- "@docusaurus/logger": "0.0.0-5865",
36
- "@docusaurus/mdx-loader": "0.0.0-5865",
37
- "@docusaurus/types": "0.0.0-5865",
38
- "@docusaurus/utils": "0.0.0-5865",
39
- "@docusaurus/utils-common": "0.0.0-5865",
40
- "@docusaurus/utils-validation": "0.0.0-5865",
34
+ "@docusaurus/core": "0.0.0-5868",
35
+ "@docusaurus/logger": "0.0.0-5868",
36
+ "@docusaurus/mdx-loader": "0.0.0-5868",
37
+ "@docusaurus/types": "0.0.0-5868",
38
+ "@docusaurus/utils": "0.0.0-5868",
39
+ "@docusaurus/utils-common": "0.0.0-5868",
40
+ "@docusaurus/utils-validation": "0.0.0-5868",
41
41
  "cheerio": "^1.0.0-rc.12",
42
42
  "feed": "^4.2.2",
43
43
  "fs-extra": "^11.1.1",
@@ -59,5 +59,5 @@
59
59
  "devDependencies": {
60
60
  "@total-typescript/shoehorn": "^0.1.2"
61
61
  },
62
- "gitHead": "0ce2912136d682daeb3abe9d1284a49f9c011efa"
62
+ "gitHead": "82bedf4154c3c66e27563a6735763c5b08518820"
63
63
  }
package/src/blogUtils.ts CHANGED
@@ -26,6 +26,7 @@ import {
26
26
  getContentPathList,
27
27
  isUnlisted,
28
28
  isDraft,
29
+ readLastUpdateData,
29
30
  } from '@docusaurus/utils';
30
31
  import {validateBlogPostFrontMatter} from './frontMatter';
31
32
  import {type AuthorsMap, getAuthorsMap, getBlogPostAuthors} from './authors';
@@ -231,6 +232,12 @@ async function processBlogSourceFile(
231
232
 
232
233
  const aliasedSource = aliasedSitePath(blogSourceAbsolute, siteDir);
233
234
 
235
+ const lastUpdate = await readLastUpdateData(
236
+ blogSourceAbsolute,
237
+ options,
238
+ frontMatter.last_update,
239
+ );
240
+
234
241
  const draft = isDraft({frontMatter});
235
242
  const unlisted = isUnlisted({frontMatter});
236
243
 
@@ -337,6 +344,8 @@ async function processBlogSourceFile(
337
344
  authors,
338
345
  frontMatter,
339
346
  unlisted,
347
+ lastUpdatedAt: lastUpdate.lastUpdatedAt,
348
+ lastUpdatedBy: lastUpdate.lastUpdatedBy,
340
349
  },
341
350
  content,
342
351
  };
@@ -4,14 +4,14 @@
4
4
  * This source code is licensed under the MIT license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
-
8
7
  import {
8
+ ContentVisibilitySchema,
9
+ FrontMatterLastUpdateSchema,
10
+ FrontMatterTOCHeadingLevels,
11
+ FrontMatterTagsSchema,
9
12
  JoiFrontMatter as Joi, // Custom instance for front matter
10
13
  URISchema,
11
14
  validateFrontMatter,
12
- FrontMatterTagsSchema,
13
- FrontMatterTOCHeadingLevels,
14
- ContentVisibilitySchema,
15
15
  } from '@docusaurus/utils-validation';
16
16
  import type {BlogPostFrontMatter} from '@docusaurus/plugin-content-blog';
17
17
 
@@ -69,6 +69,7 @@ const BlogFrontMatterSchema = Joi.object<BlogPostFrontMatter>({
69
69
  hide_table_of_contents: Joi.boolean(),
70
70
 
71
71
  ...FrontMatterTOCHeadingLevels,
72
+ last_update: FrontMatterLastUpdateSchema,
72
73
  })
73
74
  .messages({
74
75
  'deprecate.error':
package/src/options.ts CHANGED
@@ -51,6 +51,8 @@ export const DEFAULT_OPTIONS: PluginOptions = {
51
51
  authorsMapPath: 'authors.yml',
52
52
  readingTime: ({content, defaultReadingTime}) => defaultReadingTime({content}),
53
53
  sortPosts: 'descending',
54
+ showLastUpdateTime: false,
55
+ showLastUpdateAuthor: false,
54
56
  processBlogPosts: async () => undefined,
55
57
  };
56
58
 
@@ -135,6 +137,10 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
135
137
  sortPosts: Joi.string()
136
138
  .valid('descending', 'ascending')
137
139
  .default(DEFAULT_OPTIONS.sortPosts),
140
+ showLastUpdateTime: Joi.bool().default(DEFAULT_OPTIONS.showLastUpdateTime),
141
+ showLastUpdateAuthor: Joi.bool().default(
142
+ DEFAULT_OPTIONS.showLastUpdateAuthor,
143
+ ),
138
144
  processBlogPosts: Joi.function()
139
145
  .optional()
140
146
  .default(() => DEFAULT_OPTIONS.processBlogPosts),
@@ -10,7 +10,12 @@
10
10
  declare module '@docusaurus/plugin-content-blog' {
11
11
  import type {LoadedMDXContent} from '@docusaurus/mdx-loader';
12
12
  import type {MDXOptions} from '@docusaurus/mdx-loader';
13
- import type {FrontMatterTag, Tag} from '@docusaurus/utils';
13
+ import type {
14
+ FrontMatterTag,
15
+ Tag,
16
+ LastUpdateData,
17
+ FrontMatterLastUpdate,
18
+ } from '@docusaurus/utils';
14
19
  import type {DocusaurusConfig, Plugin, LoadContext} from '@docusaurus/types';
15
20
  import type {Item as FeedItem} from 'feed';
16
21
  import type {Overwrite} from 'utility-types';
@@ -156,6 +161,8 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the
156
161
  toc_min_heading_level?: number;
157
162
  /** Maximum TOC heading level. Must be between 2 and 6. */
158
163
  toc_max_heading_level?: number;
164
+ /** Allows overriding the last updated author and/or date. */
165
+ last_update?: FrontMatterLastUpdate;
159
166
  };
160
167
 
161
168
  export type BlogPostFrontMatterAuthor = Author & {
@@ -180,7 +187,7 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the
180
187
  | BlogPostFrontMatterAuthor
181
188
  | (string | BlogPostFrontMatterAuthor)[];
182
189
 
183
- export type BlogPostMetadata = {
190
+ export type BlogPostMetadata = LastUpdateData & {
184
191
  /** Path to the Markdown source, with `@site` alias. */
185
192
  readonly source: string;
186
193
  /**
@@ -426,6 +433,10 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the
426
433
  readingTime: ReadingTimeFunctionOption;
427
434
  /** Governs the direction of blog post sorting. */
428
435
  sortPosts: 'ascending' | 'descending';
436
+ /** Whether to display the last date the doc was updated. */
437
+ showLastUpdateTime: boolean;
438
+ /** Whether to display the author who last updated the doc. */
439
+ showLastUpdateAuthor: boolean;
429
440
  /** An optional function which can be used to transform blog posts
430
441
  * (filter, modify, delete, etc...).
431
442
  */