@svelte-vitals/vite 0.4.0 → 0.6.0
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.
|
@@ -13,18 +13,30 @@ function parseHtmlHead(html) {
|
|
|
13
13
|
const name = meta.getAttribute("name");
|
|
14
14
|
const property = meta.getAttribute("property");
|
|
15
15
|
if (!name && !property) continue;
|
|
16
|
+
const content = name === "robots" ? meta.getAttribute("content") : null;
|
|
17
|
+
const noindex = content != null && /(^|[\s,])(noindex|none)([\s,]|$)/i.test(content);
|
|
16
18
|
tags.push({
|
|
17
19
|
kind: "meta",
|
|
18
20
|
...name ? { name } : {},
|
|
19
21
|
...property ? { property } : {},
|
|
20
22
|
presence: "own",
|
|
21
|
-
value: attrValue(meta.getAttribute("content"))
|
|
23
|
+
value: attrValue(meta.getAttribute("content")),
|
|
24
|
+
...noindex ? { noindex: true } : {}
|
|
22
25
|
});
|
|
23
26
|
}
|
|
24
27
|
for (const link of head.querySelectorAll("link")) {
|
|
25
28
|
const rel = link.getAttribute("rel");
|
|
26
29
|
if (!rel) continue;
|
|
27
|
-
|
|
30
|
+
const asAttr = link.getAttribute("as");
|
|
31
|
+
const hasCrossorigin = link.hasAttribute("crossorigin");
|
|
32
|
+
tags.push({
|
|
33
|
+
kind: "link",
|
|
34
|
+
rel,
|
|
35
|
+
presence: "own",
|
|
36
|
+
value: attrValue(link.getAttribute("href")),
|
|
37
|
+
...asAttr != null ? { hasAs: true, as: asAttr } : {},
|
|
38
|
+
...hasCrossorigin ? { hasCrossorigin: true } : {}
|
|
39
|
+
});
|
|
28
40
|
}
|
|
29
41
|
for (const script of head.querySelectorAll("script")) {
|
|
30
42
|
if (script.getAttribute("type") === "application/ld+json") {
|
package/dist/hooks/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseHtmlHead
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GISWUGBL.js";
|
|
4
4
|
|
|
5
5
|
// src/plugin.ts
|
|
6
6
|
import { existsSync } from "fs";
|
|
@@ -52,7 +52,7 @@ async function collectRenderedHeads(prerenderPagesDir) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// src/providers/rendered/project.ts
|
|
55
|
-
import { access } from "fs/promises";
|
|
55
|
+
import { access, readFile as readFile2 } from "fs/promises";
|
|
56
56
|
import { join as join2 } from "path";
|
|
57
57
|
import { ROBOTS_SOURCE_PATHS, SITEMAP_SOURCE_PATHS } from "@svelte-vitals/core";
|
|
58
58
|
async function exists(path) {
|
|
@@ -67,12 +67,25 @@ async function existsAny(cwd, paths) {
|
|
|
67
67
|
const found = await Promise.all(paths.map((p) => exists(join2(cwd, p))));
|
|
68
68
|
return found.some(Boolean);
|
|
69
69
|
}
|
|
70
|
+
async function robotsRefsSitemap(cwd) {
|
|
71
|
+
try {
|
|
72
|
+
return /^\s*sitemap:/im.test(await readFile2(join2(cwd, "static/robots.txt"), "utf8"));
|
|
73
|
+
} catch {
|
|
74
|
+
return void 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
70
77
|
async function collectRenderedProject(cwd, htmlLang) {
|
|
71
78
|
const [hasRobotsTxt, hasSitemap] = await Promise.all([
|
|
72
79
|
existsAny(cwd, ROBOTS_SOURCE_PATHS),
|
|
73
80
|
existsAny(cwd, SITEMAP_SOURCE_PATHS)
|
|
74
81
|
]);
|
|
75
|
-
|
|
82
|
+
const robotsReferencesSitemap = await robotsRefsSitemap(cwd);
|
|
83
|
+
return {
|
|
84
|
+
hasRobotsTxt,
|
|
85
|
+
hasSitemap,
|
|
86
|
+
htmlLang,
|
|
87
|
+
...robotsReferencesSitemap !== void 0 ? { robotsReferencesSitemap } : {}
|
|
88
|
+
};
|
|
76
89
|
}
|
|
77
90
|
|
|
78
91
|
// src/version.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@svelte-vitals/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Vite/SvelteKit plugin for svelte-vitals — analyzes prerendered HTML during vite build.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"esm-env": "^1.2.2",
|
|
43
43
|
"node-html-parser": "^6.1.13",
|
|
44
44
|
"tinyglobby": "^0.2.17",
|
|
45
|
-
"@svelte-vitals/core": "0.
|
|
45
|
+
"@svelte-vitals/core": "0.13.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"@sveltejs/kit": "^2.0.0",
|