@docusaurus/preset-classic 2.0.0-beta.12faed89d → 2.0.0-beta.14

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.d.ts ADDED
@@ -0,0 +1,9 @@
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 { Preset, LoadContext } from '@docusaurus/types';
8
+ import type { Options } from '@docusaurus/preset-classic';
9
+ export default function preset(context: LoadContext, opts?: Options): Preset;
package/lib/index.js ADDED
@@ -0,0 +1,53 @@
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
+ function makePluginConfig(source, options) {
10
+ if (options) {
11
+ return [require.resolve(source), options];
12
+ }
13
+ return require.resolve(source);
14
+ }
15
+ function preset(context, opts = {}) {
16
+ const { siteConfig } = context;
17
+ const { themeConfig } = siteConfig;
18
+ const { algolia } = themeConfig;
19
+ const isProd = process.env.NODE_ENV === 'production';
20
+ const { debug, docs, blog, pages, sitemap, theme, googleAnalytics, gtag, ...rest } = opts;
21
+ const themes = [];
22
+ themes.push(makePluginConfig('@docusaurus/theme-classic', theme));
23
+ if (algolia) {
24
+ themes.push(require.resolve('@docusaurus/theme-search-algolia'));
25
+ }
26
+ const plugins = [];
27
+ if (docs !== false) {
28
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-docs', docs));
29
+ }
30
+ if (blog !== false) {
31
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-blog', blog));
32
+ }
33
+ if (pages !== false) {
34
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-pages', pages));
35
+ }
36
+ if (isProd && googleAnalytics) {
37
+ plugins.push(makePluginConfig('@docusaurus/plugin-google-analytics', googleAnalytics));
38
+ }
39
+ if (debug || (debug === undefined && !isProd)) {
40
+ plugins.push(require.resolve('@docusaurus/plugin-debug'));
41
+ }
42
+ if (isProd && gtag) {
43
+ plugins.push(makePluginConfig('@docusaurus/plugin-google-gtag', gtag));
44
+ }
45
+ if (isProd && sitemap !== false) {
46
+ plugins.push(makePluginConfig('@docusaurus/plugin-sitemap', sitemap));
47
+ }
48
+ if (Object.keys(rest).length > 0) {
49
+ throw new Error(`Unrecognized keys ${Object.keys(rest).join(', ')} found in preset-classic configuration. The allowed keys are debug, docs, blog, pages, sitemap, theme, googleAnalytics, gtag. Check the documentation: https://docusaurus.io/docs/presets#docusauruspreset-classic for more information on how to configure individual plugins.`);
50
+ }
51
+ return { themes, plugins };
52
+ }
53
+ exports.default = preset;
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@docusaurus/preset-classic",
3
- "version": "2.0.0-beta.12faed89d",
3
+ "version": "2.0.0-beta.14",
4
4
  "description": "Classic preset for Docusaurus.",
5
- "main": "src/index.js",
5
+ "main": "lib/index.js",
6
+ "types": "src/preset-classic.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "watch": "tsc --watch"
10
+ },
6
11
  "publishConfig": {
7
12
  "access": "public"
8
13
  },
@@ -13,23 +18,23 @@
13
18
  },
14
19
  "license": "MIT",
15
20
  "dependencies": {
16
- "@docusaurus/core": "2.0.0-beta.12faed89d",
17
- "@docusaurus/plugin-content-blog": "2.0.0-beta.12faed89d",
18
- "@docusaurus/plugin-content-docs": "2.0.0-beta.12faed89d",
19
- "@docusaurus/plugin-content-pages": "2.0.0-beta.12faed89d",
20
- "@docusaurus/plugin-debug": "2.0.0-beta.12faed89d",
21
- "@docusaurus/plugin-google-analytics": "2.0.0-beta.12faed89d",
22
- "@docusaurus/plugin-google-gtag": "2.0.0-beta.12faed89d",
23
- "@docusaurus/plugin-sitemap": "2.0.0-beta.12faed89d",
24
- "@docusaurus/theme-classic": "2.0.0-beta.12faed89d",
25
- "@docusaurus/theme-search-algolia": "2.0.0-beta.12faed89d"
21
+ "@docusaurus/core": "2.0.0-beta.14",
22
+ "@docusaurus/plugin-content-blog": "2.0.0-beta.14",
23
+ "@docusaurus/plugin-content-docs": "2.0.0-beta.14",
24
+ "@docusaurus/plugin-content-pages": "2.0.0-beta.14",
25
+ "@docusaurus/plugin-debug": "2.0.0-beta.14",
26
+ "@docusaurus/plugin-google-analytics": "2.0.0-beta.14",
27
+ "@docusaurus/plugin-google-gtag": "2.0.0-beta.14",
28
+ "@docusaurus/plugin-sitemap": "2.0.0-beta.14",
29
+ "@docusaurus/theme-classic": "2.0.0-beta.14",
30
+ "@docusaurus/theme-search-algolia": "2.0.0-beta.14"
26
31
  },
27
32
  "peerDependencies": {
28
33
  "react": "^16.8.4 || ^17.0.0",
29
34
  "react-dom": "^16.8.4 || ^17.0.0"
30
35
  },
31
36
  "engines": {
32
- "node": ">=12.13.0"
37
+ "node": ">=14"
33
38
  },
34
- "gitHead": "1430dbacfbe9da59a17ce395ed29bdbddaf90049"
39
+ "gitHead": "c4824a8937d8f1aa0806667749cbc74058e2b294"
35
40
  }
package/src/index.ts ADDED
@@ -0,0 +1,85 @@
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 {
9
+ Preset,
10
+ LoadContext,
11
+ PluginConfig,
12
+ PluginOptions,
13
+ } from '@docusaurus/types';
14
+ import type {Options, ThemeConfig} from '@docusaurus/preset-classic';
15
+
16
+ function makePluginConfig(
17
+ source: string,
18
+ options?: PluginOptions,
19
+ ): string | [string, PluginOptions] {
20
+ if (options) {
21
+ return [require.resolve(source), options];
22
+ }
23
+ return require.resolve(source);
24
+ }
25
+
26
+ export default function preset(
27
+ context: LoadContext,
28
+ opts: Options = {},
29
+ ): Preset {
30
+ const {siteConfig} = context;
31
+ const {themeConfig} = siteConfig;
32
+ const {algolia} = themeConfig as Partial<ThemeConfig>;
33
+ const isProd = process.env.NODE_ENV === 'production';
34
+ const {
35
+ debug,
36
+ docs,
37
+ blog,
38
+ pages,
39
+ sitemap,
40
+ theme,
41
+ googleAnalytics,
42
+ gtag,
43
+ ...rest
44
+ } = opts;
45
+
46
+ const themes: PluginConfig[] = [];
47
+ themes.push(makePluginConfig('@docusaurus/theme-classic', theme));
48
+ if (algolia) {
49
+ themes.push(require.resolve('@docusaurus/theme-search-algolia'));
50
+ }
51
+
52
+ const plugins: PluginConfig[] = [];
53
+ if (docs !== false) {
54
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-docs', docs));
55
+ }
56
+ if (blog !== false) {
57
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-blog', blog));
58
+ }
59
+ if (pages !== false) {
60
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-pages', pages));
61
+ }
62
+ if (isProd && googleAnalytics) {
63
+ plugins.push(
64
+ makePluginConfig('@docusaurus/plugin-google-analytics', googleAnalytics),
65
+ );
66
+ }
67
+ if (debug || (debug === undefined && !isProd)) {
68
+ plugins.push(require.resolve('@docusaurus/plugin-debug'));
69
+ }
70
+ if (isProd && gtag) {
71
+ plugins.push(makePluginConfig('@docusaurus/plugin-google-gtag', gtag));
72
+ }
73
+ if (isProd && sitemap !== false) {
74
+ plugins.push(makePluginConfig('@docusaurus/plugin-sitemap', sitemap));
75
+ }
76
+ if (Object.keys(rest).length > 0) {
77
+ throw new Error(
78
+ `Unrecognized keys ${Object.keys(rest).join(
79
+ ', ',
80
+ )} found in preset-classic configuration. The allowed keys are debug, docs, blog, pages, sitemap, theme, googleAnalytics, gtag. Check the documentation: https://docusaurus.io/docs/presets#docusauruspreset-classic for more information on how to configure individual plugins.`,
81
+ );
82
+ }
83
+
84
+ return {themes, plugins};
85
+ }
@@ -0,0 +1,22 @@
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 Options = {
9
+ debug?: boolean;
10
+ docs?: false | import('@docusaurus/plugin-content-docs').Options;
11
+ blog?: false | import('@docusaurus/plugin-content-blog').Options;
12
+ pages?: false | import('@docusaurus/plugin-content-pages').Options;
13
+ sitemap?: false | import('@docusaurus/plugin-sitemap').Options;
14
+ theme?: import('@docusaurus/theme-classic').Options;
15
+ googleAnalytics?: import('@docusaurus/plugin-google-analytics').Options;
16
+ gtag?: import('@docusaurus/plugin-google-gtag').Options;
17
+ };
18
+
19
+ export type ThemeConfig = import('@docusaurus/types').ThemeConfig &
20
+ import('@docusaurus/theme-common').UserThemeConfig & {
21
+ algolia?: unknown; // TODO type plugin
22
+ };
package/src/index.js DELETED
@@ -1,48 +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
- module.exports = function preset(context, opts = {}) {
9
- const {siteConfig = {}} = context;
10
- const {themeConfig} = siteConfig;
11
- const {algolia, googleAnalytics, gtag} = themeConfig;
12
- const isProd = process.env.NODE_ENV === 'production';
13
-
14
- const debug =
15
- typeof opts.debug !== 'undefined' ? Boolean(opts.debug) : !isProd;
16
-
17
- return {
18
- themes: [
19
- [require.resolve('@docusaurus/theme-classic'), opts.theme],
20
- // Don't add this if algolia config is not defined.
21
- algolia && require.resolve('@docusaurus/theme-search-algolia'),
22
- ],
23
- plugins: [
24
- opts.docs !== false && [
25
- require.resolve('@docusaurus/plugin-content-docs'),
26
- opts.docs,
27
- ],
28
- opts.blog !== false && [
29
- require.resolve('@docusaurus/plugin-content-blog'),
30
- opts.blog,
31
- ],
32
- opts.pages !== false && [
33
- require.resolve('@docusaurus/plugin-content-pages'),
34
- opts.pages,
35
- ],
36
- isProd &&
37
- googleAnalytics &&
38
- require.resolve('@docusaurus/plugin-google-analytics'),
39
- debug && require.resolve('@docusaurus/plugin-debug'),
40
- isProd && gtag && require.resolve('@docusaurus/plugin-google-gtag'),
41
- isProd &&
42
- opts.sitemap !== false && [
43
- require.resolve('@docusaurus/plugin-sitemap'),
44
- opts.sitemap,
45
- ],
46
- ],
47
- };
48
- };