🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

61
node_modules/@astrojs/sitemap/LICENSE generated vendored Normal file
View file

@ -0,0 +1,61 @@
MIT License
Copyright (c) 2021 Fred K. Schott
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.
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
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.
"""
"""
This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
MIT License
Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
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.
"""

356
node_modules/@astrojs/sitemap/README.md generated vendored Normal file
View file

@ -0,0 +1,356 @@
# @astrojs/sitemap 🗺
This **[Astro integration][astro-integration]** generates a sitemap based on your pages when you build your Astro project.
- <strong>[Why Astro Sitemap](#why-astro-sitemap)</strong>
- <strong>[Installation](#installation)</strong>
- <strong>[Usage](#usage)</strong>
- <strong>[Configuration](#configuration)</strong>
- <strong>[Examples](#examples)</strong>
- <strong>[Troubleshooting](#troubleshooting)</strong>
- <strong>[Contributing](#contributing)</strong>
- <strong>[Changelog](#changelog)</strong>
## Why Astro Sitemap
A Sitemap is an XML file that outlines all of the pages, videos, and files on your site. Search engines like Google read this file to crawl your site more efficiently. [See Google's own advice on sitemaps](https://developers.google.com/search/docs/advanced/sitemaps/overview) to learn more.
A sitemap file is recommended for large multi-page sites. If you don't use a sitemap, most search engines will still be able to list your site's pages, but a sitemap is a great way to ensure that your site is as search engine friendly as possible.
With Astro Sitemap, you don't have to worry about creating this file: build your Astro site how you normally would, and the Astro Sitemap integration will crawl your routes and create the sitemap file.
## Installation
### Quick Install
The `astro add` command-line tool automates the installation for you. Run one of the following commands in a new terminal window. (If you aren't sure which package manager you're using, run the first command.) Then, follow the prompts, and type "y" in the terminal (meaning "yes") for each one.
```sh
# Using NPM
npx astro add sitemap
# Using Yarn
yarn astro add sitemap
# Using PNPM
pnpm astro add sitemap
```
If you run into any issues, [feel free to report them to us on GitHub](https://github.com/withastro/astro/issues) and try the manual installation steps below.
### Manual Install
First, install the `@astrojs/sitemap` package using your package manager. If you're using npm or aren't sure, run this in the terminal:
```sh
npm install @astrojs/sitemap
```
Then, apply this integration to your `astro.config.*` file using the `integrations` property:
```js ins={3} "sitemap()"
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
// ...
integrations: [sitemap()],
});
```
## Usage
`@astrojs/sitemap` requires a deployment / site URL for generation. Add your site's URL under your `astro.config.*` using the `site` property. This must begin with `http:` or `https:`.
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
// ...
site: 'https://stargazers.club',
integrations: [sitemap()],
});
```
Note that unlike other configuration options, `site` is set in the root `defineConfig` object, rather than inside the `sitemap()` call.
Now, [build your site for production](https://docs.astro.build/en/reference/cli-reference/#astro-build) via the `astro build` command. You should find your sitemap under `dist/` for both `sitemap-index.xml` and `sitemap-0.xml`!
> **Warning**
> If you forget to add a `site`, you'll get a friendly warning when you build, and the `sitemap-index.xml` file won't be generated.
After verifying that the sitemaps are built, you can add them to your site's `<head>` and the `robots.txt` file for crawlers to pick up.
```html ins={3}
<!-- src/layouts/Layout.astro -->
<head>
<link rel="sitemap" href="/sitemap-index.xml" />
</head>
```
<!-- prettier-ignore -->
```diff ins={4} title="public/robots.txt"
User-agent: *
Allow: /
Sitemap: https://<YOUR SITE>/sitemap-index.xml
```
### Example of generated files for a two-page website
```xml title="sitemap-index.xml"
<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://stargazers.club/sitemap-0.xml</loc>
</sitemap>
</sitemapindex>
```
```xml title="sitemap-0.xml"
<?xml version="1.0" encoding="UTF-8"?>
<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">
<url>
<loc>https://stargazers.club/</loc>
</url>
<url>
<loc>https://stargazers.club/second-page/</loc>
</url>
</urlset>
```
## Configuration
To configure this integration, pass an object to the `sitemap()` function call in `astro.config.mjs`.
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
integrations: [
sitemap({
// configuration options
}),
],
});
```
### filter
All pages are included in your sitemap by default. By adding a custom `filter` function, you can filter included pages by URL.
```js
// astro.config.mjs
// ...
sitemap({
filter: (page) => page !== 'https://stargazers.club/secret-vip-lounge',
});
```
The function will be called for every page on your site. The `page` function parameter is the full URL of the page currently under considering, including your `site` domain. Return `true` to include the page in your sitemap, and `false` to leave it out.
To filter multiple pages, add arguments with target URLs.
```js
// astro.config.mjs
// ...
sitemap({
filter: (page) =>
page !== 'https://stargazers.club/secret-vip-lounge-1' &&
page !== 'https://stargazers.club/secret-vip-lounge-2' &&
page !== 'https://stargazers.club/secret-vip-lounge-3' &&
page !== 'https://stargazers.club/secret-vip-lounge-4',
});
```
### customPages
In some cases, a page might be part of your deployed site but not part of your Astro project. If you'd like to include a page in your sitemap that _isn't_ created by Astro, you can use this option.
```js
// astro.config.mjs
// ...
sitemap({
customPages: ['https://stargazers.club/external-page', 'https://stargazers.club/external-page2'],
});
```
### entryLimit
The maximum number entries per sitemap file. The default value is 45000. A sitemap index and multiple sitemaps are created if you have more entries. See this [explanation of splitting up a large sitemap](https://developers.google.com/search/docs/advanced/sitemaps/large-sitemaps).
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
site: 'https://stargazers.club',
integrations: [
sitemap({
entryLimit: 10000,
}),
],
});
```
### changefreq, lastmod, and priority
These options correspond to the `<changefreq>`, `<lastmod>`, and `<priority>` tags in the [Sitemap XML specification.](https://www.sitemaps.org/protocol.html)
Note that `changefreq` and `priority` are ignored by Google.
> **Note**
> Due to limitations of Astro's [Integration API](https://docs.astro.build/en/reference/integrations-reference/), this integration can't analyze a given page's source code. This configuration option can set `changefreq`, `lastmod` and `priority` on a _site-wide_ basis; see the next option **serialize** for how you can set these values on a per-page basis.
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
site: 'https://stargazers.club',
integrations: [
sitemap({
changefreq: 'weekly',
priority: 0.7,
lastmod: new Date('2022-02-24'),
}),
],
});
```
### serialize
A function called for each sitemap entry just before writing to a disk. This function can be asynchronous.
It receives as its parameter a `SitemapItem` object that can have these properties:
- `url` (absolute page URL). This is the only property that is guaranteed to be on `SitemapItem`.
- `changefreq`
- `lastmod` (ISO formatted date, `String` type)
- `priority`
- `links`.
This `links` property contains a `LinkItem` list of alternate pages including a parent page.
The `LinkItem` type has two fields: `url` (the fully-qualified URL for the version of this page for the specified language) and `lang` (a supported language code targeted by this version of the page).
The `serialize` function should return `SitemapItem`, touched or not.
The example below shows the ability to add sitemap specific properties individually.
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
site: 'https://stargazers.club',
integrations: [
sitemap({
serialize(item) {
if (/exclude-from-sitemap/.test(item.url)) {
return undefined;
}
if (/your-special-page/.test(item.url)) {
item.changefreq = 'daily';
item.lastmod = new Date();
item.priority = 0.9;
}
return item;
},
}),
],
});
```
### i18n
To localize a sitemap, pass an object to this `i18n` option.
This object has two required properties:
- `defaultLocale`: `String`. Its value must exist as one of `locales` keys.
- `locales`: `Record<String, String>`, key/value - pairs. The key is used to look for a locale part in a page path. The value is a language attribute, only English alphabet and hyphen allowed.
[Read more about language attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang).
[Read more about localization](https://developers.google.com/search/docs/advanced/crawling/localized-versions#all-method-guidelines).
```js
// astro.config.mjs
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
export default defineConfig({
site: 'https://stargazers.club',
integrations: [
sitemap({
i18n: {
defaultLocale: 'en', // All urls that don't contain `es` or `fr` after `https://stargazers.club/` will be treated as default locale, i.e. `en`
locales: {
en: 'en-US', // The `defaultLocale` value must present in `locales` keys
es: 'es-ES',
fr: 'fr-CA',
},
},
}),
],
});
```
The resulting sitemap looks like this:
```xml
...
<url>
<loc>https://stargazers.club/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://stargazers.club/"/>
<xhtml:link rel="alternate" hreflang="es-ES" href="https://stargazers.club/es/"/>
<xhtml:link rel="alternate" hreflang="fr-CA" href="https://stargazers.club/fr/"/>
</url>
<url>
<loc>https://stargazers.club/es/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://stargazers.club/"/>
<xhtml:link rel="alternate" hreflang="es-ES" href="https://stargazers.club/es/"/>
<xhtml:link rel="alternate" hreflang="fr-CA" href="https://stargazers.club/fr/"/>
</url>
<url>
<loc>https://stargazers.club/fr/</loc>
<xhtml:link rel="alternate" hreflang="en-US" href="https://stargazers.club/"/>
<xhtml:link rel="alternate" hreflang="es-ES" href="https://stargazers.club/es/"/>
<xhtml:link rel="alternate" hreflang="fr-CA" href="https://stargazers.club/fr/"/>
</url>
<url>
<loc>https://stargazers.club/es/second-page/</loc>
<xhtml:link rel="alternate" hreflang="es-ES" href="https://stargazers.club/es/second-page/"/>
<xhtml:link rel="alternate" hreflang="fr-CA" href="https://stargazers.club/fr/second-page/"/>
<xhtml:link rel="alternate" hreflang="en-US" href="https://stargazers.club/second-page/"/>
</url>
...
```
## Examples
- The official Astro website uses Astro Sitemap to generate [its sitemap](https://astro.build/sitemap-index.xml).
- [Browse projects with Astro Sitemap on GitHub](https://github.com/search?q=%22@astrojs/sitemap%22+filename:package.json&type=Code) for more examples!
## Troubleshooting
For help, check out the `#support` channel on [Discord](https://astro.build/chat). Our friendly Support Squad members are here to help!
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations.
## Contributing
This package is maintained by Astro's Core team. You're welcome to submit an issue or PR!
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for a history of changes to this integration.
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/

View file

@ -0,0 +1,3 @@
export declare const SITEMAP_CONFIG_DEFAULTS: {
entryLimit: number;
};

View file

@ -0,0 +1,6 @@
const SITEMAP_CONFIG_DEFAULTS = {
entryLimit: 45e3
};
export {
SITEMAP_CONFIG_DEFAULTS
};

View file

@ -0,0 +1,3 @@
import type { SitemapItem, SitemapOptions } from './index.js';
/** Construct sitemap.xml given a set of URLs */
export declare function generateSitemap(pages: string[], finalSiteUrl: string, opts: SitemapOptions): SitemapItem[];

43
node_modules/@astrojs/sitemap/dist/generate-sitemap.js generated vendored Normal file
View file

@ -0,0 +1,43 @@
import { parseUrl } from "./utils/parse-url.js";
function generateSitemap(pages, finalSiteUrl, opts) {
const { changefreq, priority, lastmod: lastmodSrc, i18n } = opts;
const urls = [...pages];
urls.sort((a, b) => a.localeCompare(b, "en", { numeric: true }));
const lastmod = lastmodSrc == null ? void 0 : lastmodSrc.toISOString();
const { locales, defaultLocale } = i18n || {};
const localeCodes = Object.keys(locales || {});
const getPath = (url) => {
const result = parseUrl(url, (i18n == null ? void 0 : i18n.defaultLocale) || "", localeCodes, finalSiteUrl);
return result == null ? void 0 : result.path;
};
const getLocale = (url) => {
const result = parseUrl(url, (i18n == null ? void 0 : i18n.defaultLocale) || "", localeCodes, finalSiteUrl);
return result == null ? void 0 : result.locale;
};
const urlData = urls.map((url) => {
let links;
if (defaultLocale && locales) {
const currentPath = getPath(url);
if (currentPath) {
const filtered = urls.filter((subUrl) => getPath(subUrl) === currentPath);
if (filtered.length > 1) {
links = filtered.map((subUrl) => ({
url: subUrl,
lang: locales[getLocale(subUrl)]
}));
}
}
}
return {
url,
links,
lastmod,
priority,
changefreq
};
});
return urlData;
}
export {
generateSitemap
};

21
node_modules/@astrojs/sitemap/dist/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,21 @@
import type { AstroIntegration } from 'astro';
import { EnumChangefreq, type LinkItem as LinkItemBase, type SitemapItemLoose } from 'sitemap';
export { EnumChangefreq as ChangeFreqEnum } from 'sitemap';
export type ChangeFreq = `${EnumChangefreq}`;
export type SitemapItem = Pick<SitemapItemLoose, 'url' | 'lastmod' | 'changefreq' | 'priority' | 'links'>;
export type LinkItem = LinkItemBase;
export type SitemapOptions = {
filter?(page: string): boolean;
customPages?: string[];
i18n?: {
defaultLocale: string;
locales: Record<string, string>;
};
entryLimit?: number;
changefreq?: ChangeFreq;
lastmod?: Date;
priority?: number;
serialize?(item: SitemapItem): SitemapItem | Promise<SitemapItem | undefined> | undefined;
} | undefined;
declare const createPlugin: (options?: SitemapOptions) => AstroIntegration;
export default createPlugin;

128
node_modules/@astrojs/sitemap/dist/index.js generated vendored Normal file
View file

@ -0,0 +1,128 @@
import { fileURLToPath } from "node:url";
import {
simpleSitemapAndIndex
} from "sitemap";
import { ZodError } from "zod";
import { generateSitemap } from "./generate-sitemap.js";
import { Logger } from "./utils/logger.js";
import { validateOptions } from "./validate-options.js";
import { EnumChangefreq as EnumChangefreq2 } from "sitemap";
function formatConfigErrorMessage(err) {
const errorList = err.issues.map((issue) => ` ${issue.path.join(".")} ${issue.message + "."}`);
return errorList.join("\n");
}
const PKG_NAME = "@astrojs/sitemap";
const OUTFILE = "sitemap-index.xml";
const STATUS_CODE_PAGES = /* @__PURE__ */ new Set(["/404", "/500"]);
const createPlugin = (options) => {
let config;
const logger = new Logger(PKG_NAME);
return {
name: PKG_NAME,
hooks: {
"astro:config:done": async ({ config: cfg }) => {
config = cfg;
},
"astro:build:done": async ({ dir, routes, pages }) => {
try {
if (!config.site) {
logger.warn(
"The Sitemap integration requires the `site` astro.config option. Skipping."
);
return;
}
const opts = validateOptions(config.site, options);
const { filter, customPages, serialize, entryLimit } = opts;
let finalSiteUrl;
if (config.site) {
finalSiteUrl = new URL(config.base, config.site);
} else {
console.warn(
"The Sitemap integration requires the `site` astro.config option. Skipping."
);
return;
}
let pageUrls = pages.filter((p) => !STATUS_CODE_PAGES.has("/" + p.pathname.slice(0, -1))).map((p) => {
if (p.pathname !== "" && !finalSiteUrl.pathname.endsWith("/"))
finalSiteUrl.pathname += "/";
const path = finalSiteUrl.pathname + p.pathname;
return new URL(path, finalSiteUrl).href;
});
let routeUrls = routes.reduce((urls, r) => {
if (r.type !== "page")
return urls;
if (r.pathname) {
if (STATUS_CODE_PAGES.has(r.pathname))
return urls;
const path = finalSiteUrl.pathname + r.generate(r.pathname).substring(1);
let newUrl = new URL(path, finalSiteUrl).href;
if (config.trailingSlash === "never") {
urls.push(newUrl);
} else if (config.build.format === "directory" && !newUrl.endsWith("/")) {
urls.push(newUrl + "/");
} else {
urls.push(newUrl);
}
}
return urls;
}, []);
pageUrls = Array.from(/* @__PURE__ */ new Set([...pageUrls, ...routeUrls, ...customPages ?? []]));
try {
if (filter) {
pageUrls = pageUrls.filter(filter);
}
} catch (err) {
logger.error(`Error filtering pages
${err.toString()}`);
return;
}
if (pageUrls.length === 0) {
logger.warn(`No pages found!
\`${OUTFILE}\` not created.`);
return;
}
let urlData = generateSitemap(pageUrls, finalSiteUrl.href, opts);
if (serialize) {
try {
const serializedUrls = [];
for (const item of urlData) {
const serialized = await Promise.resolve(serialize(item));
if (serialized) {
serializedUrls.push(serialized);
}
}
if (serializedUrls.length === 0) {
logger.warn("No pages found!");
return;
}
urlData = serializedUrls;
} catch (err) {
logger.error(`Error serializing pages
${err.toString()}`);
return;
}
}
await simpleSitemapAndIndex({
hostname: finalSiteUrl.href,
destinationDir: fileURLToPath(dir),
sourceData: urlData,
limit: entryLimit,
gzip: false
});
logger.success(`\`${OUTFILE}\` is created.`);
} catch (err) {
if (err instanceof ZodError) {
logger.warn(formatConfigErrorMessage(err));
} else {
throw err;
}
}
}
}
};
};
var src_default = createPlugin;
export {
EnumChangefreq2 as ChangeFreqEnum,
src_default as default
};

54
node_modules/@astrojs/sitemap/dist/schema.d.ts generated vendored Normal file
View file

@ -0,0 +1,54 @@
import { EnumChangefreq as ChangeFreq } from 'sitemap';
import { z } from 'zod';
export declare const SitemapOptionsSchema: z.ZodDefault<z.ZodObject<{
filter: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodString], z.ZodUnknown>, z.ZodBoolean>>;
customPages: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
canonicalURL: z.ZodOptional<z.ZodString>;
i18n: z.ZodOptional<z.ZodEffects<z.ZodObject<{
defaultLocale: z.ZodString;
locales: z.ZodRecord<z.ZodString, z.ZodString>;
}, "strip", z.ZodTypeAny, {
locales: Record<string, string>;
defaultLocale: string;
}, {
locales: Record<string, string>;
defaultLocale: string;
}>, {
locales: Record<string, string>;
defaultLocale: string;
}, {
locales: Record<string, string>;
defaultLocale: string;
}>>;
entryLimit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
serialize: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], z.ZodUnknown>, z.ZodAny>>;
changefreq: z.ZodOptional<z.ZodNativeEnum<typeof ChangeFreq>>;
lastmod: z.ZodOptional<z.ZodDate>;
priority: z.ZodOptional<z.ZodNumber>;
}, "strict", z.ZodTypeAny, {
changefreq?: ChangeFreq | undefined;
priority?: number | undefined;
lastmod?: Date | undefined;
i18n?: {
locales: Record<string, string>;
defaultLocale: string;
} | undefined;
filter?: ((args_0: string, ...args_1: unknown[]) => boolean) | undefined;
customPages?: string[] | undefined;
canonicalURL?: string | undefined;
serialize?: ((args_0: any, ...args_1: unknown[]) => any) | undefined;
entryLimit: number;
}, {
changefreq?: ChangeFreq | undefined;
priority?: number | undefined;
lastmod?: Date | undefined;
i18n?: {
locales: Record<string, string>;
defaultLocale: string;
} | undefined;
filter?: ((args_0: string, ...args_1: unknown[]) => boolean) | undefined;
customPages?: string[] | undefined;
canonicalURL?: string | undefined;
entryLimit?: number | undefined;
serialize?: ((args_0: any, ...args_1: unknown[]) => any) | undefined;
}>>;

28
node_modules/@astrojs/sitemap/dist/schema.js generated vendored Normal file
View file

@ -0,0 +1,28 @@
import { EnumChangefreq as ChangeFreq } from "sitemap";
import { z } from "zod";
import { SITEMAP_CONFIG_DEFAULTS } from "./config-defaults.js";
const localeKeySchema = z.string().min(1);
const SitemapOptionsSchema = z.object({
filter: z.function().args(z.string()).returns(z.boolean()).optional(),
customPages: z.string().url().array().optional(),
canonicalURL: z.string().url().optional(),
i18n: z.object({
defaultLocale: localeKeySchema,
locales: z.record(
localeKeySchema,
z.string().min(2).regex(/^[a-zA-Z\-]+$/gm, {
message: "Only English alphabet symbols and hyphen allowed"
})
)
}).refine((val) => !val || val.locales[val.defaultLocale], {
message: "`defaultLocale` must exist in `locales` keys"
}).optional(),
entryLimit: z.number().nonnegative().optional().default(SITEMAP_CONFIG_DEFAULTS.entryLimit),
serialize: z.function().args(z.any()).returns(z.any()).optional(),
changefreq: z.nativeEnum(ChangeFreq).optional(),
lastmod: z.date().optional(),
priority: z.number().min(0).max(1).optional()
}).strict().default(SITEMAP_CONFIG_DEFAULTS);
export {
SitemapOptionsSchema
};

View file

@ -0,0 +1 @@
export declare const isObjectEmpty: (o: any) => boolean;

View file

@ -0,0 +1,12 @@
const isObjectEmpty = (o) => {
if (!o) {
return true;
}
if (Array.isArray(o)) {
return o.length === 0;
}
return Object.keys(o).length === 0 && Object.getPrototypeOf(o) === Object.prototype;
};
export {
isObjectEmpty
};

View file

@ -0,0 +1 @@
export declare const isValidUrl: (s: any) => boolean;

View file

@ -0,0 +1,14 @@
const isValidUrl = (s) => {
if (typeof s !== "string" || !s) {
return false;
}
try {
const dummy = new URL(s);
return true;
} catch {
return false;
}
};
export {
isValidUrl
};

16
node_modules/@astrojs/sitemap/dist/utils/logger.d.ts generated vendored Normal file
View file

@ -0,0 +1,16 @@
export interface ILogger {
info(msg: string): void;
success(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
}
export declare class Logger implements ILogger {
private colors;
private packageName;
constructor(packageName: string);
private log;
info(msg: string): void;
success(msg: string): void;
warn(msg: string): void;
error(msg: string): void;
}

34
node_modules/@astrojs/sitemap/dist/utils/logger.js generated vendored Normal file
View file

@ -0,0 +1,34 @@
class Logger {
constructor(packageName) {
this.colors = {
reset: "\x1B[0m",
fg: {
red: "\x1B[31m",
green: "\x1B[32m",
yellow: "\x1B[33m"
}
};
this.packageName = packageName;
}
log(msg, prefix = "") {
console.log(`%s${this.packageName}:%s ${msg}
`, prefix, prefix ? this.colors.reset : "");
}
info(msg) {
this.log(msg);
}
success(msg) {
this.log(msg, this.colors.fg.green);
}
warn(msg) {
this.log(`Skipped!
${msg}`, this.colors.fg.yellow);
}
error(msg) {
this.log(`Failed!
${msg}`, this.colors.fg.red);
}
}
export {
Logger
};

View file

@ -0,0 +1,4 @@
export declare const parseUrl: (url: string, defaultLocale: string, localeCodes: string[], base: string) => {
locale: string;
path: string;
} | undefined;

31
node_modules/@astrojs/sitemap/dist/utils/parse-url.js generated vendored Normal file
View file

@ -0,0 +1,31 @@
const parseUrl = (url, defaultLocale, localeCodes, base) => {
if (!url || !defaultLocale || localeCodes.length === 0 || localeCodes.some((key) => !key) || !base) {
throw new Error("parseUrl: some parameters are empty");
}
if (url.indexOf(base) !== 0) {
return void 0;
}
let s = url.replace(base, "");
if (!s || s === "/") {
return { locale: defaultLocale, path: "/" };
}
if (!s.startsWith("/")) {
s = "/" + s;
}
const a = s.split("/");
const locale = a[1];
if (localeCodes.some((key) => key === locale)) {
let path = a.slice(2).join("/");
if (path === "//") {
path = "/";
}
if (path !== "/" && !path.startsWith("/")) {
path = "/" + path;
}
return { locale, path };
}
return { locale: defaultLocale, path: s };
};
export {
parseUrl
};

View file

@ -0,0 +1,15 @@
import type { SitemapOptions } from './index.js';
export declare const validateOptions: (site: string | undefined, opts: SitemapOptions) => {
changefreq?: import("sitemap/dist/lib/types.js").EnumChangefreq | undefined;
priority?: number | undefined;
lastmod?: Date | undefined;
i18n?: {
locales: Record<string, string>;
defaultLocale: string;
} | undefined;
filter?: ((args_0: string, ...args_1: unknown[]) => boolean) | undefined;
customPages?: string[] | undefined;
canonicalURL?: string | undefined;
serialize?: ((args_0: any, ...args_1: unknown[]) => any) | undefined;
entryLimit: number;
};

20
node_modules/@astrojs/sitemap/dist/validate-options.js generated vendored Normal file
View file

@ -0,0 +1,20 @@
import { z } from "zod";
import { SitemapOptionsSchema } from "./schema.js";
const validateOptions = (site, opts) => {
const result = SitemapOptionsSchema.parse(opts);
z.object({
site: z.string().optional(),
// Astro takes care of `site`: how to validate, transform and refine
canonicalURL: z.string().optional()
// `canonicalURL` is already validated in prev step
}).refine((options) => options.site || options.canonicalURL, {
message: "Required `site` astro.config option or `canonicalURL` integration option"
}).parse({
site,
canonicalURL: result.canonicalURL
});
return result;
};
export {
validateOptions
};

1
node_modules/@astrojs/sitemap/node_modules/.bin/sitemap generated vendored Symbolic link
View file

@ -0,0 +1 @@
../../../../sitemap/dist/cli.js

47
node_modules/@astrojs/sitemap/package.json generated vendored Normal file
View file

@ -0,0 +1,47 @@
{
"name": "@astrojs/sitemap",
"description": "Generate a sitemap for your Astro site",
"version": "2.0.0",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/withastro/astro.git",
"directory": "packages/integrations/sitemap"
},
"keywords": [
"astro-integration",
"astro-component",
"seo",
"sitemap"
],
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://docs.astro.build/en/guides/integrations-guide/sitemap/",
"exports": {
".": "./dist/index.js",
"./package.json": "./package.json"
},
"files": [
"dist"
],
"dependencies": {
"sitemap": "^7.1.1",
"zod": "^3.17.3"
},
"devDependencies": {
"chai": "^4.3.7",
"mocha": "^9.2.2",
"xml2js": "0.5.0",
"@astrojs/node": "5.3.0",
"astro": "2.8.4",
"astro-scripts": "0.0.14"
},
"scripts": {
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test": "mocha --timeout 20000"
}
}