@docusaurus/plugin-sitemap 2.0.0-beta.ff31de0ff → 2.0.0-rc.1

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.
@@ -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
- import { Joi } from '@docusaurus/utils-validation';
8
- import { PluginOptions } from './types';
9
- export declare const DEFAULT_OPTIONS: Required<PluginOptions>;
10
- export declare const PluginOptionSchema: Joi.ObjectSchema<any>;
package/lib/types.d.ts DELETED
@@ -1,12 +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 { EnumChangefreq } from 'sitemap';
8
- export interface PluginOptions {
9
- changefreq?: EnumChangefreq;
10
- priority?: number;
11
- trailingSlash?: boolean;
12
- }
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 });
@@ -1,66 +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 createSitemap from '../createSitemap';
9
- import {DocusaurusConfig} from '@docusaurus/types';
10
-
11
- describe('createSitemap', () => {
12
- test('simple site', async () => {
13
- const sitemap = await createSitemap(
14
- {
15
- url: 'https://example.com',
16
- } as DocusaurusConfig,
17
- ['/', '/test'],
18
- {
19
- changefreq: 'daily',
20
- priority: 0.7,
21
- trailingSlash: false,
22
- },
23
- );
24
- expect(sitemap).toContain(
25
- `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
26
- );
27
- });
28
-
29
- test('empty site', () => {
30
- return expect(async () => {
31
- await createSitemap({} as DocusaurusConfig, [], {});
32
- }).rejects.toThrow('url in docusaurus.config.js cannot be empty/undefined');
33
- });
34
-
35
- test('exclusion of 404 page', async () => {
36
- const sitemap = await createSitemap(
37
- {
38
- url: 'https://example.com',
39
- } as DocusaurusConfig,
40
- ['/', '/404.html', '/mypage'],
41
- {
42
- changefreq: 'daily',
43
- priority: 0.7,
44
- trailingSlash: false,
45
- },
46
- );
47
- expect(sitemap).not.toContain('404');
48
- });
49
-
50
- test('add trailing slash', async () => {
51
- const sitemap = await createSitemap(
52
- {
53
- url: 'https://example.com',
54
- } as DocusaurusConfig,
55
- ['/', '/test'],
56
- {
57
- changefreq: 'daily',
58
- priority: 0.7,
59
- trailingSlash: true,
60
- },
61
- );
62
-
63
- expect(sitemap).toContain('<loc>https://example.com/test/</loc>');
64
- expect(sitemap).not.toContain('<loc>https://example.com/test</loc>');
65
- });
66
- });
@@ -1,56 +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 {PluginOptionSchema, DEFAULT_OPTIONS} from '../pluginOptionSchema';
9
-
10
- function normalizePluginOptions(options) {
11
- const {value, error} = PluginOptionSchema.validate(options, {
12
- convert: false,
13
- });
14
- if (error) {
15
- throw error;
16
- } else {
17
- return value;
18
- }
19
- }
20
-
21
- describe('normalizeSitemapPluginOptions', () => {
22
- test('should return default values for empty user options', async () => {
23
- const {value} = await PluginOptionSchema.validate({});
24
- expect(value).toEqual(DEFAULT_OPTIONS);
25
- });
26
-
27
- test('should accept correctly defined user options', async () => {
28
- const userOptions = {
29
- changefreq: 'yearly',
30
- priority: 0.9,
31
- trailingSlash: false,
32
- };
33
- const {value} = await PluginOptionSchema.validate(userOptions);
34
- expect(value).toEqual(userOptions);
35
- });
36
-
37
- test('should reject out-of-range priority inputs', () => {
38
- expect(() => {
39
- normalizePluginOptions({
40
- priority: 2,
41
- });
42
- }).toThrowErrorMatchingInlineSnapshot(
43
- `"\\"priority\\" must be less than or equal to 1"`,
44
- );
45
- });
46
-
47
- test('should reject bad changefreq inputs', () => {
48
- expect(() => {
49
- normalizePluginOptions({
50
- changefreq: 'annually',
51
- });
52
- }).toThrowErrorMatchingInlineSnapshot(
53
- `"\\"changefreq\\" must be one of [daily, monthly, always, hourly, weekly, yearly, never]"`,
54
- );
55
- });
56
- });
@@ -1,29 +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 {Joi} from '@docusaurus/utils-validation';
9
- import {EnumChangefreq} from 'sitemap';
10
- import {PluginOptions} from './types';
11
-
12
- export const DEFAULT_OPTIONS: Required<PluginOptions> = {
13
- changefreq: EnumChangefreq.WEEKLY,
14
- priority: 0.5,
15
- trailingSlash: false,
16
- };
17
-
18
- export const PluginOptionSchema = Joi.object({
19
- // TODO temporary (@alpha-71)
20
- cacheTime: Joi.forbidden().messages({
21
- 'any.unknown':
22
- 'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
23
- }),
24
- changefreq: Joi.string()
25
- .valid(...Object.values(EnumChangefreq))
26
- .default(DEFAULT_OPTIONS.changefreq),
27
- priority: Joi.number().min(0).max(1).default(DEFAULT_OPTIONS.priority),
28
- trailingSlash: Joi.bool().default(false),
29
- });
package/src/types.ts DELETED
@@ -1,14 +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 {EnumChangefreq} from 'sitemap';
9
-
10
- export interface PluginOptions {
11
- changefreq?: EnumChangefreq;
12
- priority?: number;
13
- trailingSlash?: boolean;
14
- }
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "incremental": true,
5
- "tsBuildInfoFile": "./lib/.tsbuildinfo",
6
- "rootDir": "src",
7
- "outDir": "lib"
8
- }
9
- }