Skip to content

Latest commit

 

History

History
72 lines (50 loc) · 2.73 KB

File metadata and controls

72 lines (50 loc) · 2.73 KB

@stephansama / single-file

source code documentation npm socket.dev jsr npm downloads

cheerio oxc-parser tsdown

Fetch any webpage and produce a fully self-contained HTML file with all external resources — images, stylesheets, scripts, and SVGs — inlined directly into the document.

Table of contents
Open Table of contents

Installation

pnpm install @stephansama/single-file

CLI

# outputs to single-file.html by default
npx @stephansama/single-file <url>

# custom output path
npx @stephansama/single-file <url> --output my-page.html
npx @stephansama/single-file <url> -o my-page.html

# verbose logging
npx @stephansama/single-file <url> --verbose
npx @stephansama/single-file <url> -v
Flag Alias Default Description
--output -o single-file.html Output path for the HTML file
--verbose -v false Enable verbose output

Usage

import * as singleFile from "@stephansama/single-file";

export async function useAPI() {
  const file = await singleFile.convertPageToSingleFile(
    "https://blog.stephansama.info",
  );

  console.info(file);
}