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.js
CHANGED
|
@@ -81,10 +81,19 @@ function generateRobotsTxt(config) {
|
|
|
81
81
|
}
|
|
82
82
|
lines.push("# Default for all other bots");
|
|
83
83
|
lines.push("User-agent: *");
|
|
84
|
-
|
|
84
|
+
for (const path of config.robots.allow.length > 0 ? config.robots.allow : ["/"]) {
|
|
85
|
+
lines.push(`Allow: ${path}`);
|
|
86
|
+
}
|
|
87
|
+
for (const path of config.robots.disallow) {
|
|
88
|
+
lines.push(`Disallow: ${path}`);
|
|
89
|
+
}
|
|
90
|
+
if (config.robots.crawlDelay > 0) {
|
|
91
|
+
lines.push(`Crawl-delay: ${config.robots.crawlDelay}`);
|
|
92
|
+
}
|
|
85
93
|
lines.push("");
|
|
86
|
-
|
|
87
|
-
|
|
94
|
+
const sitemapUrl = config.robots.sitemap || (config.url ? `${config.url}/sitemap.xml` : "");
|
|
95
|
+
if (sitemapUrl) {
|
|
96
|
+
lines.push(`Sitemap: ${sitemapUrl}`);
|
|
88
97
|
}
|
|
89
98
|
lines.push("");
|
|
90
99
|
lines.push("# AEO (Answer Engine Optimization) files");
|
|
@@ -166,7 +175,7 @@ function detectFramework(projectRoot = process.cwd()) {
|
|
|
166
175
|
};
|
|
167
176
|
}
|
|
168
177
|
function resolveConfig(config = {}) {
|
|
169
|
-
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;
|
|
178
|
+
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;
|
|
170
179
|
const frameworkInfo = detectFramework();
|
|
171
180
|
return {
|
|
172
181
|
title: config.title || "My Site",
|
|
@@ -210,15 +219,16 @@ function resolveConfig(config = {}) {
|
|
|
210
219
|
widget: {
|
|
211
220
|
enabled: ((_A = config.widget) == null ? void 0 : _A.enabled) !== false,
|
|
212
221
|
position: ((_B = config.widget) == null ? void 0 : _B.position) || "bottom-right",
|
|
222
|
+
size: ((_C = config.widget) == null ? void 0 : _C.size) || "default",
|
|
213
223
|
theme: {
|
|
214
|
-
background: ((
|
|
215
|
-
text: ((
|
|
216
|
-
accent: ((
|
|
217
|
-
badge: ((
|
|
224
|
+
background: ((_E = (_D = config.widget) == null ? void 0 : _D.theme) == null ? void 0 : _E.background) || "rgba(18, 18, 24, 0.9)",
|
|
225
|
+
text: ((_G = (_F = config.widget) == null ? void 0 : _F.theme) == null ? void 0 : _G.text) || "#C0C0C5",
|
|
226
|
+
accent: ((_I = (_H = config.widget) == null ? void 0 : _H.theme) == null ? void 0 : _I.accent) || "#E8E8EA",
|
|
227
|
+
badge: ((_K = (_J = config.widget) == null ? void 0 : _J.theme) == null ? void 0 : _K.badge) || "#4ADE80"
|
|
218
228
|
},
|
|
219
|
-
humanLabel: ((
|
|
220
|
-
aiLabel: ((
|
|
221
|
-
showBadge: ((
|
|
229
|
+
humanLabel: ((_L = config.widget) == null ? void 0 : _L.humanLabel) || "Human",
|
|
230
|
+
aiLabel: ((_M = config.widget) == null ? void 0 : _M.aiLabel) || "AI",
|
|
231
|
+
showBadge: ((_N = config.widget) == null ? void 0 : _N.showBadge) !== false
|
|
222
232
|
}
|
|
223
233
|
};
|
|
224
234
|
}
|
|
@@ -846,6 +856,22 @@ function generatePageSchemas(page, config) {
|
|
|
846
856
|
}))
|
|
847
857
|
});
|
|
848
858
|
}
|
|
859
|
+
if (faqItems.length === 0) {
|
|
860
|
+
const howToSteps = detectHowToSteps(page.content || "");
|
|
861
|
+
if (howToSteps.length > 0) {
|
|
862
|
+
schemas.push({
|
|
863
|
+
"@context": "https://schema.org",
|
|
864
|
+
"@type": "HowTo",
|
|
865
|
+
name: page.title || config.title,
|
|
866
|
+
step: howToSteps.map((s, i) => ({
|
|
867
|
+
"@type": "HowToStep",
|
|
868
|
+
position: i + 1,
|
|
869
|
+
name: s.name,
|
|
870
|
+
text: s.text
|
|
871
|
+
}))
|
|
872
|
+
});
|
|
873
|
+
}
|
|
874
|
+
}
|
|
849
875
|
const pageType = config.schema.defaultType;
|
|
850
876
|
const pageSchema = {
|
|
851
877
|
"@context": "https://schema.org",
|
|
@@ -922,12 +948,43 @@ function detectFaqPatterns(content) {
|
|
|
922
948
|
}
|
|
923
949
|
return items;
|
|
924
950
|
}
|
|
951
|
+
function serializeJsonForHtml(value) {
|
|
952
|
+
return JSON.stringify(value).replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/&/g, "\\u0026").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
953
|
+
}
|
|
954
|
+
function detectHowToSteps(content) {
|
|
955
|
+
const steps = [];
|
|
956
|
+
const lines = content.split("\n");
|
|
957
|
+
for (let i = 0; i < lines.length; i++) {
|
|
958
|
+
const line = lines[i].trim();
|
|
959
|
+
const stepMatch = line.match(/^#{1,6}\s+(?:Step\s+\d+[\s:.-]*|(\d+)[.)]\s*)(.+)$/i);
|
|
960
|
+
if (stepMatch) {
|
|
961
|
+
const name = (stepMatch[2] || stepMatch[1] || "").trim();
|
|
962
|
+
const bodyLines = [];
|
|
963
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
964
|
+
const nextLine = lines[j].trim();
|
|
965
|
+
if (!nextLine) {
|
|
966
|
+
if (bodyLines.length > 0) break;
|
|
967
|
+
continue;
|
|
968
|
+
}
|
|
969
|
+
if (/^#{1,6}\s/.test(nextLine)) break;
|
|
970
|
+
bodyLines.push(nextLine);
|
|
971
|
+
}
|
|
972
|
+
if (name) {
|
|
973
|
+
steps.push({
|
|
974
|
+
name,
|
|
975
|
+
text: bodyLines.join(" ").slice(0, 500)
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
return steps.length >= 2 ? steps : [];
|
|
981
|
+
}
|
|
925
982
|
function generateJsonLdScript(schemas) {
|
|
926
983
|
if (schemas.length === 0) return "";
|
|
927
984
|
if (schemas.length === 1) {
|
|
928
|
-
return `<script type="application/ld+json">${
|
|
985
|
+
return `<script type="application/ld+json">${serializeJsonForHtml(schemas[0])}</script>`;
|
|
929
986
|
}
|
|
930
|
-
return schemas.map((s) => `<script type="application/ld+json">${
|
|
987
|
+
return schemas.map((s) => `<script type="application/ld+json">${serializeJsonForHtml(s)}</script>`).join("\n");
|
|
931
988
|
}
|
|
932
989
|
async function generateAEOFiles(configOrRoot, maybeConfig) {
|
|
933
990
|
var _a;
|
|
@@ -1373,7 +1430,7 @@ if (!document.querySelector('meta[name="astro-view-transitions-enabled"]')) {
|
|
|
1373
1430
|
devLogger.error(`Failed to generate AEO files: ${error}`);
|
|
1374
1431
|
}
|
|
1375
1432
|
const mdHandler = async (req, res, next) => {
|
|
1376
|
-
var _a
|
|
1433
|
+
var _a;
|
|
1377
1434
|
if (!((_a = req.url) == null ? void 0 : _a.endsWith(".md"))) return next();
|
|
1378
1435
|
if (req.headers["x-aeo-internal"]) return next();
|
|
1379
1436
|
const filename = req.url.startsWith("/") ? req.url.slice(1) : req.url;
|
|
@@ -1388,8 +1445,9 @@ if (!document.querySelector('meta[name="astro-view-transitions-enabled"]')) {
|
|
|
1388
1445
|
let pagePath = req.url.replace(/\.md$/, "") || "/";
|
|
1389
1446
|
if (pagePath === "/index") pagePath = "/";
|
|
1390
1447
|
try {
|
|
1391
|
-
const
|
|
1392
|
-
const
|
|
1448
|
+
const rawHost = req.headers.host || "localhost:4321";
|
|
1449
|
+
const host = /^(localhost|127\.0\.0\.1)(:\d+)?$/.test(rawHost) ? rawHost : "localhost:4321";
|
|
1450
|
+
const protocol = "http";
|
|
1393
1451
|
const response = await fetch(`${protocol}://${host}${pagePath}`, {
|
|
1394
1452
|
headers: { "x-aeo-internal": "1" }
|
|
1395
1453
|
});
|