This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

21
node_modules/@docusaurus/plugin-sitemap/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) Facebook, Inc. and its affiliates.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7
node_modules/@docusaurus/plugin-sitemap/README.md generated vendored Normal file
View File

@@ -0,0 +1,7 @@
# `@docusaurus/plugin-sitemap`
Simple sitemap generation plugin for Docusaurus.
## Usage
See [plugin-sitemap documentation](https://docusaurus.io/docs/api/plugins/@docusaurus/plugin-sitemap).

View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { DocusaurusConfig } from '@docusaurus/types';
import type { HelmetServerState } from 'react-helmet-async';
import type { PluginOptions } from './options';
export default function createSitemap(siteConfig: DocusaurusConfig, routesPaths: string[], head: {
[location: string]: HelmetServerState;
}, options: PluginOptions): Promise<string | null>;

View File

@@ -0,0 +1,56 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const sitemap_1 = require("sitemap");
const utils_common_1 = require("@docusaurus/utils-common");
const utils_1 = require("@docusaurus/utils");
function isNoIndexMetaRoute({ head, route, }) {
const isNoIndexMetaTag = ({ name, content, }) => {
if (!name || !content) {
return false;
}
return (
// meta name is not case-sensitive
name.toLowerCase() === 'robots' &&
// Robots directives are not case-sensitive
content.toLowerCase().includes('noindex'));
};
// https://github.com/staylor/react-helmet-async/pull/167
const meta = head[route]?.meta.toComponent();
return meta?.some((tag) => isNoIndexMetaTag({ name: tag.props.name, content: tag.props.content }));
}
async function createSitemap(siteConfig, routesPaths, head, options) {
const { url: hostname } = siteConfig;
if (!hostname) {
throw new Error('URL in docusaurus.config.js cannot be empty/undefined.');
}
const { changefreq, priority, ignorePatterns } = options;
const ignoreMatcher = (0, utils_1.createMatcher)(ignorePatterns);
function isRouteExcluded(route) {
return (route.endsWith('404.html') ||
ignoreMatcher(route) ||
isNoIndexMetaRoute({ head, route }));
}
const includedRoutes = routesPaths.filter((route) => !isRouteExcluded(route));
if (includedRoutes.length === 0) {
return null;
}
const sitemapStream = new sitemap_1.SitemapStream({ hostname });
includedRoutes.forEach((routePath) => sitemapStream.write({
url: (0, utils_common_1.applyTrailingSlash)(routePath, {
trailingSlash: siteConfig.trailingSlash,
baseUrl: siteConfig.baseUrl,
}),
changefreq,
priority,
}));
sitemapStream.end();
const generatedSitemap = (await (0, sitemap_1.streamToPromise)(sitemapStream)).toString();
return generatedSitemap;
}
exports.default = createSitemap;

11
node_modules/@docusaurus/plugin-sitemap/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type { PluginOptions, Options } from './options';
import type { LoadContext, Plugin } from '@docusaurus/types';
export default function pluginSitemap(context: LoadContext, options: PluginOptions): Plugin<void>;
export { validateOptions } from './options';
export type { PluginOptions, Options };

41
node_modules/@docusaurus/plugin-sitemap/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateOptions = void 0;
const tslib_1 = require("tslib");
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
const path_1 = tslib_1.__importDefault(require("path"));
const logger_1 = tslib_1.__importDefault(require("@docusaurus/logger"));
const createSitemap_1 = tslib_1.__importDefault(require("./createSitemap"));
function pluginSitemap(context, options) {
return {
name: 'docusaurus-plugin-sitemap',
async postBuild({ siteConfig, routesPaths, outDir, head }) {
if (siteConfig.noIndex) {
return;
}
// Generate sitemap.
const generatedSitemap = await (0, createSitemap_1.default)(siteConfig, routesPaths, head, options);
if (!generatedSitemap) {
return;
}
// Write sitemap file.
const sitemapPath = path_1.default.join(outDir, options.filename);
try {
await fs_extra_1.default.outputFile(sitemapPath, generatedSitemap);
}
catch (err) {
logger_1.default.error('Writing sitemap failed.');
throw err;
}
},
};
}
exports.default = pluginSitemap;
var options_1 = require("./options");
Object.defineProperty(exports, "validateOptions", { enumerable: true, get: function () { return options_1.validateOptions; } });

View File

@@ -0,0 +1,27 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import { EnumChangefreq } from 'sitemap';
import type { OptionValidationContext } from '@docusaurus/types';
export type PluginOptions = {
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
changefreq: EnumChangefreq;
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
priority: number;
/**
* A list of glob patterns; matching route paths will be filtered from the
* sitemap. Note that you may need to include the base URL in here.
*/
ignorePatterns: string[];
/**
* The path to the created sitemap file, relative to the output directory.
* Useful if you have two plugin instances outputting two files.
*/
filename: string;
};
export type Options = Partial<PluginOptions>;
export declare const DEFAULT_OPTIONS: PluginOptions;
export declare function validateOptions({ validate, options, }: OptionValidationContext<Options, PluginOptions>): PluginOptions;

39
node_modules/@docusaurus/plugin-sitemap/lib/options.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
"use strict";
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.validateOptions = exports.DEFAULT_OPTIONS = void 0;
const utils_validation_1 = require("@docusaurus/utils-validation");
const sitemap_1 = require("sitemap");
exports.DEFAULT_OPTIONS = {
changefreq: sitemap_1.EnumChangefreq.WEEKLY,
priority: 0.5,
ignorePatterns: [],
filename: 'sitemap.xml',
};
const PluginOptionSchema = utils_validation_1.Joi.object({
// @ts-expect-error: forbidden
cacheTime: utils_validation_1.Joi.forbidden().messages({
'any.unknown': 'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
}),
changefreq: utils_validation_1.Joi.string()
.valid(...Object.values(sitemap_1.EnumChangefreq))
.default(exports.DEFAULT_OPTIONS.changefreq),
priority: utils_validation_1.Joi.number().min(0).max(1).default(exports.DEFAULT_OPTIONS.priority),
ignorePatterns: utils_validation_1.Joi.array()
.items(utils_validation_1.Joi.string())
.default(exports.DEFAULT_OPTIONS.ignorePatterns),
trailingSlash: utils_validation_1.Joi.forbidden().messages({
'any.unknown': 'Please use the new Docusaurus global trailingSlash config instead, and the sitemaps plugin will use it.',
}),
filename: utils_validation_1.Joi.string().default(exports.DEFAULT_OPTIONS.filename),
});
function validateOptions({ validate, options, }) {
const validatedOptions = validate(PluginOptionSchema, options);
return validatedOptions;
}
exports.validateOptions = validateOptions;

39
node_modules/@docusaurus/plugin-sitemap/package.json generated vendored Normal file
View File

@@ -0,0 +1,39 @@
{
"name": "@docusaurus/plugin-sitemap",
"version": "3.1.1",
"description": "Simple sitemap generation plugin for Docusaurus.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build": "tsc",
"watch": "tsc --watch"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "https://github.com/facebook/docusaurus.git",
"directory": "packages/docusaurus-plugin-sitemap"
},
"license": "MIT",
"dependencies": {
"@docusaurus/core": "3.1.1",
"@docusaurus/logger": "3.1.1",
"@docusaurus/types": "3.1.1",
"@docusaurus/utils": "3.1.1",
"@docusaurus/utils-common": "3.1.1",
"@docusaurus/utils-validation": "3.1.1",
"fs-extra": "^11.1.1",
"sitemap": "^7.1.1",
"tslib": "^2.6.0"
},
"peerDependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0"
},
"engines": {
"node": ">=18.0"
},
"gitHead": "8017f6a6776ba1bd7065e630a52fe2c2654e2f1b"
}

View File

@@ -0,0 +1,96 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import type {ReactElement} from 'react';
import {SitemapStream, streamToPromise} from 'sitemap';
import {applyTrailingSlash} from '@docusaurus/utils-common';
import {createMatcher} from '@docusaurus/utils';
import type {DocusaurusConfig} from '@docusaurus/types';
import type {HelmetServerState} from 'react-helmet-async';
import type {PluginOptions} from './options';
function isNoIndexMetaRoute({
head,
route,
}: {
head: {[location: string]: HelmetServerState};
route: string;
}) {
const isNoIndexMetaTag = ({
name,
content,
}: {
name?: string;
content?: string;
}): boolean => {
if (!name || !content) {
return false;
}
return (
// meta name is not case-sensitive
name.toLowerCase() === 'robots' &&
// Robots directives are not case-sensitive
content.toLowerCase().includes('noindex')
);
};
// https://github.com/staylor/react-helmet-async/pull/167
const meta = head[route]?.meta.toComponent() as unknown as
| ReactElement<{name?: string; content?: string}>[]
| undefined;
return meta?.some((tag) =>
isNoIndexMetaTag({name: tag.props.name, content: tag.props.content}),
);
}
export default async function createSitemap(
siteConfig: DocusaurusConfig,
routesPaths: string[],
head: {[location: string]: HelmetServerState},
options: PluginOptions,
): Promise<string | null> {
const {url: hostname} = siteConfig;
if (!hostname) {
throw new Error('URL in docusaurus.config.js cannot be empty/undefined.');
}
const {changefreq, priority, ignorePatterns} = options;
const ignoreMatcher = createMatcher(ignorePatterns);
function isRouteExcluded(route: string) {
return (
route.endsWith('404.html') ||
ignoreMatcher(route) ||
isNoIndexMetaRoute({head, route})
);
}
const includedRoutes = routesPaths.filter((route) => !isRouteExcluded(route));
if (includedRoutes.length === 0) {
return null;
}
const sitemapStream = new SitemapStream({hostname});
includedRoutes.forEach((routePath) =>
sitemapStream.write({
url: applyTrailingSlash(routePath, {
trailingSlash: siteConfig.trailingSlash,
baseUrl: siteConfig.baseUrl,
}),
changefreq,
priority,
}),
);
sitemapStream.end();
const generatedSitemap = (await streamToPromise(sitemapStream)).toString();
return generatedSitemap;
}

50
node_modules/@docusaurus/plugin-sitemap/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,50 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import fs from 'fs-extra';
import path from 'path';
import logger from '@docusaurus/logger';
import createSitemap from './createSitemap';
import type {PluginOptions, Options} from './options';
import type {LoadContext, Plugin} from '@docusaurus/types';
export default function pluginSitemap(
context: LoadContext,
options: PluginOptions,
): Plugin<void> {
return {
name: 'docusaurus-plugin-sitemap',
async postBuild({siteConfig, routesPaths, outDir, head}) {
if (siteConfig.noIndex) {
return;
}
// Generate sitemap.
const generatedSitemap = await createSitemap(
siteConfig,
routesPaths,
head,
options,
);
if (!generatedSitemap) {
return;
}
// Write sitemap file.
const sitemapPath = path.join(outDir, options.filename);
try {
await fs.outputFile(sitemapPath, generatedSitemap);
} catch (err) {
logger.error('Writing sitemap failed.');
throw err;
}
},
};
}
export {validateOptions} from './options';
export type {PluginOptions, Options};

64
node_modules/@docusaurus/plugin-sitemap/src/options.ts generated vendored Normal file
View File

@@ -0,0 +1,64 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import {Joi} from '@docusaurus/utils-validation';
import {EnumChangefreq} from 'sitemap';
import type {OptionValidationContext} from '@docusaurus/types';
export type PluginOptions = {
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
changefreq: EnumChangefreq;
/** @see https://www.sitemaps.org/protocol.html#xmlTagDefinitions */
priority: number;
/**
* A list of glob patterns; matching route paths will be filtered from the
* sitemap. Note that you may need to include the base URL in here.
*/
ignorePatterns: string[];
/**
* The path to the created sitemap file, relative to the output directory.
* Useful if you have two plugin instances outputting two files.
*/
filename: string;
};
export type Options = Partial<PluginOptions>;
export const DEFAULT_OPTIONS: PluginOptions = {
changefreq: EnumChangefreq.WEEKLY,
priority: 0.5,
ignorePatterns: [],
filename: 'sitemap.xml',
};
const PluginOptionSchema = Joi.object<PluginOptions>({
// @ts-expect-error: forbidden
cacheTime: Joi.forbidden().messages({
'any.unknown':
'Option `cacheTime` in sitemap config is deprecated. Please remove it.',
}),
changefreq: Joi.string()
.valid(...Object.values(EnumChangefreq))
.default(DEFAULT_OPTIONS.changefreq),
priority: Joi.number().min(0).max(1).default(DEFAULT_OPTIONS.priority),
ignorePatterns: Joi.array()
.items(Joi.string())
.default(DEFAULT_OPTIONS.ignorePatterns),
trailingSlash: Joi.forbidden().messages({
'any.unknown':
'Please use the new Docusaurus global trailingSlash config instead, and the sitemaps plugin will use it.',
}),
filename: Joi.string().default(DEFAULT_OPTIONS.filename),
});
export function validateOptions({
validate,
options,
}: OptionValidationContext<Options, PluginOptions>): PluginOptions {
const validatedOptions = validate(PluginOptionSchema, options);
return validatedOptions;
}