@docusaurus/plugin-content-docs 0.0.0-5868 → 0.0.0-5869

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/routes.js CHANGED
@@ -13,6 +13,12 @@ const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
13
13
  const utils_1 = require("@docusaurus/utils");
14
14
  const props_1 = require("./props");
15
15
  const tags_1 = require("./tags");
16
+ function createDocRouteMetadata(docMeta) {
17
+ return {
18
+ sourceFilePath: (0, utils_1.aliasedSitePathToRelativePath)(docMeta.source),
19
+ lastUpdatedAt: docMeta.lastUpdatedAt,
20
+ };
21
+ }
16
22
  async function buildVersionCategoryGeneratedIndexRoutes({ version, actions, options, aliasedSource, }) {
17
23
  const slugs = (0, utils_1.createSlugger)();
18
24
  async function buildCategoryGeneratedIndexRoute(categoryGeneratedIndex) {
@@ -34,23 +40,24 @@ async function buildVersionCategoryGeneratedIndexRoutes({ version, actions, opti
34
40
  return Promise.all(version.categoryGeneratedIndices.map(buildCategoryGeneratedIndexRoute));
35
41
  }
36
42
  async function buildVersionDocRoutes({ version, actions, options, }) {
37
- return Promise.all(version.docs.map(async (metadataItem) => {
43
+ return Promise.all(version.docs.map(async (doc) => {
38
44
  await actions.createData(
39
45
  // Note that this created data path must be in sync with
40
46
  // metadataPath provided to mdx-loader.
41
- `${(0, utils_1.docuHash)(metadataItem.source)}.json`, JSON.stringify(metadataItem, null, 2));
47
+ `${(0, utils_1.docuHash)(doc.source)}.json`, JSON.stringify(doc, null, 2));
42
48
  const docRoute = {
43
- path: metadataItem.permalink,
49
+ path: doc.permalink,
44
50
  component: options.docItemComponent,
45
51
  exact: true,
46
52
  modules: {
47
- content: metadataItem.source,
53
+ content: doc.source,
48
54
  },
55
+ metadata: createDocRouteMetadata(doc),
49
56
  // Because the parent (DocRoot) comp need to access it easily
50
57
  // This permits to render the sidebar once without unmount/remount when
51
58
  // navigating (and preserve sidebar state)
52
- ...(metadataItem.sidebar && {
53
- sidebar: metadataItem.sidebar,
59
+ ...(doc.sidebar && {
60
+ sidebar: doc.sidebar,
54
61
  }),
55
62
  };
56
63
  return docRoute;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-5868",
3
+ "version": "0.0.0-5869",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "sideEffects": false,
@@ -35,13 +35,13 @@
35
35
  },
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
- "@docusaurus/core": "0.0.0-5868",
39
- "@docusaurus/logger": "0.0.0-5868",
40
- "@docusaurus/mdx-loader": "0.0.0-5868",
41
- "@docusaurus/module-type-aliases": "0.0.0-5868",
42
- "@docusaurus/types": "0.0.0-5868",
43
- "@docusaurus/utils": "0.0.0-5868",
44
- "@docusaurus/utils-validation": "0.0.0-5868",
38
+ "@docusaurus/core": "0.0.0-5869",
39
+ "@docusaurus/logger": "0.0.0-5869",
40
+ "@docusaurus/mdx-loader": "0.0.0-5869",
41
+ "@docusaurus/module-type-aliases": "0.0.0-5869",
42
+ "@docusaurus/types": "0.0.0-5869",
43
+ "@docusaurus/utils": "0.0.0-5869",
44
+ "@docusaurus/utils-validation": "0.0.0-5869",
45
45
  "@types/react-router-config": "^5.0.7",
46
46
  "combine-promises": "^1.1.0",
47
47
  "fs-extra": "^11.1.1",
@@ -65,5 +65,5 @@
65
65
  "engines": {
66
66
  "node": ">=18.0"
67
67
  },
68
- "gitHead": "82bedf4154c3c66e27563a6735763c5b08518820"
68
+ "gitHead": "b04beb0c2db54db2bf9f87733009a35221383933"
69
69
  }
@@ -17,6 +17,7 @@ declare module '@docusaurus/plugin-content-docs' {
17
17
  TagModule,
18
18
  Tag,
19
19
  FrontMatterLastUpdate,
20
+ LastUpdateData,
20
21
  } from '@docusaurus/utils';
21
22
  import type {Plugin, LoadContext} from '@docusaurus/types';
22
23
  import type {Overwrite, Required} from 'utility-types';
@@ -397,13 +398,6 @@ declare module '@docusaurus/plugin-content-docs' {
397
398
  last_update?: FrontMatterLastUpdate;
398
399
  };
399
400
 
400
- export type LastUpdateData = {
401
- /** A timestamp in **seconds**, directly acquired from `git log`. */
402
- lastUpdatedAt?: number;
403
- /** The author's name directly acquired from `git log`. */
404
- lastUpdatedBy?: string;
405
- };
406
-
407
401
  export type DocMetadataBase = LastUpdateData & {
408
402
  /**
409
403
  * The document id.
package/src/routes.ts CHANGED
@@ -7,21 +7,38 @@
7
7
 
8
8
  import _ from 'lodash';
9
9
  import logger from '@docusaurus/logger';
10
- import {docuHash, createSlugger, normalizeUrl} from '@docusaurus/utils';
10
+ import {
11
+ docuHash,
12
+ createSlugger,
13
+ normalizeUrl,
14
+ aliasedSitePathToRelativePath,
15
+ } from '@docusaurus/utils';
11
16
  import {
12
17
  toTagDocListProp,
13
18
  toTagsListTagsProp,
14
19
  toVersionMetadataProp,
15
20
  } from './props';
16
21
  import {getVersionTags} from './tags';
17
- import type {PluginContentLoadedActions, RouteConfig} from '@docusaurus/types';
22
+ import type {
23
+ PluginContentLoadedActions,
24
+ RouteConfig,
25
+ RouteMetadata,
26
+ } from '@docusaurus/types';
18
27
  import type {FullVersion, VersionTag} from './types';
19
28
  import type {
20
29
  CategoryGeneratedIndexMetadata,
30
+ DocMetadata,
21
31
  PluginOptions,
22
32
  PropTagsListPage,
23
33
  } from '@docusaurus/plugin-content-docs';
24
34
 
35
+ function createDocRouteMetadata(docMeta: DocMetadata): RouteMetadata {
36
+ return {
37
+ sourceFilePath: aliasedSitePathToRelativePath(docMeta.source),
38
+ lastUpdatedAt: docMeta.lastUpdatedAt,
39
+ };
40
+ }
41
+
25
42
  async function buildVersionCategoryGeneratedIndexRoutes({
26
43
  version,
27
44
  actions,
@@ -68,26 +85,27 @@ async function buildVersionDocRoutes({
68
85
  options,
69
86
  }: BuildVersionRoutesParam): Promise<RouteConfig[]> {
70
87
  return Promise.all(
71
- version.docs.map(async (metadataItem) => {
88
+ version.docs.map(async (doc) => {
72
89
  await actions.createData(
73
90
  // Note that this created data path must be in sync with
74
91
  // metadataPath provided to mdx-loader.
75
- `${docuHash(metadataItem.source)}.json`,
76
- JSON.stringify(metadataItem, null, 2),
92
+ `${docuHash(doc.source)}.json`,
93
+ JSON.stringify(doc, null, 2),
77
94
  );
78
95
 
79
96
  const docRoute: RouteConfig = {
80
- path: metadataItem.permalink,
97
+ path: doc.permalink,
81
98
  component: options.docItemComponent,
82
99
  exact: true,
83
100
  modules: {
84
- content: metadataItem.source,
101
+ content: doc.source,
85
102
  },
103
+ metadata: createDocRouteMetadata(doc),
86
104
  // Because the parent (DocRoot) comp need to access it easily
87
105
  // This permits to render the sidebar once without unmount/remount when
88
106
  // navigating (and preserve sidebar state)
89
- ...(metadataItem.sidebar && {
90
- sidebar: metadataItem.sidebar,
107
+ ...(doc.sidebar && {
108
+ sidebar: doc.sidebar,
91
109
  }),
92
110
  };
93
111