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/webpack.mjs
CHANGED
|
@@ -84,10 +84,19 @@ function generateRobotsTxt(config) {
|
|
|
84
84
|
}
|
|
85
85
|
lines.push("# Default for all other bots");
|
|
86
86
|
lines.push("User-agent: *");
|
|
87
|
-
|
|
87
|
+
for (const path of config.robots.allow.length > 0 ? config.robots.allow : ["/"]) {
|
|
88
|
+
lines.push(`Allow: ${path}`);
|
|
89
|
+
}
|
|
90
|
+
for (const path of config.robots.disallow) {
|
|
91
|
+
lines.push(`Disallow: ${path}`);
|
|
92
|
+
}
|
|
93
|
+
if (config.robots.crawlDelay > 0) {
|
|
94
|
+
lines.push(`Crawl-delay: ${config.robots.crawlDelay}`);
|
|
95
|
+
}
|
|
88
96
|
lines.push("");
|
|
89
|
-
|
|
90
|
-
|
|
97
|
+
const sitemapUrl = config.robots.sitemap || (config.url ? `${config.url}/sitemap.xml` : "");
|
|
98
|
+
if (sitemapUrl) {
|
|
99
|
+
lines.push(`Sitemap: ${sitemapUrl}`);
|
|
91
100
|
}
|
|
92
101
|
lines.push("");
|
|
93
102
|
lines.push("# AEO (Answer Engine Optimization) files");
|
|
@@ -169,7 +178,7 @@ function detectFramework(projectRoot = process.cwd()) {
|
|
|
169
178
|
};
|
|
170
179
|
}
|
|
171
180
|
function resolveConfig(config = {}) {
|
|
172
|
-
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;
|
|
181
|
+
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;
|
|
173
182
|
const frameworkInfo = detectFramework();
|
|
174
183
|
return {
|
|
175
184
|
title: config.title || "My Site",
|
|
@@ -213,15 +222,16 @@ function resolveConfig(config = {}) {
|
|
|
213
222
|
widget: {
|
|
214
223
|
enabled: ((_A = config.widget) == null ? void 0 : _A.enabled) !== false,
|
|
215
224
|
position: ((_B = config.widget) == null ? void 0 : _B.position) || "bottom-right",
|
|
225
|
+
size: ((_C = config.widget) == null ? void 0 : _C.size) || "default",
|
|
216
226
|
theme: {
|
|
217
|
-
background: ((
|
|
218
|
-
text: ((
|
|
219
|
-
accent: ((
|
|
220
|
-
badge: ((
|
|
227
|
+
background: ((_E = (_D = config.widget) == null ? void 0 : _D.theme) == null ? void 0 : _E.background) || "rgba(18, 18, 24, 0.9)",
|
|
228
|
+
text: ((_G = (_F = config.widget) == null ? void 0 : _F.theme) == null ? void 0 : _G.text) || "#C0C0C5",
|
|
229
|
+
accent: ((_I = (_H = config.widget) == null ? void 0 : _H.theme) == null ? void 0 : _I.accent) || "#E8E8EA",
|
|
230
|
+
badge: ((_K = (_J = config.widget) == null ? void 0 : _J.theme) == null ? void 0 : _K.badge) || "#4ADE80"
|
|
221
231
|
},
|
|
222
|
-
humanLabel: ((
|
|
223
|
-
aiLabel: ((
|
|
224
|
-
showBadge: ((
|
|
232
|
+
humanLabel: ((_L = config.widget) == null ? void 0 : _L.humanLabel) || "Human",
|
|
233
|
+
aiLabel: ((_M = config.widget) == null ? void 0 : _M.aiLabel) || "AI",
|
|
234
|
+
showBadge: ((_N = config.widget) == null ? void 0 : _N.showBadge) !== false
|
|
225
235
|
}
|
|
226
236
|
};
|
|
227
237
|
}
|
|
@@ -278,7 +288,8 @@ function collectMarkdownFiles(dir, base = dir) {
|
|
|
278
288
|
for (const entry of entries) {
|
|
279
289
|
const fullPath = join(dir, entry);
|
|
280
290
|
const stat = statSync(fullPath);
|
|
281
|
-
|
|
291
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "public", "dist", ".next", ".nuxt", ".output", ".open-next", "coverage", "__tests__", "__mocks__"]);
|
|
292
|
+
if (stat.isDirectory() && !entry.startsWith(".") && !SKIP_DIRS.has(entry)) {
|
|
282
293
|
files.push(...collectMarkdownFiles(fullPath, base));
|
|
283
294
|
} else if (stat.isFile() && (extname(entry) === ".md" || extname(entry) === ".mdx")) {
|
|
284
295
|
const content = readFileSync(fullPath, "utf-8");
|
|
@@ -621,7 +632,8 @@ function collectUrls(dir, config, base = dir) {
|
|
|
621
632
|
for (const entry of entries) {
|
|
622
633
|
const fullPath = join(dir, entry);
|
|
623
634
|
const stat = statSync(fullPath);
|
|
624
|
-
|
|
635
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "public", "dist", ".next", ".nuxt", ".output", ".open-next", "coverage", "__tests__", "__mocks__"]);
|
|
636
|
+
if (stat.isDirectory() && !entry.startsWith(".") && !SKIP_DIRS.has(entry)) {
|
|
625
637
|
urls.push(...collectUrls(fullPath, config, base));
|
|
626
638
|
} else if (stat.isFile() && (extname(entry) === ".md" || extname(entry) === ".mdx" || extname(entry) === ".html")) {
|
|
627
639
|
const relativePath = relative(base, fullPath);
|
|
@@ -849,6 +861,22 @@ function generatePageSchemas(page, config) {
|
|
|
849
861
|
}))
|
|
850
862
|
});
|
|
851
863
|
}
|
|
864
|
+
if (faqItems.length === 0) {
|
|
865
|
+
const howToSteps = detectHowToSteps(page.content || "");
|
|
866
|
+
if (howToSteps.length > 0) {
|
|
867
|
+
schemas.push({
|
|
868
|
+
"@context": "https://schema.org",
|
|
869
|
+
"@type": "HowTo",
|
|
870
|
+
name: page.title || config.title,
|
|
871
|
+
step: howToSteps.map((s, i) => ({
|
|
872
|
+
"@type": "HowToStep",
|
|
873
|
+
position: i + 1,
|
|
874
|
+
name: s.name,
|
|
875
|
+
text: s.text
|
|
876
|
+
}))
|
|
877
|
+
});
|
|
878
|
+
}
|
|
879
|
+
}
|
|
852
880
|
const pageType = config.schema.defaultType;
|
|
853
881
|
const pageSchema = {
|
|
854
882
|
"@context": "https://schema.org",
|
|
@@ -925,6 +953,34 @@ function detectFaqPatterns(content) {
|
|
|
925
953
|
}
|
|
926
954
|
return items;
|
|
927
955
|
}
|
|
956
|
+
function detectHowToSteps(content) {
|
|
957
|
+
const steps = [];
|
|
958
|
+
const lines = content.split("\n");
|
|
959
|
+
for (let i = 0; i < lines.length; i++) {
|
|
960
|
+
const line = lines[i].trim();
|
|
961
|
+
const stepMatch = line.match(/^#{1,6}\s+(?:Step\s+\d+[\s:.-]*|(\d+)[.)]\s*)(.+)$/i);
|
|
962
|
+
if (stepMatch) {
|
|
963
|
+
const name = (stepMatch[2] || stepMatch[1] || "").trim();
|
|
964
|
+
const bodyLines = [];
|
|
965
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
966
|
+
const nextLine = lines[j].trim();
|
|
967
|
+
if (!nextLine) {
|
|
968
|
+
if (bodyLines.length > 0) break;
|
|
969
|
+
continue;
|
|
970
|
+
}
|
|
971
|
+
if (/^#{1,6}\s/.test(nextLine)) break;
|
|
972
|
+
bodyLines.push(nextLine);
|
|
973
|
+
}
|
|
974
|
+
if (name) {
|
|
975
|
+
steps.push({
|
|
976
|
+
name,
|
|
977
|
+
text: bodyLines.join(" ").slice(0, 500)
|
|
978
|
+
});
|
|
979
|
+
}
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
return steps.length >= 2 ? steps : [];
|
|
983
|
+
}
|
|
928
984
|
async function generateAEOFiles(configOrRoot, maybeConfig) {
|
|
929
985
|
var _a;
|
|
930
986
|
let config;
|