@docusaurus/preset-classic 2.0.0-beta.1decd6f80 → 2.0.0-beta.20

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/README.md CHANGED
@@ -4,4 +4,4 @@ Classic preset for Docusaurus.
4
4
 
5
5
  ## Usage
6
6
 
7
- See [presets documentation](https://docusaurus.io/docs/presets).
7
+ See [presets documentation](https://docusaurus.io/docs/using-plugins#using-presets).
package/lib/index.d.ts ADDED
@@ -0,0 +1,10 @@
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, ThemeConfig } from './options';
9
+ export default function preset(context: LoadContext, opts?: Options): Preset;
10
+ export type { Options, ThemeConfig };
package/lib/index.js ADDED
@@ -0,0 +1,59 @@
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
+ if ('gtag' in themeConfig) {
27
+ throw new Error('The "gtag" field in themeConfig should now be specified as option for plugin-google-gtag. For preset-classic, simply move themeConfig.gtag to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.');
28
+ }
29
+ if ('googleAnalytics' in themeConfig) {
30
+ throw new Error('The "googleAnalytics" field in themeConfig should now be specified as option for plugin-google-analytics. For preset-classic, simply move themeConfig.googleAnalytics to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.');
31
+ }
32
+ const plugins = [];
33
+ if (docs !== false) {
34
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-docs', docs));
35
+ }
36
+ if (blog !== false) {
37
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-blog', blog));
38
+ }
39
+ if (pages !== false) {
40
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-pages', pages));
41
+ }
42
+ if (googleAnalytics) {
43
+ plugins.push(makePluginConfig('@docusaurus/plugin-google-analytics', googleAnalytics));
44
+ }
45
+ if (debug || (debug === undefined && !isProd)) {
46
+ plugins.push(require.resolve('@docusaurus/plugin-debug'));
47
+ }
48
+ if (gtag) {
49
+ plugins.push(makePluginConfig('@docusaurus/plugin-google-gtag', gtag));
50
+ }
51
+ if (isProd && sitemap !== false) {
52
+ plugins.push(makePluginConfig('@docusaurus/plugin-sitemap', sitemap));
53
+ }
54
+ if (Object.keys(rest).length > 0) {
55
+ 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.`);
56
+ }
57
+ return { themes, plugins };
58
+ }
59
+ exports.default = preset;
@@ -0,0 +1,44 @@
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 { Options as DocsPluginOptions } from '@docusaurus/plugin-content-docs';
8
+ import type { Options as BlogPluginOptions } from '@docusaurus/plugin-content-blog';
9
+ import type { Options as PagesPluginOptions } from '@docusaurus/plugin-content-pages';
10
+ import type { Options as SitemapPluginOptions } from '@docusaurus/plugin-sitemap';
11
+ import type { Options as GAPluginOptions } from '@docusaurus/plugin-google-analytics';
12
+ import type { Options as GtagPluginOptions } from '@docusaurus/plugin-google-gtag';
13
+ import type { Options as ThemeOptions } from '@docusaurus/theme-classic';
14
+ import type { ThemeConfig as BaseThemeConfig } from '@docusaurus/types';
15
+ import type { UserThemeConfig as ClassicThemeConfig } from '@docusaurus/theme-common';
16
+ import type { UserThemeConfig as AlgoliaThemeConfig } from '@docusaurus/theme-search-algolia';
17
+ export declare type Options = {
18
+ /**
19
+ * Options for `@docusaurus/plugin-debug`. Use `false` to disable, or `true`
20
+ * to enable even in production.
21
+ */
22
+ debug?: boolean;
23
+ /** Options for `@docusaurus/plugin-content-docs`. Use `false` to disable. */
24
+ docs?: false | DocsPluginOptions;
25
+ /** Options for `@docusaurus/plugin-content-blog`. Use `false` to disable. */
26
+ blog?: false | BlogPluginOptions;
27
+ /** Options for `@docusaurus/plugin-content-pages`. Use `false` to disable. */
28
+ pages?: false | PagesPluginOptions;
29
+ /** Options for `@docusaurus/plugin-sitemap`. Use `false` to disable. */
30
+ sitemap?: false | SitemapPluginOptions;
31
+ /** Options for `@docusaurus/theme-classic`. */
32
+ theme?: ThemeOptions;
33
+ /**
34
+ * Options for `@docusaurus/plugin-google-analytics`. Only enabled when the
35
+ * key is present.
36
+ */
37
+ googleAnalytics?: GAPluginOptions;
38
+ /**
39
+ * Options for `@docusaurus/plugin-google-gtag`. Only enabled when the key
40
+ * is present.
41
+ */
42
+ gtag?: GtagPluginOptions;
43
+ };
44
+ export declare type ThemeConfig = BaseThemeConfig & ClassicThemeConfig & AlgoliaThemeConfig;
package/lib/options.js ADDED
@@ -0,0 +1,8 @@
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/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@docusaurus/preset-classic",
3
- "version": "2.0.0-beta.1decd6f80",
3
+ "version": "2.0.0-beta.20",
4
4
  "description": "Classic preset for Docusaurus.",
5
- "main": "src/index.js",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc",
9
+ "watch": "tsc --watch"
10
+ },
6
11
  "publishConfig": {
7
12
  "access": "public"
8
13
  },
@@ -13,23 +18,24 @@
13
18
  },
14
19
  "license": "MIT",
15
20
  "dependencies": {
16
- "@docusaurus/core": "2.0.0-beta.1decd6f80",
17
- "@docusaurus/plugin-content-blog": "2.0.0-beta.1decd6f80",
18
- "@docusaurus/plugin-content-docs": "2.0.0-beta.1decd6f80",
19
- "@docusaurus/plugin-content-pages": "2.0.0-beta.1decd6f80",
20
- "@docusaurus/plugin-debug": "2.0.0-beta.1decd6f80",
21
- "@docusaurus/plugin-google-analytics": "2.0.0-beta.1decd6f80",
22
- "@docusaurus/plugin-google-gtag": "2.0.0-beta.1decd6f80",
23
- "@docusaurus/plugin-sitemap": "2.0.0-beta.1decd6f80",
24
- "@docusaurus/theme-classic": "2.0.0-beta.1decd6f80",
25
- "@docusaurus/theme-search-algolia": "2.0.0-beta.1decd6f80"
21
+ "@docusaurus/core": "2.0.0-beta.20",
22
+ "@docusaurus/plugin-content-blog": "2.0.0-beta.20",
23
+ "@docusaurus/plugin-content-docs": "2.0.0-beta.20",
24
+ "@docusaurus/plugin-content-pages": "2.0.0-beta.20",
25
+ "@docusaurus/plugin-debug": "2.0.0-beta.20",
26
+ "@docusaurus/plugin-google-analytics": "2.0.0-beta.20",
27
+ "@docusaurus/plugin-google-gtag": "2.0.0-beta.20",
28
+ "@docusaurus/plugin-sitemap": "2.0.0-beta.20",
29
+ "@docusaurus/theme-classic": "2.0.0-beta.20",
30
+ "@docusaurus/theme-common": "2.0.0-beta.20",
31
+ "@docusaurus/theme-search-algolia": "2.0.0-beta.20"
26
32
  },
27
33
  "peerDependencies": {
28
34
  "react": "^16.8.4 || ^17.0.0",
29
35
  "react-dom": "^16.8.4 || ^17.0.0"
30
36
  },
31
37
  "engines": {
32
- "node": ">=12.13.0"
38
+ "node": ">=14"
33
39
  },
34
- "gitHead": "0f82d5997e05666fa8c0e8852e551c1a8ffe3876"
40
+ "gitHead": "ed5cdba401a5948e187e927039b142a0decc702d"
35
41
  }
package/src/index.ts ADDED
@@ -0,0 +1,97 @@
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 './options';
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
+ if ('gtag' in themeConfig) {
52
+ throw new Error(
53
+ 'The "gtag" field in themeConfig should now be specified as option for plugin-google-gtag. For preset-classic, simply move themeConfig.gtag to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.',
54
+ );
55
+ }
56
+ if ('googleAnalytics' in themeConfig) {
57
+ throw new Error(
58
+ 'The "googleAnalytics" field in themeConfig should now be specified as option for plugin-google-analytics. For preset-classic, simply move themeConfig.googleAnalytics to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.',
59
+ );
60
+ }
61
+
62
+ const plugins: PluginConfig[] = [];
63
+ if (docs !== false) {
64
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-docs', docs));
65
+ }
66
+ if (blog !== false) {
67
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-blog', blog));
68
+ }
69
+ if (pages !== false) {
70
+ plugins.push(makePluginConfig('@docusaurus/plugin-content-pages', pages));
71
+ }
72
+ if (googleAnalytics) {
73
+ plugins.push(
74
+ makePluginConfig('@docusaurus/plugin-google-analytics', googleAnalytics),
75
+ );
76
+ }
77
+ if (debug || (debug === undefined && !isProd)) {
78
+ plugins.push(require.resolve('@docusaurus/plugin-debug'));
79
+ }
80
+ if (gtag) {
81
+ plugins.push(makePluginConfig('@docusaurus/plugin-google-gtag', gtag));
82
+ }
83
+ if (isProd && sitemap !== false) {
84
+ plugins.push(makePluginConfig('@docusaurus/plugin-sitemap', sitemap));
85
+ }
86
+ if (Object.keys(rest).length > 0) {
87
+ throw new Error(
88
+ `Unrecognized keys ${Object.keys(rest).join(
89
+ ', ',
90
+ )} 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.`,
91
+ );
92
+ }
93
+
94
+ return {themes, plugins};
95
+ }
96
+
97
+ export type {Options, ThemeConfig};
package/src/options.ts ADDED
@@ -0,0 +1,49 @@
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 {Options as DocsPluginOptions} from '@docusaurus/plugin-content-docs';
9
+ import type {Options as BlogPluginOptions} from '@docusaurus/plugin-content-blog';
10
+ import type {Options as PagesPluginOptions} from '@docusaurus/plugin-content-pages';
11
+ import type {Options as SitemapPluginOptions} from '@docusaurus/plugin-sitemap';
12
+ import type {Options as GAPluginOptions} from '@docusaurus/plugin-google-analytics';
13
+ import type {Options as GtagPluginOptions} from '@docusaurus/plugin-google-gtag';
14
+ import type {Options as ThemeOptions} from '@docusaurus/theme-classic';
15
+ import type {ThemeConfig as BaseThemeConfig} from '@docusaurus/types';
16
+ import type {UserThemeConfig as ClassicThemeConfig} from '@docusaurus/theme-common';
17
+ import type {UserThemeConfig as AlgoliaThemeConfig} from '@docusaurus/theme-search-algolia';
18
+
19
+ export type Options = {
20
+ /**
21
+ * Options for `@docusaurus/plugin-debug`. Use `false` to disable, or `true`
22
+ * to enable even in production.
23
+ */
24
+ debug?: boolean;
25
+ /** Options for `@docusaurus/plugin-content-docs`. Use `false` to disable. */
26
+ docs?: false | DocsPluginOptions;
27
+ /** Options for `@docusaurus/plugin-content-blog`. Use `false` to disable. */
28
+ blog?: false | BlogPluginOptions;
29
+ /** Options for `@docusaurus/plugin-content-pages`. Use `false` to disable. */
30
+ pages?: false | PagesPluginOptions;
31
+ /** Options for `@docusaurus/plugin-sitemap`. Use `false` to disable. */
32
+ sitemap?: false | SitemapPluginOptions;
33
+ /** Options for `@docusaurus/theme-classic`. */
34
+ theme?: ThemeOptions;
35
+ /**
36
+ * Options for `@docusaurus/plugin-google-analytics`. Only enabled when the
37
+ * key is present.
38
+ */
39
+ googleAnalytics?: GAPluginOptions;
40
+ /**
41
+ * Options for `@docusaurus/plugin-google-gtag`. Only enabled when the key
42
+ * is present.
43
+ */
44
+ gtag?: GtagPluginOptions;
45
+ };
46
+
47
+ export type ThemeConfig = BaseThemeConfig &
48
+ ClassicThemeConfig &
49
+ AlgoliaThemeConfig;
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
- };