@zeruxjs/seo 0.0.0-stage → 0.0.2
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.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +9 -0
- package/README.md +37 -2
- package/dist/escape.d.ts +3 -0
- package/dist/escape.js +13 -0
- package/dist/escape.js.map +1 -0
- package/dist/fetch.d.ts +23 -0
- package/dist/fetch.js +112 -0
- package/dist/fetch.js.map +1 -0
- package/dist/http.d.ts +12 -0
- package/dist/http.js +13 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata.d.ts +3 -0
- package/dist/metadata.js +50 -0
- package/dist/metadata.js.map +1 -0
- package/dist/robots.d.ts +7 -0
- package/dist/robots.js +16 -0
- package/dist/robots.js.map +1 -0
- package/dist/sitemap.d.ts +6 -0
- package/dist/sitemap.js +37 -0
- package/dist/sitemap.js.map +1 -0
- package/dist/types.d.ts +28 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +40 -4
package/LICENSE-APACHE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/LICENSE-MIT
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ZeruxJS.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zeruxjs/seo
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Modular page metadata and crawler files. Modules: `metadata`, `sitemap`, `robots`, `escape`, `http`, and `types`; the top-level `index.ts` is a public barrel.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { createMetaTags, createSitemap, createRobotsTxt, sitemapResponse } from '@zeruxjs/seo';
|
|
7
|
+
const head = createMetaTags({ title: 'Home', canonical: 'https://example.com', description: 'Welcome!' });
|
|
8
|
+
const sitemap = createSitemap([{ loc: 'https://example.com/', priority: 1 }]);
|
|
9
|
+
const robots = createRobotsTxt({ disallow: ['/private'], sitemap: 'https://example.com/sitemap.xml' });
|
|
10
|
+
const response = sitemapResponse([{loc: 'https://example.com/'}]);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Supports Open Graph, Twitter cards, JSON-LD, sitemap indexes, image entries, alternate languages, robots groups, crawler delay validation, XML/HTML escaping, and response helpers. Applications remain responsible for their canonical domain and content policies.
|
|
14
|
+
|
|
15
|
+
## Fetch crawler endpoints (Section 39)
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { createCrawlerService } from '@zeruxjs/seo/fetch';
|
|
19
|
+
const crawler = createCrawlerService({
|
|
20
|
+
origin: 'https://example.com',
|
|
21
|
+
entries: () => getPublicSitemapEntries(),
|
|
22
|
+
maxUrlsPerSitemap: 10000,
|
|
23
|
+
maxXmlBytes: 45_000_000,
|
|
24
|
+
cacheSeconds: 600,
|
|
25
|
+
snapshotTtlMs: 30000
|
|
26
|
+
});
|
|
27
|
+
// crawler.routes: /robots.txt, /sitemap.xml, /sitemaps/:page
|
|
28
|
+
// After a content deployment:
|
|
29
|
+
crawler.invalidate();
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Supports 50,000-entry-per-sitemap maximum, bounded XML byte sizes, size-based splitting, deterministic sitemap indexes, and conditional ETag responses. Optional in-memory snapshot caching coalesces concurrent rebuilds and can be explicitly invalidated. By default no server-side snapshot cache is kept; use a fresh supplier function for changing content. URLs must be public HTTPS/HTTP URLs. The `robots.txt` route only points crawlers at your sitemap; it does not implement authentication or robots enforcement.
|
|
33
|
+
|
|
34
|
+
Section 80: `createSitemap()` validates `changefreq` against the sitemap vocabulary at runtime, including untyped/JSON-fed calls.
|
|
35
|
+
|
|
36
|
+
## Release 0.0.2
|
|
37
|
+
|
|
38
|
+
Prepared to validate npm trusted publishing through GitHub Actions.
|
package/dist/escape.d.ts
ADDED
package/dist/escape.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeHtml = void 0;
|
|
4
|
+
exports.safeUrl = safeUrl;
|
|
5
|
+
exports.iso = iso;
|
|
6
|
+
// eslint-disable-next-line no-control-regex -- Intentionally matches control characters for validation or output sanitization.
|
|
7
|
+
const escapeHtml = (value) => String(value).replace(/[\x00-\x08\x0b\x0c\x0e-\x1f]/g, '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
8
|
+
exports.escapeHtml = escapeHtml;
|
|
9
|
+
function safeUrl(value) { const url = new URL(value); if (!['https:', 'http:'].includes(url.protocol) || url.username || url.password)
|
|
10
|
+
throw new TypeError('Expected an HTTP(S) URL without credentials'); return url.href; }
|
|
11
|
+
function iso(value) { const date = new Date(value); if (!Number.isFinite(date.getTime()))
|
|
12
|
+
throw new TypeError('Invalid sitemap date'); return date.toISOString().slice(0, 10); }
|
|
13
|
+
//# sourceMappingURL=escape.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escape.js","sourceRoot":"","sources":["../src/escape.ts"],"names":[],"mappings":";;;AAEA,0BAAiP;AACjP,kBAA0M;AAH1M,+HAA+H;AACxH,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,+BAA+B,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAC,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAC,OAAO,CAAC,CAAC;AAAhN,QAAA,UAAU,cAAsM;AAC7N,SAAgB,OAAO,CAAC,KAAY,IAAW,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ;IAAE,MAAM,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACjP,SAAgB,GAAG,CAAC,KAAkB,IAAW,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;IAAE,MAAM,IAAI,SAAS,CAAC,sBAAsB,CAAC,CAAC,CAAC,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC,EAAC,EAAE,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/fetch.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SitemapEntry } from './types.js';
|
|
2
|
+
import { createRobotsTxt } from './robots.js';
|
|
3
|
+
export interface CrawlerRoutesOptions {
|
|
4
|
+
origin: string;
|
|
5
|
+
entries: Iterable<SitemapEntry> | (() => Iterable<SitemapEntry> | Promise<Iterable<SitemapEntry>>);
|
|
6
|
+
robots?: Parameters<typeof createRobotsTxt>[0];
|
|
7
|
+
maxUrlsPerSitemap?: number;
|
|
8
|
+
maxXmlBytes?: number;
|
|
9
|
+
cacheSeconds?: number;
|
|
10
|
+
/** Optional server-side snapshot TTL; zero rebuilds on every request. */
|
|
11
|
+
snapshotTtlMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface CrawlerRoute {
|
|
14
|
+
path: string;
|
|
15
|
+
handler: (request: Request) => Promise<Response>;
|
|
16
|
+
}
|
|
17
|
+
/** Generates a sitemap index for large sites, and size-bounded individual pages. */
|
|
18
|
+
export declare function createCrawlerService(options: CrawlerRoutesOptions): {
|
|
19
|
+
routes: CrawlerRoute[];
|
|
20
|
+
invalidate(): void;
|
|
21
|
+
};
|
|
22
|
+
/** Backwards-compatible route builder without exposing the cache controller. */
|
|
23
|
+
export declare function createCrawlerRoutes(options: CrawlerRoutesOptions): CrawlerRoute[];
|
package/dist/fetch.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCrawlerService = createCrawlerService;
|
|
4
|
+
exports.createCrawlerRoutes = createCrawlerRoutes;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const sitemap_js_1 = require("./sitemap.js");
|
|
7
|
+
const robots_js_1 = require("./robots.js");
|
|
8
|
+
function respond(request, body, contentType, cacheSeconds) {
|
|
9
|
+
const etag = `"${(0, node_crypto_1.createHash)('sha256').update(body).digest('base64url')}"`;
|
|
10
|
+
const headers = { 'content-type': contentType, 'x-content-type-options': 'nosniff', 'cache-control': `public, max-age=${cacheSeconds}`, etag };
|
|
11
|
+
if (request.method !== 'GET' && request.method !== 'HEAD')
|
|
12
|
+
return new Response(null, { status: 405, headers: { allow: 'GET, HEAD' } });
|
|
13
|
+
if (request.headers.get('if-none-match')?.split(',').some(t => t.trim() === etag || t.trim() === '*'))
|
|
14
|
+
return new Response(null, { status: 304, headers });
|
|
15
|
+
return new Response(request.method === 'HEAD' ? null : body, { headers });
|
|
16
|
+
}
|
|
17
|
+
/** Generates a sitemap index for large sites, and size-bounded individual pages. */
|
|
18
|
+
function createCrawlerService(options) {
|
|
19
|
+
const origin = new URL(options.origin);
|
|
20
|
+
if (!['https:', 'http:'].includes(origin.protocol) || origin.username || origin.password || origin.search || origin.hash || origin.pathname !== '/')
|
|
21
|
+
throw new TypeError('Crawler origin must be an HTTP(S) origin');
|
|
22
|
+
const maxUrls = options.maxUrlsPerSitemap ?? 10000;
|
|
23
|
+
const maxBytes = options.maxXmlBytes ?? 45_000_000;
|
|
24
|
+
const ttl = options.cacheSeconds ?? 600;
|
|
25
|
+
const snapshotTtlMs = options.snapshotTtlMs ?? 0;
|
|
26
|
+
if (!Number.isSafeInteger(maxUrls) || maxUrls < 1 || maxUrls > 50000)
|
|
27
|
+
throw new RangeError('Invalid sitemap URL limit');
|
|
28
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes < 2048 || maxBytes > 52_428_800)
|
|
29
|
+
throw new RangeError('Invalid sitemap size limit');
|
|
30
|
+
if (!Number.isSafeInteger(ttl) || ttl < 0 || ttl > 31536000)
|
|
31
|
+
throw new RangeError('Invalid crawler cache lifetime');
|
|
32
|
+
if (!Number.isSafeInteger(snapshotTtlMs) || snapshotTtlMs < 0 || snapshotTtlMs > 86400000)
|
|
33
|
+
throw new RangeError('Invalid sitemap snapshot TTL');
|
|
34
|
+
const build = async () => {
|
|
35
|
+
const source = typeof options.entries === 'function' ? await options.entries() : options.entries;
|
|
36
|
+
const entries = [];
|
|
37
|
+
for (const entry of source) {
|
|
38
|
+
if (entries.length >= 500000)
|
|
39
|
+
throw new RangeError('Too many sitemap URLs');
|
|
40
|
+
entries.push(entry);
|
|
41
|
+
}
|
|
42
|
+
const pages = [];
|
|
43
|
+
const append = (group) => {
|
|
44
|
+
const xml = (0, sitemap_js_1.createSitemap)(group);
|
|
45
|
+
if (Buffer.byteLength(xml) <= maxBytes) {
|
|
46
|
+
pages.push(xml);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (group.length === 1)
|
|
50
|
+
throw new RangeError('Sitemap entry exceeds byte limit');
|
|
51
|
+
const split = Math.floor(group.length / 2);
|
|
52
|
+
append(group.slice(0, split));
|
|
53
|
+
append(group.slice(split));
|
|
54
|
+
};
|
|
55
|
+
for (let i = 0; i < entries.length; i += maxUrls)
|
|
56
|
+
append(entries.slice(i, i + maxUrls));
|
|
57
|
+
if (!pages.length)
|
|
58
|
+
pages.push((0, sitemap_js_1.createSitemap)([]));
|
|
59
|
+
const index = (0, sitemap_js_1.createSitemapIndex)(pages.map((_, i) => ({ loc: new URL(`/sitemaps/${i + 1}`, origin).href })));
|
|
60
|
+
if (Buffer.byteLength(index) > 52_428_800)
|
|
61
|
+
throw new RangeError('Sitemap index exceeds the 50 MiB maximum');
|
|
62
|
+
return { pages, index };
|
|
63
|
+
};
|
|
64
|
+
let cached;
|
|
65
|
+
let expires = 0;
|
|
66
|
+
let pending;
|
|
67
|
+
let generation = 0;
|
|
68
|
+
const read = async () => {
|
|
69
|
+
if (snapshotTtlMs && cached && Date.now() < expires)
|
|
70
|
+
return cached;
|
|
71
|
+
if (pending)
|
|
72
|
+
return pending;
|
|
73
|
+
const current = generation;
|
|
74
|
+
const task = build();
|
|
75
|
+
pending = task;
|
|
76
|
+
try {
|
|
77
|
+
const result = await task;
|
|
78
|
+
if (snapshotTtlMs && current === generation) {
|
|
79
|
+
cached = result;
|
|
80
|
+
expires = Date.now() + snapshotTtlMs;
|
|
81
|
+
}
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
if (pending === task)
|
|
86
|
+
pending = undefined;
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
const dispatch = async (request) => {
|
|
90
|
+
if (request.method !== 'GET' && request.method !== 'HEAD')
|
|
91
|
+
return new Response(null, { status: 405, headers: { allow: 'GET, HEAD' } });
|
|
92
|
+
const path = new URL(request.url).pathname;
|
|
93
|
+
if (path === '/robots.txt')
|
|
94
|
+
return respond(request, (0, robots_js_1.createRobotsTxt)(options.robots ?? { sitemap: new URL('/sitemap.xml', origin).href }), 'text/plain; charset=utf-8', ttl);
|
|
95
|
+
const snapshot = await read();
|
|
96
|
+
if (path === '/sitemap.xml')
|
|
97
|
+
return respond(request, snapshot.pages.length === 1 ? snapshot.pages[0] : snapshot.index, 'application/xml; charset=utf-8', ttl);
|
|
98
|
+
const matched = /^\/sitemaps\/([1-9][0-9]*)$/.exec(path);
|
|
99
|
+
if (!matched)
|
|
100
|
+
return new Response(null, { status: 404 });
|
|
101
|
+
const index = Number(matched[1]) - 1;
|
|
102
|
+
if (!Number.isSafeInteger(index) || index >= snapshot.pages.length)
|
|
103
|
+
return new Response(null, { status: 404 });
|
|
104
|
+
return respond(request, snapshot.pages[index], 'application/xml; charset=utf-8', ttl);
|
|
105
|
+
};
|
|
106
|
+
// Wildcard route is optional; frameworks supporting dynamic paths can use the dispatch handler.
|
|
107
|
+
return { routes: [{ path: '/robots.txt', handler: dispatch }, { path: '/sitemap.xml', handler: dispatch }, { path: '/sitemaps/:page', handler: dispatch }],
|
|
108
|
+
invalidate() { generation++; cached = undefined; expires = 0; pending = undefined; } };
|
|
109
|
+
}
|
|
110
|
+
/** Backwards-compatible route builder without exposing the cache controller. */
|
|
111
|
+
function createCrawlerRoutes(options) { return createCrawlerService(options).routes; }
|
|
112
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":";;AAwBA,oDAyDC;AAGD,kDAA8H;AApF9H,6CAAyC;AAEzC,6CAAiE;AACjE,2CAA8C;AAa9C,SAAS,OAAO,CAAC,OAAgB,EAAE,IAAY,EAAE,WAAmB,EAAE,YAAoB;IACxF,MAAM,IAAI,GAAC,IAAI,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC;IACxE,MAAM,OAAO,GAAC,EAAE,cAAc,EAAC,WAAW,EAAC,wBAAwB,EAAC,SAAS,EAAC,eAAe,EAAC,mBAAmB,YAAY,EAAE,EAAC,IAAI,EAAE,CAAC;IACvI,IAAG,OAAO,CAAC,MAAM,KAAG,KAAK,IAAE,OAAO,CAAC,MAAM,KAAG,MAAM;QAAE,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAC,EAAC,MAAM,EAAC,GAAG,EAAC,OAAO,EAAC,EAAC,KAAK,EAAC,WAAW,EAAC,EAAC,CAAC,CAAC;IACvH,IAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAA,EAAE,CAAA,CAAC,CAAC,IAAI,EAAE,KAAG,IAAI,IAAE,CAAC,CAAC,IAAI,EAAE,KAAG,GAAG,CAAC;QAAC,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAC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|
+
export declare function sitemapResponse(entries: Iterable<SitemapEntry>): {
|
|
4
|
+
status: number;
|
|
5
|
+
body: string;
|
|
6
|
+
headers: Record<string, string>;
|
|
7
|
+
};
|
|
8
|
+
export declare function robotsResponse(options?: Parameters<typeof createRobotsTxt>[0]): {
|
|
9
|
+
status: number;
|
|
10
|
+
body: string;
|
|
11
|
+
headers: Record<string, string>;
|
|
12
|
+
};
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sitemapResponse = sitemapResponse;
|
|
4
|
+
exports.robotsResponse = robotsResponse;
|
|
5
|
+
const sitemap_js_1 = require("./sitemap.js");
|
|
6
|
+
const robots_js_1 = require("./robots.js");
|
|
7
|
+
function sitemapResponse(entries) {
|
|
8
|
+
return { status: 200, body: (0, sitemap_js_1.createSitemap)(entries), headers: { 'content-type': 'application/xml; charset=utf-8', 'x-content-type-options': 'nosniff' } };
|
|
9
|
+
}
|
|
10
|
+
function robotsResponse(options) {
|
|
11
|
+
return { status: 200, body: (0, robots_js_1.createRobotsTxt)(options), headers: { 'content-type': 'text/plain; charset=utf-8', 'x-content-type-options': 'nosniff' } };
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";;AAGA,0CAEC;AACD,wCAEC;AAPD,6CAA6C;AAC7C,2CAA8C;AAC9C,SAAgB,eAAe,CAAC,OAA+B;IAC9D,OAAO,EAAC,MAAM,EAAC,GAAG,EAAC,IAAI,EAAC,IAAA,0BAAa,EAAC,OAAO,CAAC,EAAC,OAAO,EAAC,EAAC,cAAc,EAAC,gCAAgC,EAAC,wBAAwB,EAAC,SAAS,EAAC,EAAC,CAAC;AAC9I,CAAC;AACD,SAAgB,cAAc,CAAC,OAA+C;IAC7E,OAAO,EAAC,MAAM,EAAC,GAAG,EAAC,IAAI,EAAC,IAAA,2BAAe,EAAC,OAAO,CAAC,EAAC,OAAO,EAAC,EAAC,cAAc,EAAC,2BAA2B,EAAC,wBAAwB,EAAC,SAAS,EAAC,EAAC,CAAC;AAC3I,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types.js"), exports);
|
|
18
|
+
__exportStar(require("./escape.js"), exports);
|
|
19
|
+
__exportStar(require("./metadata.js"), exports);
|
|
20
|
+
__exportStar(require("./sitemap.js"), exports);
|
|
21
|
+
__exportStar(require("./robots.js"), exports);
|
|
22
|
+
__exportStar(require("./http.js"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,gDAA8B;AAC9B,+CAA6B;AAC7B,8CAA4B;AAC5B,4CAA0B"}
|
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createJsonLd = createJsonLd;
|
|
4
|
+
exports.createMetaTags = createMetaTags;
|
|
5
|
+
const escape_js_1 = require("./escape.js");
|
|
6
|
+
function createJsonLd(value) {
|
|
7
|
+
const serialized = JSON.stringify(value);
|
|
8
|
+
if (serialized === undefined)
|
|
9
|
+
throw new TypeError('JSON-LD must be JSON-serializable');
|
|
10
|
+
return `<script type="application/ld+json">${serialized.replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026').replace(/\u2028/g, '\\u2028').replace(/\u2029/g, '\\u2029')}</script>`;
|
|
11
|
+
}
|
|
12
|
+
function createMetaTags(config) {
|
|
13
|
+
if (!config.title)
|
|
14
|
+
throw new TypeError('SEO title is required');
|
|
15
|
+
const tags = [];
|
|
16
|
+
const meta = (name, content, property = false) => { if (content !== undefined && content !== '')
|
|
17
|
+
tags.push(`<meta ${property ? 'property' : 'name'}="${(0, escape_js_1.escapeHtml)(name)}" content="${(0, escape_js_1.escapeHtml)(content)}">`); };
|
|
18
|
+
tags.push(`<title>${(0, escape_js_1.escapeHtml)(config.title)}</title>`);
|
|
19
|
+
meta('description', config.description);
|
|
20
|
+
meta('robots', config.robots);
|
|
21
|
+
meta('keywords', config.keywords?.join(', '));
|
|
22
|
+
meta('og:title', config.title, true);
|
|
23
|
+
meta('og:description', config.description, true);
|
|
24
|
+
meta('og:type', config.type ?? 'website', true);
|
|
25
|
+
meta('og:site_name', config.siteName, true);
|
|
26
|
+
meta('og:locale', config.locale, true);
|
|
27
|
+
meta('twitter:title', config.title);
|
|
28
|
+
meta('twitter:description', config.description);
|
|
29
|
+
meta('twitter:site', config.twitterSite);
|
|
30
|
+
if (config.canonical) {
|
|
31
|
+
const canonical = (0, escape_js_1.safeUrl)(config.canonical);
|
|
32
|
+
tags.push(`<link rel="canonical" href="${(0, escape_js_1.escapeHtml)(canonical)}">`);
|
|
33
|
+
meta('og:url', canonical, true);
|
|
34
|
+
}
|
|
35
|
+
if (config.image) {
|
|
36
|
+
const image = (0, escape_js_1.safeUrl)(config.image);
|
|
37
|
+
meta('og:image', image, true);
|
|
38
|
+
meta('twitter:image', image);
|
|
39
|
+
meta('twitter:card', 'summary_large_image');
|
|
40
|
+
}
|
|
41
|
+
else
|
|
42
|
+
meta('twitter:card', 'summary');
|
|
43
|
+
for (const [lang, href] of Object.entries(config.alternates ?? {}))
|
|
44
|
+
tags.push(`<link rel="alternate" hreflang="${(0, escape_js_1.escapeHtml)(lang)}" href="${(0, escape_js_1.escapeHtml)((0, escape_js_1.safeUrl)(href))}">`);
|
|
45
|
+
if (config.jsonLd !== undefined)
|
|
46
|
+
for (const ld of Array.isArray(config.jsonLd) ? config.jsonLd : [config.jsonLd])
|
|
47
|
+
tags.push(createJsonLd(ld));
|
|
48
|
+
return tags.join('\n');
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata.js","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":";;AAEA,oCAGC;AACD,wCAeC;AApBD,2CAAkD;AAClD,SAAgB,YAAY,CAAC,KAAc;IACzC,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAAC,IAAI,UAAU,KAAK,SAAS;QAAE,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;IACjI,OAAO,sCAAsC,UAAU,CAAC,OAAO,CAAC,IAAI,EAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,EAAC,SAAS,CAAC,CAAC,OAAO,CAAC,IAAI,EAAC,SAAS,CAAC,CAAC,OAAO,CAAC,SAAS,EAAC,SAAS,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AAC,MAAM,CAAA,CAAC,CAAA,CAAC,MAAM,CAAC,MAAM,CAAC;YAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;IACvI,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
package/dist/robots.d.ts
ADDED
package/dist/robots.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createRobotsTxt = createRobotsTxt;
|
|
4
|
+
const escape_js_1 = require("./escape.js");
|
|
5
|
+
function positiveDelay(delay) { if (!Number.isFinite(delay) || delay < 0)
|
|
6
|
+
throw new RangeError('Invalid crawl delay'); return delay; }
|
|
7
|
+
function createRobotsTxt({ allow = ['/'], disallow = [], sitemap, groups } = {}) {
|
|
8
|
+
const validate = (s) => { if (/[\r\n\0]/.test(s))
|
|
9
|
+
throw new TypeError('Robots directives cannot contain line breaks'); return s; };
|
|
10
|
+
const all = groups ?? [{ userAgent: '*', allow, disallow }];
|
|
11
|
+
const lines = all.flatMap(group => [...([group.userAgent].flat().map(agent => `User-agent: ${validate(agent)}`)), ...(group.allow ?? []).map(path => `Allow: ${validate(path)}`), ...(group.disallow ?? []).map(path => `Disallow: ${validate(path)}`), ...(group.crawlDelay === undefined ? [] : [`Crawl-delay: ${positiveDelay(group.crawlDelay)}`]), '']);
|
|
12
|
+
for (const item of [sitemap ?? []].flat())
|
|
13
|
+
lines.push(`Sitemap: ${(0, escape_js_1.safeUrl)(item)}`);
|
|
14
|
+
return lines.join('\n').trimEnd() + '\n';
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=robots.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"robots.js","sourceRoot":"","sources":["../src/robots.ts"],"names":[],"mappings":";;AAGA,0CAMC;AARD,2CAAsC;AACtC,SAAS,aAAa,CAAC,KAAY,IAA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U,CAAC,EAAE,CAAC,CAAC,EAAC,EAAE,CAAC,CAAC,CAAC;IACrU,KAAI,MAAM,IAAI,IAAI,CAAC,OAAO,IAAE,EAAE,CAAC,CAAC,IAAI,EAAE;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,IAAA,mBAAO,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAChF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,GAAC,IAAI,CAAC;AACzC,CAAC"}
|
package/dist/sitemap.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSitemap = createSitemap;
|
|
4
|
+
exports.createSitemapIndex = createSitemapIndex;
|
|
5
|
+
const escape_js_1 = require("./escape.js");
|
|
6
|
+
function createSitemap(urls) {
|
|
7
|
+
const entries = [...urls];
|
|
8
|
+
if (entries.length > 50000)
|
|
9
|
+
throw new RangeError('A sitemap supports at most 50,000 URLs');
|
|
10
|
+
const alternates = entries.some(entry => Object.keys(entry.alternates ?? {}).length > 0);
|
|
11
|
+
const images = entries.some(entry => (entry.images?.length ?? 0) > 0);
|
|
12
|
+
const body = entries.map(entry => {
|
|
13
|
+
const tags = [`<loc>${(0, escape_js_1.escapeHtml)((0, escape_js_1.safeUrl)(entry.loc))}</loc>`];
|
|
14
|
+
if (entry.lastmod)
|
|
15
|
+
tags.push(`<lastmod>${(0, escape_js_1.iso)(entry.lastmod)}</lastmod>`);
|
|
16
|
+
if (entry.changefreq) {
|
|
17
|
+
if (!['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'].includes(entry.changefreq))
|
|
18
|
+
throw new TypeError('Invalid sitemap change frequency');
|
|
19
|
+
tags.push(`<changefreq>${entry.changefreq}</changefreq>`);
|
|
20
|
+
}
|
|
21
|
+
if (entry.priority !== undefined) {
|
|
22
|
+
if (!Number.isFinite(entry.priority) || entry.priority < 0 || entry.priority > 1)
|
|
23
|
+
throw new RangeError('Sitemap priority must be between 0 and 1');
|
|
24
|
+
tags.push(`<priority>${entry.priority.toFixed(1)}</priority>`);
|
|
25
|
+
}
|
|
26
|
+
for (const [lang, url] of Object.entries(entry.alternates ?? {}))
|
|
27
|
+
tags.push(`<xhtml:link rel="alternate" hreflang="${(0, escape_js_1.escapeHtml)(lang)}" href="${(0, escape_js_1.escapeHtml)((0, escape_js_1.safeUrl)(url))}"/>`);
|
|
28
|
+
for (const image of entry.images ?? [])
|
|
29
|
+
tags.push(`<image:image><image:loc>${(0, escape_js_1.escapeHtml)((0, escape_js_1.safeUrl)(image))}</image:loc></image:image>`);
|
|
30
|
+
return `<url>${tags.join('')}</url>`;
|
|
31
|
+
}).join('');
|
|
32
|
+
return `<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"${alternates ? ' xmlns:xhtml="http://www.w3.org/1999/xhtml"' : ''}${images ? ' xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"' : ''}>${body}</urlset>`;
|
|
33
|
+
}
|
|
34
|
+
function createSitemapIndex(sitemaps) {
|
|
35
|
+
return `<?xml version="1.0" encoding="UTF-8"?><sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">${[...sitemaps].map(s => `<sitemap><loc>${(0, escape_js_1.escapeHtml)((0, escape_js_1.safeUrl)(s.loc))}</loc>${s.lastmod ? `<lastmod>${(0, escape_js_1.iso)(s.lastmod)}</lastmod>` : ''}</sitemap>`).join('')}</sitemapindex>`;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=sitemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sitemap.js","sourceRoot":"","sources":["../src/sitemap.ts"],"names":[],"mappings":";;AAEA,sCAcC;AACD,gDAEC;AAlBD,2CAAuD;AACvD,SAAgB,aAAa,CAAC,IAA4B;IACxD,MAAM,OAAO,GAAC,CAAC,GAAG,IA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,OAAO,CAAC,YAAY,CAAA,CAAC,CAAA,EAAE,YAAY,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,iBAAiB,CAAC;AACxR,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface SeoConfig {
|
|
2
|
+
title: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
canonical?: string;
|
|
5
|
+
image?: string;
|
|
6
|
+
robots?: string;
|
|
7
|
+
locale?: string;
|
|
8
|
+
type?: string;
|
|
9
|
+
siteName?: string;
|
|
10
|
+
keywords?: string[];
|
|
11
|
+
twitterSite?: string;
|
|
12
|
+
alternates?: Record<string, string>;
|
|
13
|
+
jsonLd?: unknown | unknown[];
|
|
14
|
+
}
|
|
15
|
+
export interface SitemapEntry {
|
|
16
|
+
loc: string;
|
|
17
|
+
lastmod?: string | Date;
|
|
18
|
+
changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
19
|
+
priority?: number;
|
|
20
|
+
alternates?: Record<string, string>;
|
|
21
|
+
images?: string[];
|
|
22
|
+
}
|
|
23
|
+
export interface RobotsGroup {
|
|
24
|
+
userAgent: string | string[];
|
|
25
|
+
allow?: string[];
|
|
26
|
+
disallow?: string[];
|
|
27
|
+
crawlDelay?: number;
|
|
28
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,42 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeruxjs/seo",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "SEO Helper",
|
|
5
|
+
"homepage": "https://github.com/zeruxjs/zeruxjs#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/zeruxjs/zeruxjs/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/zeruxjs/zeruxjs.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "(MIT OR Apache-2.0)",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"dev": "tsc --watch",
|
|
19
|
+
"test": "npm run build && node --test test/*.test.mjs",
|
|
20
|
+
"prepack": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"SEO Helper"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./dist/index.js",
|
|
27
|
+
"./fetch": "./dist/fetch.js"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"dist/",
|
|
31
|
+
"README.md",
|
|
32
|
+
"LICENSE-MIT",
|
|
33
|
+
"LICENSE-APACHE"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"typescript": "^5.9.3",
|
|
40
|
+
"@types/node": "^25.4.0"
|
|
41
|
+
}
|
|
42
|
+
}
|