aeo.js 0.0.7 → 0.0.9
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/README.md +119 -164
- package/dist/angular.d.mts +1 -1
- package/dist/angular.d.ts +1 -1
- package/dist/angular.js +69 -13
- package/dist/angular.js.map +1 -1
- package/dist/angular.mjs +69 -13
- 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 +78 -18
- package/dist/astro.js.map +1 -1
- package/dist/astro.mjs +78 -18
- package/dist/astro.mjs.map +1 -1
- package/dist/cli.js +84 -27
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +84 -27
- 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 +89 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +89 -29
- 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 +71 -15
- package/dist/next.js.map +1 -1
- package/dist/next.mjs +71 -15
- 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 +69 -13
- package/dist/nuxt.js.map +1 -1
- package/dist/nuxt.mjs +69 -13
- 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 +52 -7
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +52 -7
- 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 +94 -20
- package/dist/vite.js.map +1 -1
- package/dist/vite.mjs +94 -20
- 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 +52 -7
- package/dist/vue.js.map +1 -1
- package/dist/vue.mjs +52 -7
- 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 +69 -13
- package/dist/webpack.js.map +1 -1
- package/dist/webpack.mjs +69 -13
- 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 +52 -7
- package/dist/widget.js.map +1 -1
- package/dist/widget.mjs +52 -7
- package/dist/widget.mjs.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -80,10 +80,19 @@ function generateRobotsTxt(config) {
|
|
|
80
80
|
}
|
|
81
81
|
lines.push("# Default for all other bots");
|
|
82
82
|
lines.push("User-agent: *");
|
|
83
|
-
|
|
83
|
+
for (const path of config.robots.allow.length > 0 ? config.robots.allow : ["/"]) {
|
|
84
|
+
lines.push(`Allow: ${path}`);
|
|
85
|
+
}
|
|
86
|
+
for (const path of config.robots.disallow) {
|
|
87
|
+
lines.push(`Disallow: ${path}`);
|
|
88
|
+
}
|
|
89
|
+
if (config.robots.crawlDelay > 0) {
|
|
90
|
+
lines.push(`Crawl-delay: ${config.robots.crawlDelay}`);
|
|
91
|
+
}
|
|
84
92
|
lines.push("");
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
const sitemapUrl = config.robots.sitemap || (config.url ? `${config.url}/sitemap.xml` : "");
|
|
94
|
+
if (sitemapUrl) {
|
|
95
|
+
lines.push(`Sitemap: ${sitemapUrl}`);
|
|
87
96
|
}
|
|
88
97
|
lines.push("");
|
|
89
98
|
lines.push("# AEO (Answer Engine Optimization) files");
|
|
@@ -165,7 +174,7 @@ function detectFramework(projectRoot = process.cwd()) {
|
|
|
165
174
|
};
|
|
166
175
|
}
|
|
167
176
|
function resolveConfig(config = {}) {
|
|
168
|
-
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;
|
|
177
|
+
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;
|
|
169
178
|
const frameworkInfo = detectFramework();
|
|
170
179
|
return {
|
|
171
180
|
title: config.title || "My Site",
|
|
@@ -209,15 +218,16 @@ function resolveConfig(config = {}) {
|
|
|
209
218
|
widget: {
|
|
210
219
|
enabled: ((_A = config.widget) == null ? void 0 : _A.enabled) !== false,
|
|
211
220
|
position: ((_B = config.widget) == null ? void 0 : _B.position) || "bottom-right",
|
|
221
|
+
size: ((_C = config.widget) == null ? void 0 : _C.size) || "default",
|
|
212
222
|
theme: {
|
|
213
|
-
background: ((
|
|
214
|
-
text: ((
|
|
215
|
-
accent: ((
|
|
216
|
-
badge: ((
|
|
223
|
+
background: ((_E = (_D = config.widget) == null ? void 0 : _D.theme) == null ? void 0 : _E.background) || "rgba(18, 18, 24, 0.9)",
|
|
224
|
+
text: ((_G = (_F = config.widget) == null ? void 0 : _F.theme) == null ? void 0 : _G.text) || "#C0C0C5",
|
|
225
|
+
accent: ((_I = (_H = config.widget) == null ? void 0 : _H.theme) == null ? void 0 : _I.accent) || "#E8E8EA",
|
|
226
|
+
badge: ((_K = (_J = config.widget) == null ? void 0 : _J.theme) == null ? void 0 : _K.badge) || "#4ADE80"
|
|
217
227
|
},
|
|
218
|
-
humanLabel: ((
|
|
219
|
-
aiLabel: ((
|
|
220
|
-
showBadge: ((
|
|
228
|
+
humanLabel: ((_L = config.widget) == null ? void 0 : _L.humanLabel) || "Human",
|
|
229
|
+
aiLabel: ((_M = config.widget) == null ? void 0 : _M.aiLabel) || "AI",
|
|
230
|
+
showBadge: ((_N = config.widget) == null ? void 0 : _N.showBadge) !== false
|
|
221
231
|
}
|
|
222
232
|
};
|
|
223
233
|
}
|
|
@@ -274,7 +284,8 @@ function collectMarkdownFiles(dir, base = dir) {
|
|
|
274
284
|
for (const entry of entries) {
|
|
275
285
|
const fullPath = path.join(dir, entry);
|
|
276
286
|
const stat = fs.statSync(fullPath);
|
|
277
|
-
|
|
287
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "public", "dist", ".next", ".nuxt", ".output", ".open-next", "coverage", "__tests__", "__mocks__"]);
|
|
288
|
+
if (stat.isDirectory() && !entry.startsWith(".") && !SKIP_DIRS.has(entry)) {
|
|
278
289
|
files.push(...collectMarkdownFiles(fullPath, base));
|
|
279
290
|
} else if (stat.isFile() && (path.extname(entry) === ".md" || path.extname(entry) === ".mdx")) {
|
|
280
291
|
const content = fs.readFileSync(fullPath, "utf-8");
|
|
@@ -617,7 +628,8 @@ function collectUrls(dir, config, base = dir) {
|
|
|
617
628
|
for (const entry of entries) {
|
|
618
629
|
const fullPath = path.join(dir, entry);
|
|
619
630
|
const stat = fs.statSync(fullPath);
|
|
620
|
-
|
|
631
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "public", "dist", ".next", ".nuxt", ".output", ".open-next", "coverage", "__tests__", "__mocks__"]);
|
|
632
|
+
if (stat.isDirectory() && !entry.startsWith(".") && !SKIP_DIRS.has(entry)) {
|
|
621
633
|
urls.push(...collectUrls(fullPath, config, base));
|
|
622
634
|
} else if (stat.isFile() && (path.extname(entry) === ".md" || path.extname(entry) === ".mdx" || path.extname(entry) === ".html")) {
|
|
623
635
|
const relativePath = path.relative(base, fullPath);
|
|
@@ -845,6 +857,22 @@ function generatePageSchemas(page, config) {
|
|
|
845
857
|
}))
|
|
846
858
|
});
|
|
847
859
|
}
|
|
860
|
+
if (faqItems.length === 0) {
|
|
861
|
+
const howToSteps = detectHowToSteps(page.content || "");
|
|
862
|
+
if (howToSteps.length > 0) {
|
|
863
|
+
schemas.push({
|
|
864
|
+
"@context": "https://schema.org",
|
|
865
|
+
"@type": "HowTo",
|
|
866
|
+
name: page.title || config.title,
|
|
867
|
+
step: howToSteps.map((s, i) => ({
|
|
868
|
+
"@type": "HowToStep",
|
|
869
|
+
position: i + 1,
|
|
870
|
+
name: s.name,
|
|
871
|
+
text: s.text
|
|
872
|
+
}))
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
}
|
|
848
876
|
const pageType = config.schema.defaultType;
|
|
849
877
|
const pageSchema = {
|
|
850
878
|
"@context": "https://schema.org",
|
|
@@ -921,6 +949,34 @@ function detectFaqPatterns(content) {
|
|
|
921
949
|
}
|
|
922
950
|
return items;
|
|
923
951
|
}
|
|
952
|
+
function detectHowToSteps(content) {
|
|
953
|
+
const steps = [];
|
|
954
|
+
const lines = content.split("\n");
|
|
955
|
+
for (let i = 0; i < lines.length; i++) {
|
|
956
|
+
const line = lines[i].trim();
|
|
957
|
+
const stepMatch = line.match(/^#{1,6}\s+(?:Step\s+\d+[\s:.-]*|(\d+)[.)]\s*)(.+)$/i);
|
|
958
|
+
if (stepMatch) {
|
|
959
|
+
const name = (stepMatch[2] || stepMatch[1] || "").trim();
|
|
960
|
+
const bodyLines = [];
|
|
961
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
962
|
+
const nextLine = lines[j].trim();
|
|
963
|
+
if (!nextLine) {
|
|
964
|
+
if (bodyLines.length > 0) break;
|
|
965
|
+
continue;
|
|
966
|
+
}
|
|
967
|
+
if (/^#{1,6}\s/.test(nextLine)) break;
|
|
968
|
+
bodyLines.push(nextLine);
|
|
969
|
+
}
|
|
970
|
+
if (name) {
|
|
971
|
+
steps.push({
|
|
972
|
+
name,
|
|
973
|
+
text: bodyLines.join(" ").slice(0, 500)
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
return steps.length >= 2 ? steps : [];
|
|
979
|
+
}
|
|
924
980
|
async function generateAEOFiles(configOrRoot, maybeConfig) {
|
|
925
981
|
var _a;
|
|
926
982
|
let config;
|
|
@@ -1130,15 +1186,18 @@ function auditSchemaPresence(config, issues, suggestions) {
|
|
|
1130
1186
|
if (!hasLogo) {
|
|
1131
1187
|
suggestions.push("Add schema.organization.logo for richer search results and AI knowledge");
|
|
1132
1188
|
}
|
|
1133
|
-
const
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1189
|
+
const hasFaqOrHowTo = config.pages.some((p) => {
|
|
1190
|
+
const content = p.content || "";
|
|
1191
|
+
return /^#{1,6}\s+.+\?\s*$/m.test(content) || /^#{1,6}\s+(?:Step\s+\d+[\s:.-]|How\s+to)/im.test(content);
|
|
1192
|
+
});
|
|
1193
|
+
checks.push({ label: "FAQPage or HowTo schema", passed: hasFaqOrHowTo, points: hasFaqOrHowTo ? 4 : 0 });
|
|
1194
|
+
if (!hasFaqOrHowTo) {
|
|
1195
|
+
suggestions.push("Add FAQ sections (question headings) or step-by-step content to auto-generate FAQPage/HowTo schema");
|
|
1137
1196
|
}
|
|
1138
|
-
const
|
|
1139
|
-
checks.push({ label: "
|
|
1140
|
-
if (!
|
|
1141
|
-
|
|
1197
|
+
const hasArticleOrWebPage = schemaEnabled && (config.schema.defaultType === "Article" || config.schema.defaultType === "WebPage");
|
|
1198
|
+
checks.push({ label: "Article/WebPage schema", passed: hasArticleOrWebPage, points: hasArticleOrWebPage ? 4 : 0 });
|
|
1199
|
+
if (!hasArticleOrWebPage && schemaEnabled) {
|
|
1200
|
+
suggestions.push('Set schema.defaultType to "Article" or "WebPage" for per-page structured data');
|
|
1142
1201
|
}
|
|
1143
1202
|
return {
|
|
1144
1203
|
name: "Schema Presence",
|
|
@@ -1177,12 +1236,10 @@ function auditMetaQuality(config, issues, suggestions) {
|
|
|
1177
1236
|
if (!goodTitleCoverage && config.pages.length > 0) {
|
|
1178
1237
|
issues.push({ category: "Meta Quality", severity: "warning", message: `Only ${pagesWithTitles.length}/${config.pages.length} pages have titles`, fix: "Add titles to all pages" });
|
|
1179
1238
|
}
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
if (!goodDescCoverage && config.pages.length > 0) {
|
|
1185
|
-
suggestions.push(`Only ${pagesWithDesc.length}/${config.pages.length} pages have descriptions \u2014 add per-page descriptions`);
|
|
1239
|
+
const hasOgImage = !!config.og.image;
|
|
1240
|
+
checks.push({ label: "OG image configured", passed: hasOgImage, points: hasOgImage ? 4 : 0 });
|
|
1241
|
+
if (!hasOgImage) {
|
|
1242
|
+
suggestions.push("Set og.image for richer social sharing previews and AI citation cards");
|
|
1186
1243
|
}
|
|
1187
1244
|
return {
|
|
1188
1245
|
name: "Meta Quality",
|