Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

astro-sitemap

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-sitemap - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

9

dist/index.d.ts
import type { AstroIntegration } from 'astro';
import { LinkItem as LinkItemBase, SitemapItemLoose } from 'sitemap';
import { changefreqValues } from './constants';
export declare type ChangeFreq = typeof changefreqValues[number];
import { LinkItem as LinkItemBase, SitemapItemLoose, EnumChangefreq } from 'sitemap';
export declare type ChangeFreq = EnumChangefreq;
export declare type SitemapItem = Pick<SitemapItemLoose, 'url' | 'lastmod' | 'changefreq' | 'priority' | 'links'>;

@@ -16,9 +15,9 @@ export declare type LinkItem = LinkItemBase;

entryLimit?: number;
createLinkInHead?: boolean;
serialize?(item: SitemapItemLoose): SitemapItemLoose;
changefreq?: ChangeFreq;
lastmod?: Date;
priority?: number;
serialize?(item: SitemapItem): SitemapItem | Promise<SitemapItem>;
createLinkInHead?: boolean;
} | undefined;
declare const createPlugin: (options?: SitemapOptions) => AstroIntegration;
export default createPlugin;

@@ -0,1 +1,3 @@

"use strict";
// src/index.ts

@@ -80,6 +82,4 @@ import path from "path";

import { z } from "zod";
import { EnumChangefreq as ChangeFreq } from "sitemap";
// src/constants.ts
var changefreqValues = ["always", "hourly", "daily", "weekly", "monthly", "yearly", "never"];
// src/config-defaults.ts

@@ -92,21 +92,21 @@ var SITEMAP_CONFIG_DEFAULTS = {

// src/schema.ts
var localeKeySchema = () => z.string().min(1);
var isFunction = (fn) => fn instanceof Function;
var fnSchema = () => z.any().refine((val) => !val || isFunction(val), { message: "Not a function" }).optional();
var localeKeySchema = z.string().min(1);
var SitemapOptionsSchema = z.object({
filter: fnSchema(),
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" }))
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 exists in `locales` keys"
message: "`defaultLocale` must exist in `locales` keys"
}).optional(),
createLinkInHead: z.boolean().default(SITEMAP_CONFIG_DEFAULTS.createLinkInHead),
entryLimit: z.number().nonnegative().default(SITEMAP_CONFIG_DEFAULTS.entryLimit),
serialize: fnSchema(),
changefreq: z.enum(changefreqValues).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()
priority: z.number().min(0).max(1).optional(),
createLinkInHead: z.boolean().optional().default(SITEMAP_CONFIG_DEFAULTS.createLinkInHead)
}).strict().default(SITEMAP_CONFIG_DEFAULTS);

@@ -162,7 +162,6 @@

function generateSitemap(pages, finalSiteUrl, opts) {
const { changefreq, priority: prioritySrc, lastmod: lastmodSrc, i18n } = opts;
const { changefreq, priority, lastmod: lastmodSrc, i18n } = opts;
const urls = [...pages].filter((url) => !STATUS_CODE_PAGE_REGEXP.test(url));
urls.sort((a, b) => a.localeCompare(b, "en", { numeric: true }));
const lastmod = lastmodSrc == null ? void 0 : lastmodSrc.toISOString();
const priority = typeof prioritySrc === "number" ? prioritySrc : void 0;
const { locales, defaultLocale } = i18n || {};

@@ -243,3 +242,3 @@ const localeCodes = Object.keys(locales || {});

function formatConfigErrorMessage(err) {
const errorList = err.issues.map((issue) => ` ${issue.path.join(".")} ${issue.message + "."}`);
const errorList = err.issues.map((issue) => `${issue.path.join(".")} ${issue.message + "."}`);
return errorList.join("\n");

@@ -246,0 +245,0 @@ }

{
"name": "astro-sitemap",
"version": "0.2.2",
"version": "0.2.3",
"description": "Generate a sitemap for Astro with more control",

@@ -32,4 +32,3 @@ "keywords": [

"dist/index.js",
"dist/index.d.ts",
"dist/constants.ts"
"dist/index.d.ts"
],

@@ -43,7 +42,7 @@ "dependencies": {

"devDependencies": {
"@types/node": "^17.0.43",
"astro": "^1.0.0-beta.46",
"@types/node": "^18.0.0",
"astro": "^1.0.0-beta.47",
"at-scripts": "0.0.4",
"c8": "^7.11.3",
"typescript": "^4.7.3",
"typescript": "^4.7.4",
"vite": "^2.9.12",

@@ -57,3 +56,3 @@ "vitest": "^0.15.1"

"scripts": {
"build": "at-scripts create-pkg-name && at-scripts build && tsc -p tsconfig.build.json && at-scripts copy index.d.ts && at-scripts copy-s constants.ts",
"build": "at-scripts create-pkg-name && at-scripts build && tsc -p tsconfig.build.json && at-scripts copy index.d.ts",
"typecheck": "tsc --noEmit --pretty",

@@ -60,0 +59,0 @@ "test": "vitest run",

@@ -163,16 +163,16 @@ [![Help Ukraine now!](https://raw.githubusercontent.com/alextim/help-ukraine-win-flag/master/stop-russian-agressian-help-ukraine-now-link.svg 'Help Ukraine now!')](https://bank.gov.ua/en/about/support-the-armed-forces)

| Name | Type | Required | Description |
| :------------: | :-------------: | :------: | :--------------- |
| `url` | `String` | Yes | Absolute url |
| `changefreq` | `ChangeFreq` | No | |
| `lastmod` | `Date` | No | |
| `priority` | `Number` | No | |
| `links` | `LinkItem[]` | No | for localization |
| Name | Type | Required | Description |
| :------------: | :-------------: | :------: | :----------------- |
| `url` | `String` | Yes | Absolute url |
| `changefreq` | `ChangeFreq` | No | |
| `lastmod` | `String` | No | ISO formatted date |
| `priority` | `Number` | No | |
| `links` | `LinkItem[]` | No | for localization |
### LinkItem
| Name | Type | Required | Description |
| :------------: | :-------------: | :------: | :-------------- |
| `url` | `String` | Yes | Absolute url |
| `hreflang` | `String` | No | example 'en-us' |
| Name | Type | Required | Description |
| :------------: | :-------------: | :------: | :------------------------ |
| `url` | `String` | Yes | Absolute url |
| `lang` | `String` | Yes | hreflag, example: 'en-US' |

@@ -197,5 +197,5 @@ **Sample of _astro.config.mjs_**

// exclude pages from sitemap
filter: (page: string) => !/exclude-this/.test(page), // default - undefined
filter: (page: string) => !/exclude-this/.test(page), // default - undefined
// Absolute urls of extra pages
customPages: [ // default - undefined
customPages: [ // default - undefined
// extra pages for sitemap

@@ -207,11 +207,10 @@ 'https://sample.com/virtual-one.html',

// if `canonicalURL` is provided it will be used instead of `site` value
canonicalURL: 'https://sample.com', // default - undefined
canonicalURL: 'https://sample.com', // default - undefined
/**
* `astro-sitemap` integration options
*/
* `astro-sitemap` integration extra options
*/
// This function is called just before a sitemap writing to disk.
// You have more control on resulting output.
// async supported.
serialize(item: SitemapItem): SitemapItem { // default - undefined
// sync or async
serialize(item: SitemapItem): SitemapItem {
if (/special-page/.test(item.url)) {

@@ -228,9 +227,9 @@ item.changefreq = 'daily';

// sitemap specific
changefreq: 'yearly', // default - undefined
lastmod: new Date('May 01, 2019 03:24:00'), // default - undefined
priority: 0.2, // default - undefined
// Create or not a link to sitemap in '<head>' section of generated pages
createLinkInHead: true, // default - true
// sitemap specific
changefreq: 'yearly', // default - undefined
lastmod: new Date('May 01, 2019 03:24:00'), // default - undefined
priority: 0.2, // default - undefined
}),

@@ -237,0 +236,0 @@ ],

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc