UNPKG

@stacksjs/stx

Version:

A performant UI Framework. Powered by Bun.

146 lines 4.39 kB
import type { CustomDirective, StxOptions } from './types'; /** * Process @meta directive for generating meta tags. * Supports both simple `@meta('name', 'content')` and * OpenGraph `@meta('og:title')` formats. */ export declare function processMetaDirectives(template: string, context: Record<string, any>, _filePath: string, _options: StxOptions): string; /** * Process @structuredData directive for JSON-LD. * Automatically adds schema.org context if not provided. */ export declare function processStructuredData(template: string, context: Record<string, any>, _filePath: string): string; /** * Process @seo directive for automatic meta tag generation. * Generates title, description, Open Graph, Twitter, and structured data tags. */ export declare function processSeoDirective(template: string, context: Record<string, any>, _filePath: string, _options: StxOptions): string; /** * Injects default SEO tags if no @seo directive is used. * Respects seo.enabled config and skipDefaultSeoTags option. */ export declare function injectSeoTags(html: string, context: Record<string, any>, options: StxOptions): string; /** * Register SEO directives */ export declare function registerSeoDirectives(): CustomDirective[]; /** * Generate an XML sitemap from a list of URL entries. * * @param entries - Array of sitemap entries * @param options - Sitemap generation options * @returns XML sitemap string * * @example * ```typescript * const sitemap = generateSitemap([ * { loc: '/', priority: 1.0 }, * { loc: '/about', priority: 0.8 }, * { loc: '/blog', changefreq: 'daily' }, * ], { baseUrl: 'https://example.com' }) * ``` */ export declare function generateSitemap(entries: SitemapEntry[], options: SitemapOptions): string; /** * Generate a sitemap index for multiple sitemaps. * * @param sitemaps - Array of sitemap URLs * @param baseUrl - Base URL for the site * @returns XML sitemap index string */ export declare function generateSitemapIndex(sitemaps: string[], baseUrl: string): string; /** * Scan a directory and generate sitemap entries. * * @param directory - Directory to scan for .stx/.html files * @param options - Scan options * @param options.extensions - File extensions to include * @param options.ignore - Patterns to ignore * @param options.baseUrl - Base URL for the sitemap * @returns Array of sitemap entries */ export declare function scanForSitemapEntries(directory: string, options: { extensions?: string[] ignore?: string[] baseUrl: string }): Promise<SitemapEntry[]>; /** * Generate a robots.txt file content. * * @param options - Robots.txt options * @returns robots.txt content string * * @example * ```typescript * const robotsTxt = generateRobotsTxt({ * rules: [ * { * userAgent: '*', * allow: ['/'], * disallow: ['/admin', '/private'], * }, * { * userAgent: 'Googlebot', * allow: ['/'], * crawlDelay: 1, * }, * ], * sitemap: 'https://example.com/sitemap.xml', * }) * ``` */ export declare function generateRobotsTxt(options: RobotsOptions): string; /** * Generate a default robots.txt that allows all crawling. * * @param sitemapUrl - Optional sitemap URL * @returns robots.txt content string */ export declare function generateDefaultRobotsTxt(sitemapUrl?: string): string; /** * SEO meta directive for basic meta tag generation */ export declare const metaDirective: CustomDirective; /** * SEO structured data directive for JSON-LD generation */ export declare const structuredDataDirective: CustomDirective; declare interface StructuredData { '@context': string '@type': string } /** * URL entry for sitemap */ export declare interface SitemapEntry { loc: string lastmod?: string changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never' priority?: number } /** * Sitemap generation options */ export declare interface SitemapOptions { baseUrl: string defaultChangefreq?: SitemapEntry['changefreq'] defaultPriority?: number includeLastmod?: boolean } /** * Robots.txt rule */ export declare interface RobotsRule { userAgent: string allow?: string[] disallow?: string[] crawlDelay?: number } /** * Robots.txt generation options */ export declare interface RobotsOptions { rules: RobotsRule[] sitemap?: string | string[] host?: string }