# jg-publishing-guides

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

- **Version:** `1.0.1`
- **Runtimes:** Node.js
- **Install:** `npm install jg-publishing-guides`
- **On npm:** [jg-publishing-guides](https://www.npmjs.com/package/jg-publishing-guides)
- **Source:** [packages/jg-publishing-guides](https://github.com/jesusgraterol/jg-packages/tree/main/packages/jg-publishing-guides)
- **Recipes:** [jg-publishing-guides recipes](https://jg-packages.jesusgraterol.dev/packages/jg-publishing-guides/recipes/index.md)

## 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. |

## <a id="api-reference"></a>jg-publishing-guides API reference

Every export of `jg-publishing-guides@1.0.1`, 9 in all, with its signature, its errors, and an example. It's generated from the package's TSDoc.

- Functions: [`renderPublishingGuide`](#api-renderPublishingGuide)
- Constants: [`ERRORS`](#api-ERRORS)
- Types: [`IPublishingChannel`](#api-IPublishingChannel), [`IPublishingGuide`](#api-IPublishingGuide), [`IPublishingGuideFile`](#api-IPublishingGuideFile), [`IPublishingGuideLocale`](#api-IPublishingGuideLocale), [`IPublishingGuideOptions`](#api-IPublishingGuideOptions), [`IPublishingGuideResult`](#api-IPublishingGuideResult), [`IPublishingGuideStep`](#api-IPublishingGuideStep)

### <a id="api-functions"></a>Functions

#### <a id="api-renderPublishingGuide"></a>`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.

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

**Parameters**

- `guide` `IPublishingGuide`: 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_GUIDE`: The publishing guide input is invalid.

**Example**

```ts
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];
```

### <a id="api-constants"></a>Constants

#### <a id="api-ERRORS"></a>`ERRORS`

*Constant*

stable public code for presentation input failures

```ts
const ERRORS: { INVALID_PUBLISHING_GUIDE: "INVALID_PUBLISHING_GUIDE" }
```

### <a id="api-types"></a>Types

#### <a id="api-IPublishingChannel"></a>`IPublishingChannel`

*Type*

manual destinations already supported by offline publishing packets

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

#### <a id="api-IPublishingGuide"></a>`IPublishingGuide`

*Type*

the caller-approved presentation records for one publishing packet

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

**Members**

- `title: string` (property)
- `summary: string` (property)
- `files: IPublishingGuideFile[]` (property)
- `walkthrough: IPublishingGuideStep[]` (property)

#### <a id="api-IPublishingGuideFile"></a>`IPublishingGuideFile`

*Type*

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

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

#### <a id="api-IPublishingGuideLocale"></a>`IPublishingGuideLocale`

*Type*

supported interface languages

```ts
type IPublishingGuideLocale = 'en' | 'es';
```

#### <a id="api-IPublishingGuideOptions"></a>`IPublishingGuideOptions`

*Type*

the interface locale is independent of the authored copy

```ts
type IPublishingGuideOptions = {
    locale?: IPublishingGuideLocale;
};
```

**Members**

- `locale: IPublishingGuideLocale` (property)

#### <a id="api-IPublishingGuideResult"></a>`IPublishingGuideResult`

*Type*

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

```ts
type IPublishingGuideResult = {
    html: string;
    readme: string;
};
```

**Members**

- `html: string` (property)
- `readme: string` (property)

#### <a id="api-IPublishingGuideStep"></a>`IPublishingGuideStep`

*Type*

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

```ts
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;
};
```
