@docusaurus/plugin-content-pages 3.8.1 → 3.9.0-canary-6406

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/content.d.ts CHANGED
@@ -4,18 +4,17 @@
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
+ import { type ContentPaths } from '@docusaurus/utils';
7
8
  import type { LoadContext } from '@docusaurus/types';
8
- import type { PagesContentPaths } from './types';
9
9
  import type { PluginOptions, LoadedContent } from '@docusaurus/plugin-content-pages';
10
10
  export declare function createPagesContentPaths({ context, options, }: {
11
11
  context: LoadContext;
12
12
  options: PluginOptions;
13
- }): PagesContentPaths;
14
- export declare function getContentPathList(contentPaths: PagesContentPaths): string[];
13
+ }): ContentPaths;
15
14
  type LoadContentParams = {
16
15
  context: LoadContext;
17
16
  options: PluginOptions;
18
- contentPaths: PagesContentPaths;
17
+ contentPaths: ContentPaths;
19
18
  };
20
19
  export declare function loadPagesContent(params: LoadContentParams): Promise<LoadedContent>;
21
20
  export {};
package/lib/content.js CHANGED
@@ -7,7 +7,6 @@
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.createPagesContentPaths = createPagesContentPaths;
10
- exports.getContentPathList = getContentPathList;
11
10
  exports.loadPagesContent = loadPagesContent;
12
11
  const tslib_1 = require("tslib");
13
12
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
@@ -16,18 +15,18 @@ const utils_1 = require("@docusaurus/utils");
16
15
  const frontMatter_1 = require("./frontMatter");
17
16
  function createPagesContentPaths({ context, options, }) {
18
17
  const { siteDir, localizationDir } = context;
18
+ const shouldTranslate = (0, utils_1.getLocaleConfig)(context.i18n).translate;
19
19
  return {
20
20
  contentPath: path_1.default.resolve(siteDir, options.path),
21
- contentPathLocalized: (0, utils_1.getPluginI18nPath)({
22
- localizationDir,
23
- pluginName: 'docusaurus-plugin-content-pages',
24
- pluginId: options.id,
25
- }),
21
+ contentPathLocalized: shouldTranslate
22
+ ? (0, utils_1.getPluginI18nPath)({
23
+ localizationDir,
24
+ pluginName: 'docusaurus-plugin-content-pages',
25
+ pluginId: options.id,
26
+ })
27
+ : undefined,
26
28
  };
27
29
  }
28
- function getContentPathList(contentPaths) {
29
- return [contentPaths.contentPathLocalized, contentPaths.contentPath];
30
- }
31
30
  const isMarkdownSource = (source) => source.endsWith('.md') || source.endsWith('.mdx');
32
31
  async function loadPagesContent(params) {
33
32
  const { options } = params;
@@ -52,7 +51,7 @@ async function processPageSourceFile(relativeSource, params) {
52
51
  const { siteConfig, baseUrl, siteDir, i18n } = context;
53
52
  const { editUrl } = options;
54
53
  // Lookup in localized folder in priority
55
- const contentPath = await (0, utils_1.getFolderContainingFile)(getContentPathList(contentPaths), relativeSource);
54
+ const contentPath = await (0, utils_1.getFolderContainingFile)((0, utils_1.getContentPathList)(contentPaths), relativeSource);
56
55
  const source = path_1.default.join(contentPath, relativeSource);
57
56
  const aliasedSourcePath = (0, utils_1.aliasedSitePath)(source, siteDir);
58
57
  const filenameSlug = (0, utils_1.encodePath)((0, utils_1.fileToPath)(relativeSource));
@@ -75,7 +74,7 @@ async function processPageSourceFile(relativeSource, params) {
75
74
  const frontMatter = (0, frontMatter_1.validatePageFrontMatter)(unsafeFrontMatter);
76
75
  const slug = frontMatter.slug ?? filenameSlug;
77
76
  const permalink = (0, utils_1.normalizeUrl)([baseUrl, options.routeBasePath, slug]);
78
- const pagesDirPath = await (0, utils_1.getFolderContainingFile)(getContentPathList(contentPaths), relativeSource);
77
+ const pagesDirPath = await (0, utils_1.getFolderContainingFile)((0, utils_1.getContentPathList)(contentPaths), relativeSource);
79
78
  const pagesSourceAbsolute = path_1.default.join(pagesDirPath, relativeSource);
80
79
  function getPagesEditUrl() {
81
80
  const pagesPathRelative = path_1.default.relative(pagesDirPath, path_1.default.resolve(pagesSourceAbsolute));
@@ -89,7 +88,9 @@ async function processPageSourceFile(relativeSource, params) {
89
88
  }
90
89
  else if (typeof editUrl === 'string') {
91
90
  const isLocalized = pagesDirPath === contentPaths.contentPathLocalized;
92
- const fileContentPath = isLocalized && options.editLocalizedFiles
91
+ const fileContentPath = isLocalized &&
92
+ options.editLocalizedFiles &&
93
+ contentPaths.contentPathLocalized
93
94
  ? contentPaths.contentPathLocalized
94
95
  : contentPaths.contentPath;
95
96
  const contentPathEditUrl = (0, utils_1.normalizeUrl)([
package/lib/index.js CHANGED
@@ -22,7 +22,7 @@ async function pluginContentPages(context, options) {
22
22
  const dataDir = path_1.default.join(pluginDataDirRoot, options.id ?? utils_1.DEFAULT_PLUGIN_ID);
23
23
  async function createPagesMDXLoaderRule() {
24
24
  const { admonitions, rehypePlugins, remarkPlugins, recmaPlugins, beforeDefaultRehypePlugins, beforeDefaultRemarkPlugins, } = options;
25
- const contentDirs = (0, content_1.getContentPathList)(contentPaths);
25
+ const contentDirs = (0, utils_1.getContentPathList)(contentPaths);
26
26
  return (0, mdx_loader_1.createMDXLoaderRule)({
27
27
  include: contentDirs
28
28
  // Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
@@ -57,7 +57,7 @@ async function pluginContentPages(context, options) {
57
57
  name: 'docusaurus-plugin-content-pages',
58
58
  getPathsToWatch() {
59
59
  const { include } = options;
60
- return (0, content_1.getContentPathList)(contentPaths).flatMap((contentPath) => include.map((pattern) => `${contentPath}/${pattern}`));
60
+ return (0, utils_1.getContentPathList)(contentPaths).flatMap((contentPath) => include.map((pattern) => `${contentPath}/${pattern}`));
61
61
  },
62
62
  async loadContent() {
63
63
  if (!(await fs_extra_1.default.pathExists(contentPaths.contentPath))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-pages",
3
- "version": "3.8.1",
3
+ "version": "3.9.0-canary-6406",
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": "3.8.1",
22
- "@docusaurus/mdx-loader": "3.8.1",
23
- "@docusaurus/types": "3.8.1",
24
- "@docusaurus/utils": "3.8.1",
25
- "@docusaurus/utils-validation": "3.8.1",
21
+ "@docusaurus/core": "3.9.0-canary-6406",
22
+ "@docusaurus/mdx-loader": "3.9.0-canary-6406",
23
+ "@docusaurus/types": "3.9.0-canary-6406",
24
+ "@docusaurus/utils": "3.9.0-canary-6406",
25
+ "@docusaurus/utils-validation": "3.9.0-canary-6406",
26
26
  "fs-extra": "^11.1.1",
27
27
  "tslib": "^2.6.0",
28
28
  "webpack": "^5.88.1"
@@ -32,7 +32,7 @@
32
32
  "react-dom": "^18.0.0 || ^19.0.0"
33
33
  },
34
34
  "engines": {
35
- "node": ">=18.0"
35
+ "node": ">=20.0"
36
36
  },
37
- "gitHead": "fa8ae13e668fcbc0481ce10c0a734e2a5b397293"
37
+ "gitHead": "796441f4f831278ffc57971fabcd4c730da9e9d7"
38
38
  }
package/src/content.ts CHANGED
@@ -21,10 +21,12 @@ import {
21
21
  getEditUrl,
22
22
  posixPath,
23
23
  getPluginI18nPath,
24
+ getContentPathList,
25
+ getLocaleConfig,
26
+ type ContentPaths,
24
27
  } from '@docusaurus/utils';
25
28
  import {validatePageFrontMatter} from './frontMatter';
26
29
  import type {LoadContext} from '@docusaurus/types';
27
- import type {PagesContentPaths} from './types';
28
30
  import type {
29
31
  PluginOptions,
30
32
  Metadata,
@@ -37,29 +39,29 @@ export function createPagesContentPaths({
37
39
  }: {
38
40
  context: LoadContext;
39
41
  options: PluginOptions;
40
- }): PagesContentPaths {
42
+ }): ContentPaths {
41
43
  const {siteDir, localizationDir} = context;
44
+
45
+ const shouldTranslate = getLocaleConfig(context.i18n).translate;
42
46
  return {
43
47
  contentPath: path.resolve(siteDir, options.path),
44
- contentPathLocalized: getPluginI18nPath({
45
- localizationDir,
46
- pluginName: 'docusaurus-plugin-content-pages',
47
- pluginId: options.id,
48
- }),
48
+ contentPathLocalized: shouldTranslate
49
+ ? getPluginI18nPath({
50
+ localizationDir,
51
+ pluginName: 'docusaurus-plugin-content-pages',
52
+ pluginId: options.id,
53
+ })
54
+ : undefined,
49
55
  };
50
56
  }
51
57
 
52
- export function getContentPathList(contentPaths: PagesContentPaths): string[] {
53
- return [contentPaths.contentPathLocalized, contentPaths.contentPath];
54
- }
55
-
56
58
  const isMarkdownSource = (source: string) =>
57
59
  source.endsWith('.md') || source.endsWith('.mdx');
58
60
 
59
61
  type LoadContentParams = {
60
62
  context: LoadContext;
61
63
  options: PluginOptions;
62
- contentPaths: PagesContentPaths;
64
+ contentPaths: ContentPaths;
63
65
  };
64
66
 
65
67
  export async function loadPagesContent(
@@ -158,7 +160,9 @@ async function processPageSourceFile(
158
160
  } else if (typeof editUrl === 'string') {
159
161
  const isLocalized = pagesDirPath === contentPaths.contentPathLocalized;
160
162
  const fileContentPath =
161
- isLocalized && options.editLocalizedFiles
163
+ isLocalized &&
164
+ options.editLocalizedFiles &&
165
+ contentPaths.contentPathLocalized
162
166
  ? contentPaths.contentPathLocalized
163
167
  : contentPaths.contentPath;
164
168
 
package/src/index.ts CHANGED
@@ -12,15 +12,12 @@ import {
12
12
  docuHash,
13
13
  addTrailingPathSeparator,
14
14
  createAbsoluteFilePathMatcher,
15
+ getContentPathList,
15
16
  DEFAULT_PLUGIN_ID,
16
17
  } from '@docusaurus/utils';
17
18
  import {createMDXLoaderRule} from '@docusaurus/mdx-loader';
18
19
  import {createAllRoutes} from './routes';
19
- import {
20
- createPagesContentPaths,
21
- getContentPathList,
22
- loadPagesContent,
23
- } from './content';
20
+ import {createPagesContentPaths, loadPagesContent} from './content';
24
21
  import type {LoadContext, Plugin} from '@docusaurus/types';
25
22
  import type {
26
23
  PluginOptions,
package/lib/types.d.ts DELETED
@@ -1,10 +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
- export type PagesContentPaths = {
8
- contentPath: string;
9
- contentPathLocalized: string;
10
- };
package/lib/types.js DELETED
@@ -1,8 +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 });
package/src/types.ts DELETED
@@ -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
-
8
- export type PagesContentPaths = {
9
- contentPath: string;
10
- contentPathLocalized: string;
11
- };