API Reference
defineConfig(config)
Section titled “defineConfig(config)”Type-safe configuration helper:
import { defineConfig } from 'aeo.js';
export default defineConfig({ title: 'My Site', url: 'https://mysite.com',});generateAll(config)
Section titled “generateAll(config)”Generate all AEO files programmatically:
import { generateAll } from 'aeo.js';
await generateAll({ title: 'My Site', url: 'https://mysite.com', outDir: 'dist',});resolveConfig(config)
Section titled “resolveConfig(config)”Resolve a partial config into a fully resolved config with defaults:
import { resolveConfig } from 'aeo.js';
const resolved = resolveConfig({ title: 'My Site' });// All fields now have defaultsvalidateConfig(config)
Section titled “validateConfig(config)”Validate a config object and return any errors:
import { validateConfig } from 'aeo.js';
const errors = validateConfig(config);detectFramework()
Section titled “detectFramework()”Auto-detect the framework used in the current project:
import { detectFramework } from 'aeo.js';
const info = detectFramework();// { framework: 'next', contentDir: 'pages', outDir: '.next' }HTML Extraction
Section titled “HTML Extraction”htmlToMarkdown(html)
Section titled “htmlToMarkdown(html)”Convert HTML to clean markdown:
import { htmlToMarkdown } from 'aeo.js';
const md = htmlToMarkdown('<h1>Hello</h1><p>World</p>');// '# Hello\n\nWorld'extractTextFromHtml(html)
Section titled “extractTextFromHtml(html)”Extract plain text from HTML:
import { extractTextFromHtml } from 'aeo.js';
const text = extractTextFromHtml('<p>Hello <strong>world</strong></p>');extractTitle(html) / extractDescription(html)
Section titled “extractTitle(html) / extractDescription(html)”Extract the title or meta description from an HTML document.
extractJsonLd(html)
Section titled “extractJsonLd(html)”Extract JSON-LD structured data from an HTML document.
Schema
Section titled “Schema”generateSchemaObjects(config)
Section titled “generateSchemaObjects(config)”Generate JSON-LD schema objects:
import { generateSchemaObjects } from 'aeo.js';
const schemas = generateSchemaObjects(resolvedConfig);generateJsonLdScript(config)
Section titled “generateJsonLdScript(config)”Generate a <script type="application/ld+json"> tag:
import { generateJsonLdScript } from 'aeo.js';
const script = generateJsonLdScript(resolvedConfig);generateSiteSchemas(config) / generatePageSchemas(config, page)
Section titled “generateSiteSchemas(config) / generatePageSchemas(config, page)”Generate schemas for the site or individual pages.
Open Graph
Section titled “Open Graph”generateOGTags(config, page)
Section titled “generateOGTags(config, page)”Returns an array of MetaTag objects:
import { generateOGTags } from 'aeo.js';
const tags = generateOGTags(config, { pathname: '/', title: 'Home' });// [{ property: 'og:title', content: 'Home' }, ...]generateOGTagsHtml(config, page)
Section titled “generateOGTagsHtml(config, page)”Returns OG tags as an HTML string.
auditSite(url)
Section titled “auditSite(url)”Audit a site for AEO best practices:
import { auditSite, formatAuditReport, getGrade } from 'aeo.js';
const result = await auditSite('https://mysite.com');console.log(formatAuditReport(result));console.log(getGrade(result)); // 'A', 'B', 'C', etc.Citability
Section titled “Citability”scorePageCitability(url, html)
Section titled “scorePageCitability(url, html)”Score how likely a page is to be cited by AI:
import { scorePageCitability, formatPageCitability } from 'aeo.js';
const score = await scorePageCitability(url, html);console.log(formatPageCitability(score));scoreSiteCitability(url, pages)
Section titled “scoreSiteCitability(url, pages)”Score citability across your entire site.
Reports
Section titled “Reports”generateReport(config)
Section titled “generateReport(config)”Generate a comprehensive AEO report:
import { generateReport, formatReportMarkdown } from 'aeo.js';
const report = await generateReport(config);console.log(formatReportMarkdown(report));All types are exported from the main entry:
import type { AeoConfig, ResolvedAeoConfig, PageEntry, DocEntry, AeoManifest, MarkdownFile, ManifestEntry, AIIndexEntry, FrameworkType, FrameworkInfo, AuditResult, AuditCategory, AuditIssue, MetaTag, PageCitabilityResult, SiteCitabilityResult, CitabilityDimension, ContentHint, AeoReport, PlatformHint,} from 'aeo.js';