astro-sitemap
Advanced tools
Comparing version 0.5.1 to 0.6.0
// src/index.ts | ||
import path from "path"; | ||
import { fileURLToPath } from "url"; | ||
import path from "node:path"; | ||
import { fileURLToPath } from "node:url"; | ||
import { ZodError } from "zod"; | ||
import merge from "deepmerge"; | ||
import load from "@proload/core"; | ||
import typescript from "@proload/plugin-tsm"; | ||
@@ -191,8 +188,8 @@ // ../utils/src/logger.ts | ||
import { SitemapAndIndexStream, SitemapStream } from "sitemap"; | ||
import { createWriteStream, promises } from "fs"; | ||
import { normalize, resolve } from "path"; | ||
import { Readable, pipeline } from "stream"; | ||
import { createGzip } from "zlib"; | ||
import { format, promisify } from "util"; | ||
import { URL as URL2 } from "url"; | ||
import { createWriteStream, promises } from "node:fs"; | ||
import { normalize, resolve } from "node:path"; | ||
import { Readable, pipeline } from "node:stream"; | ||
import { createGzip } from "node:zlib"; | ||
import { format, promisify } from "node:util"; | ||
import { URL as URL2 } from "node:url"; | ||
@@ -264,3 +261,3 @@ // src/output-files.ts | ||
// src/process-pages.ts | ||
import { promises as fs } from "fs"; | ||
import { promises as fs } from "node:fs"; | ||
var addTailSlash = (s) => s.endsWith("/") ? s : s + "/"; | ||
@@ -297,8 +294,8 @@ var removeHeadingSlash = (s) => s.replace(/^\/+/, ""); | ||
// src/helpers/exclude-routes.ts | ||
import mmpkg from "minimatch"; | ||
import { minimatch } from "minimatch"; | ||
function excludeRoutes(patterns, routes) { | ||
patterns.forEach((pattern) => { | ||
const minimatch = new mmpkg.Minimatch(pattern); | ||
minimatch.negate = true; | ||
routes = routes.filter((path2) => minimatch.match(path2)); | ||
const mm = new minimatch.Minimatch(pattern); | ||
mm.negate = true; | ||
routes = routes.filter((path2) => mm.match(path2)); | ||
}); | ||
@@ -327,11 +324,4 @@ return routes; | ||
"astro:build:done": async ({ dir, pages: srcPages }) => { | ||
const namespace = packageName.replace("astro-", ""); | ||
load.use([typescript]); | ||
const external = await load(namespace, { | ||
mustExist: false, | ||
cwd: fileURLToPath(config.root) | ||
}); | ||
const merged = merge((external == null ? void 0 : external.value) || {}, options); | ||
try { | ||
const opts = validateOptions(config.site, merged); | ||
const opts = validateOptions(config.site, options); | ||
const { filter, exclude, customPages, canonicalURL, entryLimit, lastmodDateOnly, xslUrl, xmlns, serialize, createLinkInHead } = opts; | ||
@@ -338,0 +328,0 @@ let finalSiteUrl; |
{ | ||
"name": "astro-sitemap", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"description": "Generate a sitemap for Astro with more control", | ||
@@ -36,6 +36,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@proload/core": "^0.3.3", | ||
"@proload/plugin-tsm": "^0.2.1", | ||
"deepmerge": "^4.3.1", | ||
"minimatch": "^7.4.3", | ||
"minimatch": "^9.0.0", | ||
"sitemap": "^7.1.1", | ||
@@ -45,10 +42,9 @@ "zod": "^3.21.4" | ||
"devDependencies": { | ||
"@types/minimatch": "^5.1.2", | ||
"@types/node": "^18.15.5", | ||
"astro": "^2.1.5", | ||
"@types/node": "^18.15.11", | ||
"astro": "^2.3.0", | ||
"at-scripts": "0.0.4", | ||
"c8": "^7.13.0", | ||
"typescript": "^5.0.2", | ||
"vite": "^4.2.1", | ||
"vitest": "^0.29.7", | ||
"at-scripts": "0.0.4" | ||
"typescript": "^5.0.4", | ||
"vite": "^4.2.2", | ||
"vitest": "^0.30.1" | ||
}, | ||
@@ -55,0 +51,0 @@ "publishConfig": { |
@@ -14,3 +14,2 @@ [![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://war.ukraine.ua/support-ukraine/) | ||
- <strong>[Localization](#localization)</strong> | ||
- <strong>[External config file](#external-config-file)</strong> | ||
- <strong>[Examples](#examples)</strong> | ||
@@ -36,3 +35,2 @@ - <strong>[Contributing](#contributing)</strong> | ||
- 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. | ||
@@ -109,2 +107,3 @@ | ||
__`astro.config.mjs`__ | ||
@@ -171,2 +170,4 @@ | ||
:bulb: For this integration to work correctly, it is recommended to use the `mjs` or `js` configuration file extensions. | ||
__`astro.config.mjs`__ | ||
@@ -183,2 +184,3 @@ | ||
<details> | ||
@@ -717,35 +719,3 @@ <summary><strong>canonicalURL</strong></summary> | ||
## External config file | ||
You can configure the integration using the external file `sitemap.config.*` (`js`, `cjs`, `mjs`, `ts`). Put it in the application `root` folder (see about `root` in official [docs](https://docs.astro.build/en/reference/configuration-reference/)). | ||
The external config must contain the default export statement: | ||
```js | ||
// ESM | ||
export default { | ||
... | ||
}; | ||
``` | ||
or | ||
```js | ||
// CommonJS | ||
module.exports = { | ||
... | ||
}; | ||
``` | ||
**How does the integration internally resolve a config?** | ||
| Options parameter provided? | External config exists? | Result | | ||
| :-------------------------- | :---------------------: | :----------------------------------------------- | | ||
| No | No | Default config used | | ||
| Yes | No | Options parameter used | | ||
| No | Yes | External config used | | ||
| Yes | Yes | External config is merged with options parameter | | ||
The external configuration usage example is in this demo [repo](https://github.com/alextim/astro-lib/tree/main/examples/sitemap/advanced). | ||
## Examples | ||
@@ -752,0 +722,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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3
7
0
40679
441
736
+ Addedminimatch@9.0.5(transitive)
- Removed@proload/core@^0.3.3
- Removed@proload/plugin-tsm@^0.2.1
- Removeddeepmerge@^4.3.1
- Removed@esbuild/android-arm@0.15.18(transitive)
- Removed@esbuild/linux-loong64@0.15.18(transitive)
- Removed@proload/core@0.3.3(transitive)
- Removed@proload/plugin-tsm@0.2.1(transitive)
- Removeddeepmerge@4.3.1(transitive)
- Removedesbuild@0.15.18(transitive)
- Removedesbuild-android-64@0.15.18(transitive)
- Removedesbuild-android-arm64@0.15.18(transitive)
- Removedesbuild-darwin-64@0.15.18(transitive)
- Removedesbuild-darwin-arm64@0.15.18(transitive)
- Removedesbuild-freebsd-64@0.15.18(transitive)
- Removedesbuild-freebsd-arm64@0.15.18(transitive)
- Removedesbuild-linux-32@0.15.18(transitive)
- Removedesbuild-linux-64@0.15.18(transitive)
- Removedesbuild-linux-arm@0.15.18(transitive)
- Removedesbuild-linux-arm64@0.15.18(transitive)
- Removedesbuild-linux-mips64le@0.15.18(transitive)
- Removedesbuild-linux-ppc64le@0.15.18(transitive)
- Removedesbuild-linux-riscv64@0.15.18(transitive)
- Removedesbuild-linux-s390x@0.15.18(transitive)
- Removedesbuild-netbsd-64@0.15.18(transitive)
- Removedesbuild-openbsd-64@0.15.18(transitive)
- Removedesbuild-sunos-64@0.15.18(transitive)
- Removedesbuild-windows-32@0.15.18(transitive)
- Removedesbuild-windows-64@0.15.18(transitive)
- Removedesbuild-windows-arm64@0.15.18(transitive)
- Removedescalade@3.2.0(transitive)
- Removedminimatch@7.4.6(transitive)
- Removedtsm@2.3.0(transitive)
Updatedminimatch@^9.0.0