• Font size
  • Line height
  • Font
  • PagesMap

    [email protected]

    Signature

    export type PagesMap = Record<string, PagesEntry | PagesEntry[]> & {    fallback?: PagesFunction}

    Specifies the locations of pages to use for generating PDF files.

    Description

    The locations can be absolute pathnames to use pages within your Astro site, or full URLs for using other websites.

    Optionally provide a fallback PagesFunction which will be called with the pagenames of pages generated by Astro which are not already in the map.

    If the pathname is in the map, but the maps to null, undefined, or an empty array, it will treated as if it is not in the map, meaning the pathname will still be passed to fallback. If the pathname maps to false, then the page is skipped.

    Example

    {    pages: {        'https://example.com': 'example.pdf',        '/specific/page': [            {                path: 'specific-page.pdf'            },            {                path: 'specific-page-screen.pdf',                screen: true,                pdf: {                    printBackground: true                }            }        ],        '/documents/dynamic': false, // will not be passed to fallback        fallback: (pathname) => {            if (pathname.startsWith('/documents/')) {                return `/generated/${pathname.substring(11)}.pdf`            }        }    }}

    Given the following project structure:

    pages/├── documents/│   ├── index.astro│   ├── static1.astro│   ├── static2.astro│   └── dynamic.astro├── specific/│   └── page.astro└── other/    └── page.astro

    The above config will generate:

    example.pdfspecific-page.pdfspecific-page-screen.pdfgenerated/├── static1.pdf└── static2.pdf

    with the fallback function being called with:

    /documents/documents/static1/documents/static2/other/page

    assuming that your build.format is set to file.