shevky-plugin-robots-txt 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -0
  3. package/main.js +36 -0
  4. package/package.json +34 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fatih Tatoğlu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # shevky-plugin-robots-txt
2
+
3
+ A simple Shevky plugin that generates `robots.txt`. It runs on the `dist:clean` hook, uses allow/disallow lists from the config, and adds a `Sitemap` line based on the site root URL.
4
+
5
+ ## Features
6
+
7
+ - Automatically generates `robots.txt`
8
+ - Reads `Allow` and `Disallow` rules from config
9
+ - Writes `Sitemap` as `<site-url>/sitemap.xml`
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm i shevky-plugin-robots-txt
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ The example config below uses `identity.url`, `robots.allow`, and `robots.disallow`:
20
+
21
+ ```json
22
+ // site.json (example)
23
+ {
24
+ "identity": {
25
+ "url": "https://example.com",
26
+ },
27
+ "robots": {
28
+ "allow": ["/", "/blog/"],
29
+ "disallow": ["/admin/", "/private/"],
30
+ },
31
+ "plugins": [
32
+ "shevky-plugin-robots-txt",
33
+ ],
34
+ }
35
+ ```
36
+
37
+ Example generated `robots.txt` output:
38
+
39
+ ```text
40
+ User-agent: *
41
+ Allow: /
42
+ Allow: /blog/
43
+ Disallow: /admin/
44
+ Disallow: /private/
45
+
46
+ Sitemap: https://example.com/sitemap.xml
47
+ ```
48
+
49
+ ## License
50
+
51
+ MIT
package/main.js ADDED
@@ -0,0 +1,36 @@
1
+ const PLUGIN = {
2
+ name: "shevky-robots-txt",
3
+ version: "0.0.1",
4
+ hooks: {
5
+ "dist:clean": async function (ctx, services) {
6
+ const _cfg = ctx.config;
7
+ const base = _cfg.identity.url.replace(/\/+$/, "");
8
+ const allowList = _cfg.robots.allow;
9
+ const disallowList = _cfg.robots.disallow;
10
+
11
+ const lines = ["User-agent: *"];
12
+
13
+ allowList.forEach((path) => {
14
+ if (typeof path === "string" && path.trim().length > 0) {
15
+ lines.push(`Allow: ${path.trim()}`);
16
+ }
17
+ });
18
+
19
+ disallowList.forEach((path) => {
20
+ if (typeof path === "string" && path.trim().length > 0) {
21
+ lines.push(`Disallow: ${path.trim()}`);
22
+ }
23
+ });
24
+
25
+ lines.push("");
26
+ lines.push(`Sitemap: ${base}/sitemap.xml`);
27
+ lines.push("");
28
+
29
+ const payload = lines.join("\n");
30
+
31
+ await services.write("robots.txt", payload, {});
32
+ },
33
+ },
34
+ };
35
+
36
+ export default PLUGIN;
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "shevky-plugin-robots-txt",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "main": "main.js",
6
+ "exports": "./main.js",
7
+ "files": [
8
+ "main.js",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "keywords": [
13
+ "shevky",
14
+ "plugin",
15
+ "robots.txt",
16
+ "robots",
17
+ "sitemap",
18
+ "seo"
19
+ ],
20
+ "author": "Fatih Tatoğlu <fatih@tatoglu.net>",
21
+ "license": "MIT",
22
+ "description": "Shevky plugin that generates robots.txt from allow/disallow rules and adds a sitemap line.",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/fatihtatoglu/shevky-plugin-robots-txt.git"
26
+ },
27
+ "homepage": "https://github.com/fatihtatoglu/shevky-plugin-robots-txt#readme",
28
+ "bugs": {
29
+ "url": "https://github.com/fatihtatoglu/shevky-plugin-robots-txt/issues"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ }
34
+ }