Skip to main content
jg-packages

Search

    Static site checks

    jg-site-checks

    Verify built static sites from an explicit page inventory, with exact canonical URLs, links, fragments, sitemaps, robots.txt, and llms.txt.

    v1.0.0Node.jsESMMIT

    npm

    npm install jg-site-checks

    pnpm

    pnpm add jg-site-checks

    Usage

    Pass verifyStaticSite the artifact directory, production origin and expected public page paths. Each page declares its exact canonical URL or null, and whether it should be indexed. The checker verifies those expectations, same-origin HTML links and fragments, and the supplied discovery files.

    A sitemap can be a URL set or an index of local URL sets. Its URLs must match the indexable canonical inventory exactly. Parsed entries include the sitemap’s lastmod text when present so a caller can check its own dates. Optional robots verification requires the configured sitemap reference. Optional llms.txt verification checks local Markdown link targets. Site-specific crawl policy, page content and search index checks belong in the caller.

    A path with a trailing slash resolves to its index.html. Other paths resolve to an existing file, then a directory index or a matching .html file. HTML links with a different origin are ignored. Links, robots references and sitemap locations are never fetched. Build the artifact before verifying it and keep it unchanged until the check finishes. The default limits are 16,384 file and directory entries, 8 MiB per text file and 128 MiB of text per build.

    Errors

    Code Message
    INVALID_SITE_BUILD_OPTIONS The site build verification options are invalid.
    SITE_BUILD_INVALID The static site build failed verification.

    Generated from TSDoc

    API reference

    Every export of [email protected], 9 in all, with its signature, its errors, and an example.

    Functions

    verifyStaticSite

    function

    Verifies a static build against an explicit site inventory. Reads only contained local artifact files, indexing each inspected HTML file once. Checks canonical metadata, robots indexability, links and fragments, and the discovery files the caller supplies.

    Signature
    verifyStaticSite(
      options: IVerifyStaticSiteOptions,
    ): Promise<IStaticSiteVerification>

    Parameters

    optionsIVerifyStaticSiteOptions

    The local artifact, production origin, page inventory and optional read limits.

    Returns

    Promise<IStaticSiteVerification>

    Verified pages and optional sitemap entries in document order.

    Throws

    • INVALID_SITE_BUILD_OPTIONSThe site build verification options are invalid.
    • SITE_BUILD_INVALIDThe static site build failed verification.
    Example
    import { verifyStaticSite } from 'jg-site-checks';
    
    await verifyStaticSite({
      artifactRoot: 'dist',
      origin: 'https://example.com',
      pages: [{ path: '/', canonicalUrl: 'https://example.com/', indexable: true }],
      discovery: { sitemap: '/sitemap.xml', robots: '/robots.txt' },
    });

    Constants

    ERRORS

    const

    stable public error codes

    Declaration
    const ERRORS: { INVALID_SITE_BUILD_OPTIONS: "INVALID_SITE_BUILD_OPTIONS"; SITE_BUILD_INVALID: "SITE_BUILD_INVALID" }

    Types

    ICheckedSitePage

    type

    the verified inventory page and the relative build file that serves it

    Declaration
    type ICheckedSitePage = IStaticSitePage & {
        file: string;
    };

    ISiteSitemapEntry

    type

    the exact sitemap location and optional published modification date

    Declaration
    type ISiteSitemapEntry = {
        url: string;
        lastmod?: string;
    };

    Members

    • urlproperty
      string
    • lastmodproperty
      string

    IStaticSiteDiscovery

    type

    discovery paths are same-origin site paths such as /sitemap-index.xml

    Declaration
    type IStaticSiteDiscovery = {
        sitemap?: string;
        robots?: string;
        llms?: string;
    };

    Members

    • sitemapproperty
      string
    • robotsproperty
      string
    • llmsproperty
      string

    IStaticSiteLimits

    type

    traversal and cumulative UTF-8 file read limits for one artifact

    Declaration
    type IStaticSiteLimits = {
        entries: number;
        textBytes: number;
        totalTextBytes: number;
    };

    Members

    • entriesproperty
      number
    • textBytesproperty
      number
    • totalTextBytesproperty
      number

    IStaticSitePage

    type

    the canonical URL and indexing policy expected for a single served page

    Declaration
    type IStaticSitePage = {
        path: string;
        canonicalUrl: string | null;
        indexable: boolean;
    };

    Members

    • pathproperty
      string
    • canonicalUrlproperty
      string | null
    • indexableproperty
      boolean

    IStaticSiteVerification

    type

    verified pages in input order and, when enabled, sitemap entries in document order

    Declaration
    type IStaticSiteVerification = {
        pages: ICheckedSitePage[];
        sitemapEntries?: ISiteSitemapEntry[];
    };

    Members

    • pagesproperty
      ICheckedSitePage[]
    • sitemapEntriesproperty
      ISiteSitemapEntry[]

    IVerifyStaticSiteOptions

    type

    caller-owned site expectations and the local artifact containing its built files

    Declaration
    type IVerifyStaticSiteOptions = {
        artifactRoot: string;
        origin: string;
        pages: IStaticSitePage[];
        discovery?: IStaticSiteDiscovery;
        limits?: Partial<IStaticSiteLimits>;
    };

    Members

    • artifactRootproperty
      string
    • originproperty
      string
    • pagesproperty
      IStaticSitePage[]
    • discoveryproperty
      IStaticSiteDiscovery
    • limitsproperty
      Partial<IStaticSiteLimits>