astro-robots-txt
Advanced tools
Comparing version 0.1.17 to 0.2.0
@@ -14,3 +14,3 @@ import type { AstroIntegration } from 'astro'; | ||
} | undefined; | ||
declare const createPlugin: (pluginOptions?: RobotsTxtOptions) => AstroIntegration; | ||
declare const createPlugin: (pluginOptions: RobotsTxtOptions) => AstroIntegration; | ||
export default createPlugin; |
@@ -1,4 +0,1 @@ | ||
// src/index.ts | ||
import fs from "fs"; | ||
// ../utils/src/is-object-empty.ts | ||
@@ -74,3 +71,3 @@ var isObjectEmpty = (o) => { | ||
log(msg, prefix = "") { | ||
console.log(`%s${this.packageName}: ${msg}%s | ||
console.log(`%s${this.packageName}:%s ${msg} | ||
`, prefix, prefix ? this.colors.reset : ""); | ||
@@ -89,3 +86,3 @@ } | ||
error(msg) { | ||
this.log(`Failed to create 'robots.txt'! | ||
this.log(`Failed! | ||
${msg}`, this.colors.fg.red); | ||
@@ -98,2 +95,5 @@ } | ||
// src/on-build-done.ts | ||
import fs from "fs"; | ||
// src/with-options.ts | ||
@@ -290,5 +290,17 @@ var defaultOptions = { | ||
// src/on-build-done.ts | ||
var onBuildDone = (pluginOptions, config, dir, logger2) => { | ||
const opts = withOptions(pluginOptions); | ||
if (!isOptsValid(config.site, opts, logger2)) { | ||
return; | ||
} | ||
const robotsTxtContent = getRobotsTxtContent(config.site, opts); | ||
const url = new URL("robots.txt", dir); | ||
fs.writeFileSync(url, robotsTxtContent); | ||
logger2.success("`robots.txt` is created."); | ||
}; | ||
var on_build_done_default = onBuildDone; | ||
// src/index.ts | ||
var logger2 = new Logger(packageName); | ||
var createPlugin = (pluginOptions = {}) => { | ||
var createPlugin = (pluginOptions) => { | ||
let config; | ||
@@ -301,16 +313,3 @@ return { | ||
}, | ||
"astro:build:done": async ({ dir }) => { | ||
const opts = withOptions(pluginOptions); | ||
if (!isOptsValid(config.site, opts, logger2)) { | ||
return; | ||
} | ||
const robotsTxtContent = getRobotsTxtContent(config.site, opts); | ||
try { | ||
const url = new URL("robots.txt", dir); | ||
fs.writeFileSync(url, robotsTxtContent); | ||
logger2.success("`robots.txt` is created."); | ||
} catch (err) { | ||
logger2.error(err.toString()); | ||
} | ||
} | ||
"astro:build:done": async ({ dir }) => on_build_done_default(pluginOptions, config, dir, new Logger(packageName)) | ||
} | ||
@@ -317,0 +316,0 @@ }; |
{ | ||
"name": "astro-robots-txt", | ||
"version": "0.1.17", | ||
"version": "0.2.0", | ||
"description": "Generate a robots.txt for Astro", | ||
@@ -35,10 +35,9 @@ "keywords": [ | ||
"devDependencies": { | ||
"@types/node": "^17.0.35", | ||
"@types/jest": "^27.5.1", | ||
"at-scripts": "0.0.1", | ||
"astro": "^1.0.0-beta.31", | ||
"jest": "28.1.0", | ||
"memfs": "^3.4.3", | ||
"ts-jest": "^28.0.2", | ||
"typescript": "^4.6.4" | ||
"@types/node": "^17.0.38", | ||
"astro": "^1.0.0-beta.38", | ||
"at-scripts": "0.0.3", | ||
"c8": "^7.11.3", | ||
"typescript": "^4.7.2", | ||
"vite": "^2.9.9", | ||
"vitest": "^0.13.1" | ||
}, | ||
@@ -50,8 +49,8 @@ "publishConfig": { | ||
"scripts": { | ||
"build": "at-scripts create-pkg-name && at-scripts build && tsc -p tsconfig.build.json && node ./scripts/copy.mjs", | ||
"build:declarations": "tsc -p tsconfig.build.json", | ||
"typecheck": "tsc --noEmit", | ||
"test": "jest", | ||
"build": "at-scripts create-pkg-name && at-scripts build && tsc -p tsconfig.build.json && at-scripts copy-index.d.ts", | ||
"typecheck": "tsc --noEmit --pretty", | ||
"test": "vitest run", | ||
"coverage": "vitest run --coverage", | ||
"test:pub": "pnpm publish --dry-run --no-git-checks" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
<a href="https://war.ukraine.ua/support-ukraine/"> | ||
<a href="https://bank.gov.ua/en/about/support-the-armed-forces"> | ||
<img src="https://raw.githubusercontent.com/alextim/help-ukraine-win-flag/master/stop-russian-agressian-help-ukraine-now-link.svg" alt="Help Ukraine now!"> | ||
@@ -7,3 +7,3 @@ </a> | ||
This **[Astro integration][astro-integration]** generates a _robots.txt_ for your Astro project during build. | ||
This **[Astro integration](https://docs.astro.build/en/guides/integrations-guide/)** generates a _robots.txt_ for your Astro project during build. | ||
@@ -106,3 +106,3 @@  [](https://opensource.org/licenses/MIT) | ||
You can also check our [Astro Integration Documentation][astro-integration] for more on integrations. | ||
You can also check [Astro Integration Documentation](https://docs.astro.build/en/guides/integrations-guide/) for more on integrations. | ||
@@ -109,0 +109,0 @@ ## Configuration |
19682
7
320