@docusaurus/plugin-content-pages 0.0.0-6065 → 0.0.0-6068

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
@@ -15,13 +15,11 @@ const utils_1 = require("@docusaurus/utils");
15
15
  const mdx_loader_1 = require("@docusaurus/mdx-loader");
16
16
  const routes_1 = require("./routes");
17
17
  const content_1 = require("./content");
18
- const contentHelpers_1 = require("./contentHelpers");
19
18
  async function pluginContentPages(context, options) {
20
19
  const { siteConfig, siteDir, generatedFilesDir } = context;
21
20
  const contentPaths = (0, content_1.createPagesContentPaths)({ context, options });
22
21
  const pluginDataDirRoot = path_1.default.join(generatedFilesDir, 'docusaurus-plugin-content-pages');
23
22
  const dataDir = path_1.default.join(pluginDataDirRoot, options.id ?? utils_1.DEFAULT_PLUGIN_ID);
24
- const contentHelpers = (0, contentHelpers_1.createContentHelpers)();
25
23
  async function createPagesMDXLoaderRule() {
26
24
  const { admonitions, rehypePlugins, remarkPlugins, recmaPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
27
25
  const contentDirs = (0, content_1.getContentPathList)(contentPaths);
@@ -39,15 +37,9 @@ async function pluginContentPages(context, options) {
39
37
  // Note that metadataPath must be the same/in-sync as
40
38
  // the path from createData for each MDX.
41
39
  const aliasedSource = (0, utils_1.aliasedSitePath)(mdxPath, siteDir);
42
- const metadataPath = path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedSource)}.json`);
43
- const metadataContent = contentHelpers.sourceToPage.get(aliasedSource);
44
- return {
45
- metadataPath,
46
- metadataContent,
47
- };
40
+ return path_1.default.join(dataDir, `${(0, utils_1.docuHash)(aliasedSource)}.json`);
48
41
  },
49
- // Assets allow to convert some relative images paths to
50
- // require(...) calls
42
+ // createAssets converts relative paths to require() calls
51
43
  createAssets: ({ frontMatter }) => ({
52
44
  image: frontMatter.image,
53
45
  }),
@@ -77,7 +69,6 @@ async function pluginContentPages(context, options) {
77
69
  if (!content) {
78
70
  return;
79
71
  }
80
- contentHelpers.updateContent(content);
81
72
  await (0, routes_1.createAllRoutes)({ content, options, actions });
82
73
  },
83
74
  configureWebpack() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-pages",
3
- "version": "0.0.0-6065",
3
+ "version": "0.0.0-6068",
4
4
  "description": "Pages plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "types": "src/plugin-content-pages.d.ts",
@@ -18,11 +18,11 @@
18
18
  },
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
- "@docusaurus/core": "0.0.0-6065",
22
- "@docusaurus/mdx-loader": "0.0.0-6065",
23
- "@docusaurus/types": "0.0.0-6065",
24
- "@docusaurus/utils": "0.0.0-6065",
25
- "@docusaurus/utils-validation": "0.0.0-6065",
21
+ "@docusaurus/core": "0.0.0-6068",
22
+ "@docusaurus/mdx-loader": "0.0.0-6068",
23
+ "@docusaurus/types": "0.0.0-6068",
24
+ "@docusaurus/utils": "0.0.0-6068",
25
+ "@docusaurus/utils-validation": "0.0.0-6068",
26
26
  "fs-extra": "^11.1.1",
27
27
  "tslib": "^2.6.0",
28
28
  "webpack": "^5.88.1"
@@ -34,5 +34,5 @@
34
34
  "engines": {
35
35
  "node": ">=18.0"
36
36
  },
37
- "gitHead": "6da713a524315a36515fc3e998ff1551bfa054d2"
37
+ "gitHead": "4f0bc982b589965d7238334bb9b5bf6c483cc35a"
38
38
  }
package/src/index.ts CHANGED
@@ -24,7 +24,6 @@ import {
24
24
  getContentPathList,
25
25
  loadPagesContent,
26
26
  } from './content';
27
- import {createContentHelpers} from './contentHelpers';
28
27
  import type {LoadContext, Plugin} from '@docusaurus/types';
29
28
  import type {
30
29
  PluginOptions,
@@ -47,8 +46,6 @@ export default async function pluginContentPages(
47
46
  );
48
47
  const dataDir = path.join(pluginDataDirRoot, options.id ?? DEFAULT_PLUGIN_ID);
49
48
 
50
- const contentHelpers = createContentHelpers();
51
-
52
49
  async function createPagesMDXLoaderRule(): Promise<RuleSetRule> {
53
50
  const {
54
51
  admonitions,
@@ -76,18 +73,9 @@ export default async function pluginContentPages(
76
73
  // Note that metadataPath must be the same/in-sync as
77
74
  // the path from createData for each MDX.
78
75
  const aliasedSource = aliasedSitePath(mdxPath, siteDir);
79
- const metadataPath = path.join(
80
- dataDir,
81
- `${docuHash(aliasedSource)}.json`,
82
- );
83
- const metadataContent = contentHelpers.sourceToPage.get(aliasedSource);
84
- return {
85
- metadataPath,
86
- metadataContent,
87
- };
76
+ return path.join(dataDir, `${docuHash(aliasedSource)}.json`);
88
77
  },
89
- // Assets allow to convert some relative images paths to
90
- // require(...) calls
78
+ // createAssets converts relative paths to require() calls
91
79
  createAssets: ({frontMatter}: {frontMatter: PageFrontMatter}) => ({
92
80
  image: frontMatter.image,
93
81
  }),
@@ -125,7 +113,6 @@ export default async function pluginContentPages(
125
113
  if (!content) {
126
114
  return;
127
115
  }
128
- contentHelpers.updateContent(content);
129
116
  await createAllRoutes({content, options, actions});
130
117
  },
131
118
 
@@ -1,11 +0,0 @@
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
- import type { LoadedContent, Metadata } from '@docusaurus/plugin-content-pages';
8
- export declare function createContentHelpers(): {
9
- updateContent: (content: LoadedContent) => void;
10
- sourceToPage: Map<string, Metadata>;
11
- };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- /**
3
- * Copyright (c) Facebook, Inc. and its affiliates.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.createContentHelpers = createContentHelpers;
10
- function indexPagesBySource(content) {
11
- return new Map(content.map((page) => [page.source, page]));
12
- }
13
- // TODO this is bad, we should have a better way to do this (new lifecycle?)
14
- // The source to page/permalink is a mutable map passed to the mdx loader
15
- // See https://github.com/facebook/docusaurus/pull/10457
16
- // See https://github.com/facebook/docusaurus/pull/10185
17
- function createContentHelpers() {
18
- const sourceToPage = new Map();
19
- // const sourceToPermalink = new Map<string, string>();
20
- // Mutable map update :/
21
- function updateContent(content) {
22
- sourceToPage.clear();
23
- // sourceToPermalink.clear();
24
- indexPagesBySource(content).forEach((value, key) => {
25
- sourceToPage.set(key, value);
26
- // sourceToPermalink.set(key, value.metadata.permalink);
27
- });
28
- }
29
- return { updateContent, sourceToPage };
30
- }
@@ -1,33 +0,0 @@
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
-
8
- import type {LoadedContent, Metadata} from '@docusaurus/plugin-content-pages';
9
-
10
- function indexPagesBySource(content: LoadedContent): Map<string, Metadata> {
11
- return new Map(content.map((page) => [page.source, page]));
12
- }
13
-
14
- // TODO this is bad, we should have a better way to do this (new lifecycle?)
15
- // The source to page/permalink is a mutable map passed to the mdx loader
16
- // See https://github.com/facebook/docusaurus/pull/10457
17
- // See https://github.com/facebook/docusaurus/pull/10185
18
- export function createContentHelpers() {
19
- const sourceToPage = new Map<string, Metadata>();
20
- // const sourceToPermalink = new Map<string, string>();
21
-
22
- // Mutable map update :/
23
- function updateContent(content: LoadedContent): void {
24
- sourceToPage.clear();
25
- // sourceToPermalink.clear();
26
- indexPagesBySource(content).forEach((value, key) => {
27
- sourceToPage.set(key, value);
28
- // sourceToPermalink.set(key, value.metadata.permalink);
29
- });
30
- }
31
-
32
- return {updateContent, sourceToPage};
33
- }