astro-sitemap
Advanced tools
Comparing version 0.2.8 to 0.3.0
@@ -20,21 +20,18 @@ // src/index.ts | ||
} | ||
toArray(msg) { | ||
return Array.isArray(msg) ? msg : [msg]; | ||
} | ||
log(msg, prefix = "") { | ||
const s = Array.isArray(msg) ? msg.join("\n") : msg; | ||
const s = msg.join("\n"); | ||
console.log(`%s${this.packageName}:%s ${s} | ||
`, prefix, prefix ? this.colors.reset : ""); | ||
} | ||
info(msg) { | ||
info(...msg) { | ||
this.log(msg); | ||
} | ||
success(msg) { | ||
success(...msg) { | ||
this.log(msg, this.colors.fg.green); | ||
} | ||
warn(msg) { | ||
this.log(["Skipped!", ...this.toArray(msg)], this.colors.fg.yellow); | ||
warn(...msg) { | ||
this.log(["Skipped!", ...msg], this.colors.fg.yellow); | ||
} | ||
error(msg) { | ||
this.log(["Failed!", ...this.toArray(msg)], this.colors.fg.red); | ||
error(...msg) { | ||
this.log(["Failed!", ...msg], this.colors.fg.red); | ||
} | ||
@@ -110,5 +107,8 @@ }; | ||
defaultLocale: localeKeySchema, | ||
locales: z.record(localeKeySchema, z.string().min(2).regex(/^[a-zA-Z\-]+$/gm, { | ||
message: "Only English alphabet symbols and hyphen allowed" | ||
})) | ||
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], { | ||
@@ -227,3 +227,3 @@ message: "`defaultLocale` must exist in `locales` keys" | ||
import { createGzip } from "zlib"; | ||
import { promisify } from "util"; | ||
import { format, promisify } from "util"; | ||
import { URL as URL2 } from "url"; | ||
@@ -263,3 +263,3 @@ | ||
}); | ||
const chunkName = SITEMAP_CHUNK_TEMPLATE.replace("%d", i.toString(10)) + suffix; | ||
const chunkName = format(SITEMAP_CHUNK_TEMPLATE, i) + suffix; | ||
result.push(chunkName); | ||
@@ -347,3 +347,3 @@ const writePath2 = resolve(destinationDir, chunkName); | ||
} | ||
var createSitemapIntegration = (options) => { | ||
var createSitemapIntegration = (options = {}) => { | ||
let config; | ||
@@ -358,4 +358,4 @@ return { | ||
const namespace = packageName.replace("astro-", ""); | ||
const external = await loadConfig(namespace, config.root); | ||
const merged = merge(external || {}, options || {}); | ||
const external = await loadConfig(namespace, config.root) || {}; | ||
const merged = merge(external, options); | ||
try { | ||
@@ -378,3 +378,3 @@ const opts = validateOptions(config.site, merged); | ||
} catch (err) { | ||
logger.error(["Page exclusion error", getErrorMessage(err)]); | ||
logger.error("Page exclusion error", getErrorMessage(err)); | ||
return; | ||
@@ -387,3 +387,3 @@ } | ||
} catch (err) { | ||
logger.error(["Page filtering error", getErrorMessage(err)]); | ||
logger.error("Page filtering error", getErrorMessage(err)); | ||
return; | ||
@@ -400,7 +400,9 @@ } | ||
if (pageUrls.length === 0) { | ||
if (typeof config.adapter !== "undefined") { | ||
logger.warn(`No pages found! | ||
We can only detect sitemap routes for "static" projects. Since you are using an SSR adapter, we recommend manually listing your sitemap routes using the "customPages" integration option. | ||
Example: \`sitemap({ customPages: ['https://example.com/route'] })\``); | ||
if (config.output !== "static") { | ||
logger.warn( | ||
"No pages found!", | ||
'We can only detect sitemap routes for "static" projects. Since you are using an SSR adapter, we recommend manually listing your sitemap routes using the "customPages" integration option.', | ||
"", | ||
"Example: `sitemap({ customPages: ['https://example.com/route'] })`" | ||
); | ||
} else { | ||
@@ -427,3 +429,3 @@ logger.warn("No pages found!"); | ||
} catch (err) { | ||
logger.error(["Page serialization error", getErrorMessage(err)]); | ||
logger.error("Page serialization error", getErrorMessage(err)); | ||
return; | ||
@@ -441,3 +443,3 @@ } | ||
}); | ||
logger.success([`${fileNames.map((name) => `\`${name}\``).join(", ")} are created.`, `Total entries: ${urlData.length}.`]); | ||
logger.success(`${fileNames.map((name) => `\`${name}\``).join(", ")} are created.`, `Total entries: ${urlData.length}.`); | ||
if (createLinkInHead) { | ||
@@ -444,0 +446,0 @@ const sitemapHref = path.posix.join(config.base, fileNames[0]); |
{ | ||
"name": "astro-sitemap", | ||
"version": "0.2.8", | ||
"version": "0.3.0", | ||
"description": "Generate a sitemap for Astro with more control", | ||
@@ -43,9 +43,9 @@ "keywords": [ | ||
"@types/minimatch": "^3.0.5", | ||
"@types/node": "^18.0.6", | ||
"astro": "^1.0.0-beta.73", | ||
"@types/node": "^18.6.1", | ||
"astro": "^1.0.0-rc.1", | ||
"at-scripts": "0.0.4", | ||
"c8": "^7.12.0", | ||
"typescript": "^4.7.4", | ||
"vite": "^3.0.2", | ||
"vitest": "^0.18.1" | ||
"vite": "^3.0.3", | ||
"vitest": "^0.19.1" | ||
}, | ||
@@ -52,0 +52,0 @@ "publishConfig": { |
@@ -34,9 +34,9 @@ [![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) | ||
- possibility to add a link to custom XSL. | ||
- Automatically creates a link to sitemap in `<head>` section of generated pages. | ||
- Automatically creates a link to the sitemap in the `<head>` section of generated pages. | ||
- Flexible configuration: configure the integration with an external config, `astro.config.*` or a combination of both. | ||
- Better logging. | ||
Part of the functionality from **astro-sitemap** became an update for the official integration [@astrojs/sitemap](https://github.com/withastro/astro/tree/main/packages/integrations/sitemap) from v0.1.2 to v0.2.0. | ||
Part of the functionality of **astro-sitemap** has become a minor update of the official integration [@astrojs/sitemap](https://github.com/withastro/astro/tree/main/packages/integrations/sitemap) from v0.1.2 to version 0.2.0. | ||
Shared functionality with the official **@astrojs/sitemap**: | ||
Shared functionality with the official [@astrojs/sitemap](https://github.com/withastro/astro/tree/main/packages/integrations/sitemap): | ||
@@ -540,3 +540,3 @@ - Split up your large sitemap into multiple sitemaps by a custom limit. | ||
<details> | ||
<summary><strong>Type `NSArgs`</strong></summary> | ||
<summary><strong>Interface `NSArgs`</strong></summary> | ||
@@ -579,6 +579,4 @@ | Name | Type | Required | Default | Description | | ||
```xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?xml-stylesheet type="text/xsl" href="https://example/style.xsl"?> | ||
<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" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> | ||
@@ -585,0 +583,0 @@ ... |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
470
43627
786