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/next.d.mts
CHANGED
package/dist/next.d.ts
CHANGED
package/dist/next.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
|
}
|
|
@@ -275,7 +285,8 @@ function collectMarkdownFiles(dir, base = dir) {
|
|
|
275
285
|
for (const entry of entries) {
|
|
276
286
|
const fullPath = path.join(dir, entry);
|
|
277
287
|
const stat = fs.statSync(fullPath);
|
|
278
|
-
|
|
288
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "public", "dist", ".next", ".nuxt", ".output", ".open-next", "coverage", "__tests__", "__mocks__"]);
|
|
289
|
+
if (stat.isDirectory() && !entry.startsWith(".") && !SKIP_DIRS.has(entry)) {
|
|
279
290
|
files.push(...collectMarkdownFiles(fullPath, base));
|
|
280
291
|
} else if (stat.isFile() && (path.extname(entry) === ".md" || path.extname(entry) === ".mdx")) {
|
|
281
292
|
const content = fs.readFileSync(fullPath, "utf-8");
|
|
@@ -618,7 +629,8 @@ function collectUrls(dir, config, base = dir) {
|
|
|
618
629
|
for (const entry of entries) {
|
|
619
630
|
const fullPath = path.join(dir, entry);
|
|
620
631
|
const stat = fs.statSync(fullPath);
|
|
621
|
-
|
|
632
|
+
const SKIP_DIRS = /* @__PURE__ */ new Set(["node_modules", "public", "dist", ".next", ".nuxt", ".output", ".open-next", "coverage", "__tests__", "__mocks__"]);
|
|
633
|
+
if (stat.isDirectory() && !entry.startsWith(".") && !SKIP_DIRS.has(entry)) {
|
|
622
634
|
urls.push(...collectUrls(fullPath, config, base));
|
|
623
635
|
} else if (stat.isFile() && (path.extname(entry) === ".md" || path.extname(entry) === ".mdx" || path.extname(entry) === ".html")) {
|
|
624
636
|
const relativePath = path.relative(base, fullPath);
|
|
@@ -846,6 +858,22 @@ function generatePageSchemas(page, config) {
|
|
|
846
858
|
}))
|
|
847
859
|
});
|
|
848
860
|
}
|
|
861
|
+
if (faqItems.length === 0) {
|
|
862
|
+
const howToSteps = detectHowToSteps(page.content || "");
|
|
863
|
+
if (howToSteps.length > 0) {
|
|
864
|
+
schemas.push({
|
|
865
|
+
"@context": "https://schema.org",
|
|
866
|
+
"@type": "HowTo",
|
|
867
|
+
name: page.title || config.title,
|
|
868
|
+
step: howToSteps.map((s, i) => ({
|
|
869
|
+
"@type": "HowToStep",
|
|
870
|
+
position: i + 1,
|
|
871
|
+
name: s.name,
|
|
872
|
+
text: s.text
|
|
873
|
+
}))
|
|
874
|
+
});
|
|
875
|
+
}
|
|
876
|
+
}
|
|
849
877
|
const pageType = config.schema.defaultType;
|
|
850
878
|
const pageSchema = {
|
|
851
879
|
"@context": "https://schema.org",
|
|
@@ -922,6 +950,34 @@ function detectFaqPatterns(content) {
|
|
|
922
950
|
}
|
|
923
951
|
return items;
|
|
924
952
|
}
|
|
953
|
+
function detectHowToSteps(content) {
|
|
954
|
+
const steps = [];
|
|
955
|
+
const lines = content.split("\n");
|
|
956
|
+
for (let i = 0; i < lines.length; i++) {
|
|
957
|
+
const line = lines[i].trim();
|
|
958
|
+
const stepMatch = line.match(/^#{1,6}\s+(?:Step\s+\d+[\s:.-]*|(\d+)[.)]\s*)(.+)$/i);
|
|
959
|
+
if (stepMatch) {
|
|
960
|
+
const name = (stepMatch[2] || stepMatch[1] || "").trim();
|
|
961
|
+
const bodyLines = [];
|
|
962
|
+
for (let j = i + 1; j < lines.length; j++) {
|
|
963
|
+
const nextLine = lines[j].trim();
|
|
964
|
+
if (!nextLine) {
|
|
965
|
+
if (bodyLines.length > 0) break;
|
|
966
|
+
continue;
|
|
967
|
+
}
|
|
968
|
+
if (/^#{1,6}\s/.test(nextLine)) break;
|
|
969
|
+
bodyLines.push(nextLine);
|
|
970
|
+
}
|
|
971
|
+
if (name) {
|
|
972
|
+
steps.push({
|
|
973
|
+
name,
|
|
974
|
+
text: bodyLines.join(" ").slice(0, 500)
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
return steps.length >= 2 ? steps : [];
|
|
980
|
+
}
|
|
925
981
|
async function generateAEOFiles(configOrRoot, maybeConfig) {
|
|
926
982
|
var _a;
|
|
927
983
|
let config;
|
|
@@ -1157,7 +1213,7 @@ function withAeo(nextConfig = {}) {
|
|
|
1157
1213
|
page.description = aeoOptions.description;
|
|
1158
1214
|
}
|
|
1159
1215
|
}
|
|
1160
|
-
const contentDir = aeoOptions.contentDir ||
|
|
1216
|
+
const contentDir = aeoOptions.contentDir || [path.join(projectRoot, "content"), path.join(projectRoot, "docs"), path.join(projectRoot, "src")].find((d) => fs.existsSync(d)) || path.join(projectRoot, "content");
|
|
1161
1217
|
const resolvedConfig = resolveConfig({
|
|
1162
1218
|
...aeoOptions,
|
|
1163
1219
|
outDir: aeoOptions.outDir || path.join(projectRoot, "public"),
|
|
@@ -1277,7 +1333,7 @@ async function postBuild(config = {}) {
|
|
|
1277
1333
|
page.description = config.description;
|
|
1278
1334
|
}
|
|
1279
1335
|
}
|
|
1280
|
-
const contentDir = config.contentDir ||
|
|
1336
|
+
const contentDir = config.contentDir || [path.join(projectRoot, "content"), path.join(projectRoot, "docs"), path.join(projectRoot, "src")].find((d) => fs.existsSync(d)) || path.join(projectRoot, "content");
|
|
1281
1337
|
const resolvedConfig = resolveConfig({
|
|
1282
1338
|
...config,
|
|
1283
1339
|
outDir: config.outDir || path.join(projectRoot, "public"),
|