Skip to main content
jg-packages

Search

    Publishing guides

    jg-publishing-guides

    Create offline HTML and plain-text publishing guides with reviewed copy, ordered files, and English or Spanish controls.

    v1.0.1Node.jsESMMIT

    npm

    npm install jg-publishing-guides

    pnpm

    pnpm add jg-publishing-guides

    Usage

    renderPublishingGuide takes a title, a summary, selected files, optional channel steps and literal copy keyed by selected path. It returns html for start-here.html and readme for readme.txt. Keep both files alongside the selected outputs. The English or Spanish interface follows the requested locale. Reviewed copy remains in its original language.

    Use a file-only guide for a handoff without channel steps. Channel guides support ordered image uploads, document posts, TikTok captions with an optional separate title, and Instagram reposts of a preceding, explicitly identified original. The HTML offers keyboard navigation, file links and copy controls with manual selection on clipboard refusal. Its inline script is authorized by its exact CSP hash. The page uses system light and dark modes and needs no server or installation.

    The renderer validates portable paths and presentation references. Your caller owns file access, selection and publication approval. The guide provides instructions for manual publication.

    Errors

    Code Message
    INVALID_PUBLISHING_GUIDE The publishing guide input is invalid.

    Generated from TSDoc

    API reference

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

    Functions

    renderPublishingGuide

    function

    Renders a caller-approved selection into a self-contained HTML guide and a plain-text README. The HTML uses local relative file links and an inline script permitted by its exact CSP hash.

    Signature
    renderPublishingGuide(
      guide: IPublishingGuide,
      copy?: ReadonlyMap<string, string>,
      options?: IPublishingGuideOptions,
    ): IPublishingGuideResult

    Parameters

    guideIPublishingGuide

    The title, selected files and optional channel steps.

    copy?ReadonlyMap<string, string>

    Reviewed literal text keyed by selected local filename.

    Defaults to ....

    options?IPublishingGuideOptions

    The guide interface locale.

    Defaults to {}.

    Returns

    IPublishingGuideResult

    The HTML and plain-text documents.

    Throws

    • INVALID_PUBLISHING_GUIDEThe publishing guide input is invalid.
    Example
    import { renderPublishingGuide } from 'jg-publishing-guides';
    
    const { html, readme } = renderPublishingGuide(
      {
        title: 'Reviewed caption',
        summary: 'Selected copy for manual publication.',
        files: [{ path: 'caption.txt', label: 'Caption', details: 'Reviewed text.', kind: 'file' }],
      },
      new Map([['caption.txt', 'Copy for the published post.']]),
    );
    // write html to start-here.html and readme to readme.txt beside caption.txt
    void [html, readme];

    Constants

    ERRORS

    const

    stable public code for presentation input failures

    Declaration
    const ERRORS: { INVALID_PUBLISHING_GUIDE: "INVALID_PUBLISHING_GUIDE" }

    Types

    IPublishingChannel

    type

    manual destinations already supported by offline publishing packets

    Declaration
    type IPublishingChannel = 'x' | 'linkedin' | 'instagram' | 'tiktok' | 'facebook' | 'threads' | 'bluesky' | 'youtube' | 'github' | 'post';

    IPublishingGuide

    type

    the caller-approved presentation records for one publishing packet

    Declaration
    type IPublishingGuide = {
        title: string;
        summary: string;
        files: IPublishingGuideFile[];
        walkthrough?: IPublishingGuideStep[];
    };

    Members

    • titleproperty
      string
    • summaryproperty
      string
    • filesproperty
      IPublishingGuideFile[]
    • walkthroughproperty
      IPublishingGuideStep[]

    IPublishingGuideFile

    type

    one portable file selected by the caller, with preview dimensions for images and video

    Declaration
    type IPublishingGuideFile = {
        path: string;
        label: string;
        details: string;
    } & ({
        kind: 'file';
    } | {
        kind: 'image' | 'video';
        width: number;
        height: number;
    });

    IPublishingGuideOptions

    type

    the interface locale is independent of the authored copy

    Declaration
    type IPublishingGuideOptions = {
        locale?: IPublishingGuideLocale;
    };

    Members

    • localeproperty
      IPublishingGuideLocale

    IPublishingGuideResult

    type

    offline formats for start-here.html and readme.txt, respectively

    Declaration
    type IPublishingGuideResult = {
        html: string;
        readme: string;
    };

    Members

    • htmlproperty
      string
    • readmeproperty
      string

    IPublishingGuideStep

    type

    one channel's caption and upload order, or a repost of an earlier Instagram step

    Declaration
    type IPublishingGuideStep = ({
        channel: IPublishingChannel;
        id?: string;
        caption: string;
        media: string[];
        documentTitle?: string;
        postTitle?: string;
        repostOf?: undefined;
    } | {
        channel: 'instagram';
        id: string;
        caption?: string;
        media: [];
        documentTitle?: undefined;
        postTitle?: undefined;
        repostOf: string;
    }) & {
        label?: string;
    };