aeo.js 0.0.6 → 0.0.8
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/dist/angular.d.mts +1 -1
- package/dist/angular.d.ts +1 -1
- package/dist/angular.js +65 -11
- package/dist/angular.js.map +1 -1
- package/dist/angular.mjs +65 -11
- package/dist/angular.mjs.map +1 -1
- package/dist/astro.d.mts +1 -1
- package/dist/astro.d.ts +1 -1
- package/dist/astro.js +74 -16
- package/dist/astro.js.map +1 -1
- package/dist/astro.mjs +74 -16
- package/dist/astro.mjs.map +1 -1
- package/dist/cli.js +80 -25
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +80 -25
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +85 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +85 -27
- package/dist/index.mjs.map +1 -1
- package/dist/next.d.mts +1 -1
- package/dist/next.d.ts +1 -1
- package/dist/next.js +65 -11
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +65 -11
- package/dist/next.mjs.map +1 -1
- package/dist/nuxt.d.mts +1 -1
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +65 -11
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +65 -11
- package/dist/nuxt.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +61 -9
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +61 -9
- package/dist/react.mjs.map +1 -1
- package/dist/{types-Cn_Qbkmg.d.mts → types-BlLNcw-X.d.mts} +2 -0
- package/dist/{types-Cn_Qbkmg.d.ts → types-BlLNcw-X.d.ts} +2 -0
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +90 -18
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +90 -18
- package/dist/vite.mjs.map +1 -1
- package/dist/vue.d.mts +1 -1
- package/dist/vue.d.ts +1 -1
- package/dist/vue.js +61 -9
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +61 -9
- package/dist/vue.mjs.map +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +65 -11
- package/dist/webpack.js.map +1 -1
- package/dist/webpack.mjs +65 -11
- package/dist/webpack.mjs.map +1 -1
- package/dist/widget.d.mts +1 -1
- package/dist/widget.d.ts +1 -1
- package/dist/widget.js +61 -9
- package/dist/widget.js.map +1 -1
- package/dist/widget.mjs +61 -9
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/astro.mjs
CHANGED
|
@@ -77,10 +77,19 @@ function generateRobotsTxt(config) {
|
|
|
77
77
|
}
|
|
78
78
|
lines.push("# Default for all other bots");
|
|
79
79
|
lines.push("User-agent: *");
|
|
80
|
-
|
|
80
|
+
for (const path of config.robots.allow.length > 0 ? config.robots.allow : ["/"]) {
|
|
81
|
+
lines.push(`Allow: ${path}`);
|
|
82
|
+
}
|
|
83
|
+
for (const path of config.robots.disallow) {
|
|
84
|
+
lines.push(`Disallow: ${path}`);
|
|
85
|
+
}
|
|
86
|
+
if (config.robots.crawlDelay > 0) {
|
|
87
|
+
lines.push(`Crawl-delay: ${config.robots.crawlDelay}`);
|
|
88
|
+
}
|
|
81
89
|
lines.push("");
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
const sitemapUrl = config.robots.sitemap || (config.url ? `${config.url}/sitemap.xml` : "");
|
|
91
|
+
if (sitemapUrl) {
|
|
92
|
+
lines.push(`Sitemap: ${sitemapUrl}`);
|
|
84
93
|
}
|
|
85
94
|
lines.push("");
|
|
86
95
|
lines.push("# AEO (Answer Engine Optimization) files");
|
|
@@ -162,7 +171,7 @@ function detectFramework(projectRoot = process.cwd()) {
|
|
|
162
171
|
};
|
|
163
172
|
}
|
|
164
173
|
function resolveConfig(config = {}) {
|
|
165
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M;
|
|
174
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N;
|
|
166
175
|
const frameworkInfo = detectFramework();
|
|
167
176
|
return {
|
|
168
177
|
title: config.title || "My Site",
|
|
@@ -206,15 +215,16 @@ function resolveConfig(config = {}) {
|
|
|
206
215
|
widget: {
|
|
207
216
|
enabled: ((_A = config.widget) == null ? void 0 : _A.enabled) !== false,
|
|
208
217
|
position: ((_B = config.widget) == null ? void 0 : _B.position) || "bottom-right",
|
|
218
|
+
size: ((_C = config.widget) == null ? void 0 : _C.size) || "default",
|
|
209
219
|
theme: {
|
|
210
|
-
background: ((
|
|
211
|
-
text: ((
|
|
212
|
-
accent: ((
|
|
213
|
-
badge: ((
|
|
220
|
+
background: ((_E = (_D = config.widget) == null ? void 0 : _D.theme) == null ? void 0 : _E.background) || "rgba(18, 18, 24, 0.9)",
|
|
221
|
+
text: ((_G = (_F = config.widget) == null ? void 0 : _F.theme) == null ? void 0 : _G.text) || "#C0C0C5",
|
|
222
|
+
accent: ((_I = (_H = config.widget) == null ? void 0 : _H.theme) == null ? void 0 : _I.accent) || "#E8E8EA",
|
|
223
|
+
badge: ((_K = (_J = config.widget) == null ? void 0 : _J.theme) == null ? void 0 : _K.badge) || "#4ADE80"
|
|
214
224
|
},
|
|
215
|
-
humanLabel: ((
|
|
216
|
-
aiLabel: ((
|
|
217
|
-
showBadge: ((
|
|
225
|
+
humanLabel: ((_L = config.widget) == null ? void 0 : _L.humanLabel) || "Human",
|
|
226
|
+
aiLabel: ((_M = config.widget) == null ? void 0 : _M.aiLabel) || "AI",
|
|
227
|
+
showBadge: ((_N = config.widget) == null ? void 0 : _N.showBadge) !== false
|
|
218
228
|
}
|
|
219
229
|
};
|
|
220
230
|
}
|
|
@@ -842,6 +852,22 @@ function generatePageSchemas(page, config) {
|
|
|
842
852
|
}))
|
|
843
853
|
});
|
|
844
854
|
}
|
|
855
|
+
if (faqItems.length === 0) {
|
|
856
|
+
const howToSteps = detectHowToSteps(page.content || "");
|
|
857
|
+
if (howToSteps.length > 0) {
|
|
858
|
+
schemas.push({
|
|
859
|
+
"@context": "https://schema.org",
|
|
860
|
+
"@type": "HowTo",
|
|
861
|
+
name: page.title || config.title,
|
|
862
|
+
step: howToSteps.map((s, i) => ({
|
|
863
|
+
"@type": "HowToStep",
|
|
864
|
+
position: i + 1,
|
|
865
|
+
name: s.name,
|
|
866
|
+
text: s.text
|
|
867
|
+
}))
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
}
|
|
845
871
|
const pageType = config.schema.defaultType;
|
|
846
872
|
const pageSchema = {
|
|
847
873
|
"@context": "https://schema.org",
|
|
@@ -918,12 +944,43 @@ function detectFaqPatterns(content) {
|
|
|
918
944
|
}
|
|
919
945
|
return items;
|
|
920
946
|
}
|
|
947
|
+
function serializeJsonForHtml(value) {
|
|
948
|
+
return JSON.stringify(value).replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
949
|
+
}
|
|
950
|
+
function detectHowToSteps(content) {
|
|
951
|
+
const steps = [];
|
|
952
|
+
const lines = content.split("\n");
|
|
953
|
+
for (let i = 0; i < lines.length; i++) {
|
|
954
|
+
const line = lines[i].trim();
|
|
955
|
+
const stepMatch = line.match(/^#{1,6}\s+(?:Step\s+\d+[\s:.-]*|(\d+)[.)]\s*)(.+)$/i);
|
|
956
|
+
if (stepMatch) {
|
|
957
|
+
const name = (stepMatch[2] || stepMatch[1] || "").trim();
|
|
958
|
+
const bodyLines = [];
|
|
959
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
960
|
+
const nextLine = lines[j].trim();
|
|
961
|
+
if (!nextLine) {
|
|
962
|
+
if (bodyLines.length > 0) break;
|
|
963
|
+
continue;
|
|
964
|
+
}
|
|
965
|
+
if (/^#{1,6}\s/.test(nextLine)) break;
|
|
966
|
+
bodyLines.push(nextLine);
|
|
967
|
+
}
|
|
968
|
+
if (name) {
|
|
969
|
+
steps.push({
|
|
970
|
+
name,
|
|
971
|
+
text: bodyLines.join(" ").slice(0, 500)
|
|
972
|
+
});
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
return steps.length >= 2 ? steps : [];
|
|
977
|
+
}
|
|
921
978
|
function generateJsonLdScript(schemas) {
|
|
922
979
|
if (schemas.length === 0) return "";
|
|
923
980
|
if (schemas.length === 1) {
|
|
924
|
-
return `<script type="application/ld+json">${
|
|
981
|
+
return `<script type="application/ld+json">${serializeJsonForHtml(schemas[0])}</script>`;
|
|
925
982
|
}
|
|
926
|
-
return schemas.map((s) => `<script type="application/ld+json">${
|
|
983
|
+
return schemas.map((s) => `<script type="application/ld+json">${serializeJsonForHtml(s)}</script>`).join("\n");
|
|
927
984
|
}
|
|
928
985
|
async function generateAEOFiles(configOrRoot, maybeConfig) {
|
|
929
986
|
var _a;
|
|
@@ -1369,7 +1426,7 @@ if (!document.querySelector('meta[name="astro-view-transitions-enabled"]')) {
|
|
|
1369
1426
|
devLogger.error(`Failed to generate AEO files: ${error}`);
|
|
1370
1427
|
}
|
|
1371
1428
|
const mdHandler = async (req, res, next) => {
|
|
1372
|
-
var _a
|
|
1429
|
+
var _a;
|
|
1373
1430
|
if (!((_a = req.url) == null ? void 0 : _a.endsWith(".md"))) return next();
|
|
1374
1431
|
if (req.headers["x-aeo-internal"]) return next();
|
|
1375
1432
|
const filename = req.url.startsWith("/") ? req.url.slice(1) : req.url;
|
|
@@ -1384,8 +1441,9 @@ if (!document.querySelector('meta[name="astro-view-transitions-enabled"]')) {
|
|
|
1384
1441
|
let pagePath = req.url.replace(/\.md$/, "") || "/";
|
|
1385
1442
|
if (pagePath === "/index") pagePath = "/";
|
|
1386
1443
|
try {
|
|
1387
|
-
const
|
|
1388
|
-
const
|
|
1444
|
+
const rawHost = req.headers.host || "localhost:4321";
|
|
1445
|
+
const host = /^(localhost|127\.0\.0\.1)(:\d+)?$/.test(rawHost) ? rawHost : "localhost:4321";
|
|
1446
|
+
const protocol = "http";
|
|
1389
1447
|
const response = await fetch(`${protocol}://${host}${pagePath}`, {
|
|
1390
1448
|
headers: { "x-aeo-internal": "1" }
|
|
1391
1449
|
});
|