aeo.js 0.0.2 → 0.0.3

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.
Files changed (62) hide show
  1. package/README.md +132 -17
  2. package/dist/angular.d.mts +29 -0
  3. package/dist/angular.d.ts +29 -0
  4. package/dist/angular.js +1314 -0
  5. package/dist/angular.js.map +1 -0
  6. package/dist/angular.mjs +1310 -0
  7. package/dist/angular.mjs.map +1 -0
  8. package/dist/astro.d.mts +8 -2
  9. package/dist/astro.d.ts +8 -2
  10. package/dist/astro.js +342 -100
  11. package/dist/astro.js.map +1 -1
  12. package/dist/astro.mjs +342 -100
  13. package/dist/astro.mjs.map +1 -1
  14. package/dist/cli.d.mts +1 -0
  15. package/dist/cli.d.ts +1 -0
  16. package/dist/cli.js +1880 -0
  17. package/dist/cli.js.map +1 -0
  18. package/dist/cli.mjs +1878 -0
  19. package/dist/cli.mjs.map +1 -0
  20. package/dist/index.d.mts +178 -4
  21. package/dist/index.d.ts +178 -4
  22. package/dist/index.js +972 -19
  23. package/dist/index.js.map +1 -1
  24. package/dist/index.mjs +952 -20
  25. package/dist/index.mjs.map +1 -1
  26. package/dist/next.d.mts +2 -17
  27. package/dist/next.d.ts +2 -17
  28. package/dist/next.js +262 -73
  29. package/dist/next.js.map +1 -1
  30. package/dist/next.mjs +262 -73
  31. package/dist/next.mjs.map +1 -1
  32. package/dist/nuxt.d.mts +13 -0
  33. package/dist/nuxt.d.ts +13 -0
  34. package/dist/nuxt.js +1344 -0
  35. package/dist/nuxt.js.map +1 -0
  36. package/dist/nuxt.mjs +1337 -0
  37. package/dist/nuxt.mjs.map +1 -0
  38. package/dist/react.d.mts +1 -1
  39. package/dist/react.d.ts +1 -1
  40. package/dist/{types-BTY-v-7i.d.mts → types-Cn_Qbkmg.d.mts} +34 -0
  41. package/dist/{types-BTY-v-7i.d.ts → types-Cn_Qbkmg.d.ts} +34 -0
  42. package/dist/vite.d.mts +5 -0
  43. package/dist/vite.d.ts +5 -0
  44. package/dist/vite.js +1370 -0
  45. package/dist/vite.js.map +1 -0
  46. package/dist/vite.mjs +1366 -0
  47. package/dist/vite.mjs.map +1 -0
  48. package/dist/vue.d.mts +19 -0
  49. package/dist/vue.d.ts +19 -0
  50. package/dist/vue.js +1078 -0
  51. package/dist/vue.js.map +1 -0
  52. package/dist/vue.mjs +1072 -0
  53. package/dist/vue.mjs.map +1 -0
  54. package/dist/webpack.d.mts +1 -1
  55. package/dist/webpack.d.ts +1 -1
  56. package/dist/webpack.js +178 -18
  57. package/dist/webpack.js.map +1 -1
  58. package/dist/webpack.mjs +178 -18
  59. package/dist/webpack.mjs.map +1 -1
  60. package/dist/widget.d.mts +1 -1
  61. package/dist/widget.d.ts +1 -1
  62. package/package.json +48 -2
package/dist/webpack.mjs CHANGED
@@ -169,7 +169,7 @@ function detectFramework(projectRoot = process.cwd()) {
169
169
  };
170
170
  }
171
171
  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;
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;
173
173
  const frameworkInfo = detectFramework();
174
174
  return {
175
175
  title: config.title || "My Site",
@@ -185,26 +185,43 @@ function resolveConfig(config = {}) {
185
185
  rawMarkdown: ((_d = config.generators) == null ? void 0 : _d.rawMarkdown) !== false,
186
186
  manifest: ((_e = config.generators) == null ? void 0 : _e.manifest) !== false,
187
187
  sitemap: ((_f = config.generators) == null ? void 0 : _f.sitemap) !== false,
188
- aiIndex: ((_g = config.generators) == null ? void 0 : _g.aiIndex) !== false
188
+ aiIndex: ((_g = config.generators) == null ? void 0 : _g.aiIndex) !== false,
189
+ schema: ((_h = config.generators) == null ? void 0 : _h.schema) !== false
189
190
  },
190
191
  robots: {
191
- allow: ((_h = config.robots) == null ? void 0 : _h.allow) || ["/"],
192
- disallow: ((_i = config.robots) == null ? void 0 : _i.disallow) || [],
193
- crawlDelay: ((_j = config.robots) == null ? void 0 : _j.crawlDelay) || 0,
194
- sitemap: ((_k = config.robots) == null ? void 0 : _k.sitemap) || ""
192
+ allow: ((_i = config.robots) == null ? void 0 : _i.allow) || ["/"],
193
+ disallow: ((_j = config.robots) == null ? void 0 : _j.disallow) || [],
194
+ crawlDelay: ((_k = config.robots) == null ? void 0 : _k.crawlDelay) || 0,
195
+ sitemap: ((_l = config.robots) == null ? void 0 : _l.sitemap) || ""
196
+ },
197
+ schema: {
198
+ enabled: ((_m = config.schema) == null ? void 0 : _m.enabled) !== false,
199
+ organization: {
200
+ name: ((_o = (_n = config.schema) == null ? void 0 : _n.organization) == null ? void 0 : _o.name) || config.title || "My Site",
201
+ url: ((_q = (_p = config.schema) == null ? void 0 : _p.organization) == null ? void 0 : _q.url) || config.url || "https://example.com",
202
+ logo: ((_s = (_r = config.schema) == null ? void 0 : _r.organization) == null ? void 0 : _s.logo) || "",
203
+ sameAs: ((_u = (_t = config.schema) == null ? void 0 : _t.organization) == null ? void 0 : _u.sameAs) || []
204
+ },
205
+ defaultType: ((_v = config.schema) == null ? void 0 : _v.defaultType) || "WebPage"
206
+ },
207
+ og: {
208
+ enabled: ((_w = config.og) == null ? void 0 : _w.enabled) !== false,
209
+ image: ((_x = config.og) == null ? void 0 : _x.image) || "",
210
+ twitterHandle: ((_y = config.og) == null ? void 0 : _y.twitterHandle) || "",
211
+ type: ((_z = config.og) == null ? void 0 : _z.type) || "website"
195
212
  },
196
213
  widget: {
197
- enabled: ((_l = config.widget) == null ? void 0 : _l.enabled) !== false,
198
- position: ((_m = config.widget) == null ? void 0 : _m.position) || "bottom-right",
214
+ enabled: ((_A = config.widget) == null ? void 0 : _A.enabled) !== false,
215
+ position: ((_B = config.widget) == null ? void 0 : _B.position) || "bottom-right",
199
216
  theme: {
200
- background: ((_o = (_n = config.widget) == null ? void 0 : _n.theme) == null ? void 0 : _o.background) || "rgba(18, 18, 24, 0.9)",
201
- text: ((_q = (_p = config.widget) == null ? void 0 : _p.theme) == null ? void 0 : _q.text) || "#C0C0C5",
202
- accent: ((_s = (_r = config.widget) == null ? void 0 : _r.theme) == null ? void 0 : _s.accent) || "#E8E8EA",
203
- badge: ((_u = (_t = config.widget) == null ? void 0 : _t.theme) == null ? void 0 : _u.badge) || "#4ADE80"
217
+ background: ((_D = (_C = config.widget) == null ? void 0 : _C.theme) == null ? void 0 : _D.background) || "rgba(18, 18, 24, 0.9)",
218
+ text: ((_F = (_E = config.widget) == null ? void 0 : _E.theme) == null ? void 0 : _F.text) || "#C0C0C5",
219
+ accent: ((_H = (_G = config.widget) == null ? void 0 : _G.theme) == null ? void 0 : _H.accent) || "#E8E8EA",
220
+ badge: ((_J = (_I = config.widget) == null ? void 0 : _I.theme) == null ? void 0 : _J.badge) || "#4ADE80"
204
221
  },
205
- humanLabel: ((_v = config.widget) == null ? void 0 : _v.humanLabel) || "Human",
206
- aiLabel: ((_w = config.widget) == null ? void 0 : _w.aiLabel) || "AI",
207
- showBadge: ((_x = config.widget) == null ? void 0 : _x.showBadge) !== false
222
+ humanLabel: ((_K = config.widget) == null ? void 0 : _K.humanLabel) || "Human",
223
+ aiLabel: ((_L = config.widget) == null ? void 0 : _L.aiLabel) || "AI",
224
+ showBadge: ((_M = config.widget) == null ? void 0 : _M.showBadge) !== false
208
225
  }
209
226
  };
210
227
  }
@@ -503,8 +520,8 @@ function generatePageMarkdownFiles(config) {
503
520
  const generated = [];
504
521
  const pages = config.pages || [];
505
522
  for (const page of pages) {
523
+ if (!page.content) continue;
506
524
  const pageTitle = page.title || (page.pathname === "/" ? config.title : void 0);
507
- if (!page.content && !pageTitle) continue;
508
525
  let filename;
509
526
  if (page.pathname === "/") {
510
527
  filename = "index.md";
@@ -774,6 +791,140 @@ function generateAIIndex(config) {
774
791
  };
775
792
  return JSON.stringify(index, null, 2);
776
793
  }
794
+
795
+ // src/core/schema.ts
796
+ function generateSchema(config) {
797
+ const output = generateSchemaObjects(config);
798
+ return JSON.stringify(output, null, 2);
799
+ }
800
+ function generateSchemaObjects(config) {
801
+ const siteSchemas = generateSiteSchemas(config);
802
+ const pageSchemas = {};
803
+ for (const page of config.pages) {
804
+ const schemas = generatePageSchemas(page, config);
805
+ if (schemas.length > 0) {
806
+ pageSchemas[page.pathname] = schemas;
807
+ }
808
+ }
809
+ return { site: siteSchemas, pages: pageSchemas };
810
+ }
811
+ function generateSiteSchemas(config) {
812
+ const schemas = [];
813
+ schemas.push({
814
+ "@context": "https://schema.org",
815
+ "@type": "WebSite",
816
+ name: config.title,
817
+ description: config.description || void 0,
818
+ url: config.url
819
+ });
820
+ const org = config.schema.organization;
821
+ if (org.name || org.sameAs.length > 0) {
822
+ const orgSchema = {
823
+ "@context": "https://schema.org",
824
+ "@type": "Organization",
825
+ name: org.name,
826
+ url: org.url
827
+ };
828
+ if (org.logo) orgSchema.logo = org.logo;
829
+ if (org.sameAs.length > 0) orgSchema.sameAs = org.sameAs;
830
+ schemas.push(orgSchema);
831
+ }
832
+ return schemas;
833
+ }
834
+ function generatePageSchemas(page, config) {
835
+ const schemas = [];
836
+ const pageUrl = page.pathname === "/" ? config.url : `${config.url.replace(/\/$/, "")}${page.pathname}`;
837
+ const faqItems = detectFaqPatterns(page.content || "");
838
+ if (faqItems.length > 0) {
839
+ schemas.push({
840
+ "@context": "https://schema.org",
841
+ "@type": "FAQPage",
842
+ mainEntity: faqItems.map(({ question, answer }) => ({
843
+ "@type": "Question",
844
+ name: question,
845
+ acceptedAnswer: {
846
+ "@type": "Answer",
847
+ text: answer
848
+ }
849
+ }))
850
+ });
851
+ }
852
+ const pageType = config.schema.defaultType;
853
+ const pageSchema = {
854
+ "@context": "https://schema.org",
855
+ "@type": pageType,
856
+ name: page.title || config.title,
857
+ url: pageUrl
858
+ };
859
+ if (page.description) pageSchema.description = page.description;
860
+ if (pageType === "Article") {
861
+ pageSchema.headline = page.title || config.title;
862
+ pageSchema.author = {
863
+ "@type": "Organization",
864
+ name: config.schema.organization.name
865
+ };
866
+ }
867
+ schemas.push(pageSchema);
868
+ if (page.pathname !== "/") {
869
+ const breadcrumbs = generateBreadcrumbs(page.pathname, config);
870
+ if (breadcrumbs.length > 1) {
871
+ schemas.push({
872
+ "@context": "https://schema.org",
873
+ "@type": "BreadcrumbList",
874
+ itemListElement: breadcrumbs.map((crumb, i) => ({
875
+ "@type": "ListItem",
876
+ position: i + 1,
877
+ name: crumb.name,
878
+ item: crumb.url
879
+ }))
880
+ });
881
+ }
882
+ }
883
+ return schemas;
884
+ }
885
+ function generateBreadcrumbs(pathname, config) {
886
+ const baseUrl = config.url.replace(/\/$/, "");
887
+ const parts = pathname.split("/").filter(Boolean);
888
+ const crumbs = [
889
+ { name: "Home", url: baseUrl + "/" }
890
+ ];
891
+ let currentPath = "";
892
+ for (const part of parts) {
893
+ currentPath += "/" + part;
894
+ crumbs.push({
895
+ name: part.charAt(0).toUpperCase() + part.slice(1).replace(/-/g, " "),
896
+ url: baseUrl + currentPath
897
+ });
898
+ }
899
+ return crumbs;
900
+ }
901
+ function detectFaqPatterns(content) {
902
+ const items = [];
903
+ const lines = content.split("\n");
904
+ for (let i = 0; i < lines.length; i++) {
905
+ const line = lines[i].trim();
906
+ const headingMatch = line.match(/^#{1,6}\s+(.+\?)\s*$/);
907
+ if (headingMatch) {
908
+ const answerLines = [];
909
+ for (let j = i + 1; j < lines.length; j++) {
910
+ const nextLine = lines[j].trim();
911
+ if (!nextLine) {
912
+ if (answerLines.length > 0) break;
913
+ continue;
914
+ }
915
+ if (/^#{1,6}\s/.test(nextLine)) break;
916
+ answerLines.push(nextLine);
917
+ }
918
+ if (answerLines.length > 0) {
919
+ items.push({
920
+ question: headingMatch[1],
921
+ answer: answerLines.join(" ").slice(0, 500)
922
+ });
923
+ }
924
+ }
925
+ }
926
+ return items;
927
+ }
777
928
  async function generateAEOFiles(configOrRoot, maybeConfig) {
778
929
  var _a;
779
930
  let config;
@@ -802,7 +953,7 @@ async function generateAEOFiles(configOrRoot, maybeConfig) {
802
953
  if (config.generators.llmsTxt) {
803
954
  try {
804
955
  const content = generateLlmsTxt(config);
805
- writeFileSync(join(outDir, "llms.txt"), "\uFEFF" + content, "utf-8");
956
+ writeFileSync(join(outDir, "llms.txt"), content, "utf-8");
806
957
  files.push("llms.txt");
807
958
  } catch (e) {
808
959
  errors.push(`llms.txt: ${e.message}`);
@@ -811,7 +962,7 @@ async function generateAEOFiles(configOrRoot, maybeConfig) {
811
962
  if (config.generators.llmsFullTxt) {
812
963
  try {
813
964
  const content = generateLlmsFullTxt(config);
814
- writeFileSync(join(outDir, "llms-full.txt"), "\uFEFF" + content, "utf-8");
965
+ writeFileSync(join(outDir, "llms-full.txt"), content, "utf-8");
815
966
  files.push("llms-full.txt");
816
967
  } catch (e) {
817
968
  errors.push(`llms-full.txt: ${e.message}`);
@@ -862,6 +1013,15 @@ async function generateAEOFiles(configOrRoot, maybeConfig) {
862
1013
  errors.push(`ai-index.json: ${e.message}`);
863
1014
  }
864
1015
  }
1016
+ if (config.generators.schema && config.schema.enabled) {
1017
+ try {
1018
+ const content = generateSchema(config);
1019
+ writeFileSync(join(outDir, "schema.json"), content, "utf-8");
1020
+ files.push("schema.json");
1021
+ } catch (e) {
1022
+ errors.push(`schema.json: ${e.message}`);
1023
+ }
1024
+ }
865
1025
  return { files, errors };
866
1026
  }
867
1027
  function scanHtmlAssets(compilation) {