astro-robots-txt
Advanced tools
Comparing version 0.3.5 to 0.3.6
@@ -6,2 +6,3 @@ "use strict"; | ||
import { ZodError } from "zod"; | ||
import merge from "deepmerge"; | ||
@@ -53,4 +54,8 @@ // ../utils/src/is-valid-hostname.ts | ||
} | ||
toArray(msg) { | ||
return Array.isArray(msg) ? msg : [msg]; | ||
} | ||
log(msg, prefix = "") { | ||
console.log(`%s${this.packageName}:%s ${msg} | ||
const s = Array.isArray(msg) ? msg.join("\n") : msg; | ||
console.log(`%s${this.packageName}:%s ${s} | ||
`, prefix, prefix ? this.colors.reset : ""); | ||
@@ -65,8 +70,6 @@ } | ||
warn(msg) { | ||
this.log(`Skipped! | ||
${msg}`, this.colors.fg.yellow); | ||
this.log(["Skipped!", ...this.toArray(msg)], this.colors.fg.yellow); | ||
} | ||
error(msg) { | ||
this.log(`Failed! | ||
${msg}`, this.colors.fg.red); | ||
this.log(["Failed!", ...this.toArray(msg)], this.colors.fg.red); | ||
} | ||
@@ -109,4 +112,6 @@ }; | ||
// src/index.ts | ||
import merge from "deepmerge"; | ||
// ../utils/src/error-helpers.ts | ||
function getErrorMessage(err) { | ||
return err instanceof Error ? err.message : String(err); | ||
} | ||
@@ -233,3 +238,3 @@ // src/validate-options.ts | ||
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"); | ||
@@ -262,4 +267,3 @@ } | ||
} catch (err) { | ||
logger.error(`Error transforming content | ||
${err.toString()}`); | ||
logger.error(["Error transforming content", getErrorMessage(err)]); | ||
return; | ||
@@ -266,0 +270,0 @@ } |
{ | ||
"name": "astro-robots-txt", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "Generate a robots.txt for Astro", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"@types/node": "^18.0.0", | ||
"astro": "^1.0.0-beta.50", | ||
"astro": "^1.0.0-beta.53", | ||
"at-scripts": "0.0.4", | ||
@@ -47,3 +47,3 @@ "c8": "^7.11.3", | ||
"vite": "^2.9.12", | ||
"vitest": "^0.15.2" | ||
"vitest": "^0.16.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "publishConfig": { |
@@ -100,3 +100,3 @@ [](https://bank.gov.ua/en/about/support-the-armed-forces) | ||
Allow: / | ||
Sitemap: https://example.com/sitemap.xml | ||
Sitemap: https://example.com/sitemap-index.xml | ||
``` | ||
@@ -113,5 +113,5 @@ | ||
| `host` | `String` | No | | Host of your site | | ||
| `sitemap` |`Boolean` / `String` / `String[]`| No | `true` | Resulting output in a _robots.txt_ will be `Sitemap: your-site-url/sitemap.xml`.<br/>If `sitemap: false` - no `Sitemap` line in the output.<br/>When the `sitemap` is `String` or `String[]` its values have to be a valid **http** url. Empty strings or other protocols are not allowed. | | ||
| `sitemap` |`Boolean` / `String` / `String[]`| No | `true` | Resulting output in a _robots.txt_ will be `Sitemap: your-site-url/sitemap-index.xml`.<br/>If `sitemap: false` - no `Sitemap` line in the output.<br/>When the `sitemap` is `String` or `String[]` its values have to be a valid **http** url. Empty strings or other protocols are not allowed. | | ||
| `policy` | `Policy[]` | No | [{ allow: `/`, userAgent: `*` }] | List of `Policy` rules | | ||
| `sitemapBaseFileName` | `String` | No | `sitemap-index`| The name of a sitemap file before the file extension (`.xml`). It's used if the `sitemap` option is `true`. | | ||
| `sitemapBaseFileName` | `String` | No | `sitemap-index`| The name of a sitemap file before the file extension (`.xml`). It will be used if the `sitemap` option is `true`.<br/>[@astrojs/sitemap](https://github.com/withastro/astro/tree/main/packages/integrations/sitemap) and [astro-sitemap](https://github.com/alextim/astro-lib/tree/main/packages/astro-sitemap) have `sitemap-index.xml` as their primary output. | | ||
| `transform` |`(content: String):`<br/> `String`\|`Promise<String>` | No | | Called just before writing the text output to disk. Sync or async. | | ||
@@ -167,3 +167,3 @@ | ||
transform(content) { | ||
return `# some comments before main content\n#second line\n${content}`; | ||
return `# Some comments before main content.\n# Second line.\n\n${content}`; | ||
}, | ||
@@ -170,0 +170,0 @@ }), |
21480
267