Options
All
  • Public
  • Public/Protected
  • All
Menu

Config module

Index

Type aliases

Config

Config: z.infer<typeof configSchema>

Delimiter

Delimiter: string

Metadata

Metadata: z.infer<typeof metaDataSchema>

PartialConfig

PartialConfig: Partial<Config>
example

Custom book config loaded from file may contain selected (partial) config properties

PartialConfigWithDeprecated

PartialConfigWithDeprecated: Partial<ConfigWithDeprecated>
example

Custom book config loaded from file may contain selected (partial) config properties

Preview

Preview: z.infer<typeof previewSchema>

PreviewTrue

PreviewTrue: z.infer<typeof previewTrueSchema>

SelectorFn

SelectorFn: (root: Document | Element) => void

Type declaration

    • (root: Document | Element): void
    • A callback that marks elements as chunks of ideas. Those are then used for idea mapping.

      Parameters

      • root: Document | Element

        DOM Document or Element

      Returns void

      Modifies DOM Document

Selectors

Selectors: (keyof HTMLElementTagNameMap | string)[] | SelectorFn

TokenizerFn

TokenizerFn: (node: Node, text: string) => string

Type declaration

    • (node: Node, text: string): string
    • A callback used to split chunk contents into ideas.

      Parameters

      • node: Node
      • text: string

      Returns string

Variables

Const configSchema

configSchema: ZodObject<{ delimiter: ZodDefault<ZodString>; languageCode: ZodDefault<ZodString>; meta: ZodDefault<ZodOptional<ZodObject<{ author: ZodString; edition: ZodOptional<ZodString>; keywords: ZodOptional<ZodArray<ZodString, "many">>; published: ZodOptional<ZodNumber>; publisher: ZodOptional<ZodString>; subtitle: ZodOptional<ZodString>; title: ZodString }, "strip", ZodTypeAny, { author: string; edition: undefined | string; keywords: undefined | string[]; published: undefined | number; publisher: undefined | string; subtitle: undefined | string; title: string }, { author: string; edition: undefined | string; keywords: undefined | string[]; published: undefined | number; publisher: undefined | string; subtitle: undefined | string; title: string }>>>; output: ZodDefault<ZodEnum<["jsdom", "html"]>>; preview: ZodDefault<ZodOptional<ZodDiscriminatedUnion<"isPreview", Primitive, ZodObject<{ chaptersSlice: ZodDefault<ZodOptional<ZodNumber>>; fullTextUrl: ZodString; isPreview: ZodLiteral<true>; removeChapters: ZodArray<ZodString, "many"> }, "strip", ZodTypeAny, { chaptersSlice: number; fullTextUrl: string; isPreview: true; removeChapters: string[] }, { chaptersSlice: undefined | number; fullTextUrl: string; isPreview: true; removeChapters: string[] }> | ZodObject<{ isPreview: ZodLiteral<false> }, "strip", ZodTypeAny, { isPreview: false }, { isPreview: false }>>>>; readingOrder: ZodDefault<ZodArray<ZodString, "many">>; root: ZodDefault<ZodString>; selectors: ZodDefault<ZodArray<ZodString, "many">>; static: ZodDefault<ZodArray<ZodString, "many">>; tocBase: ZodDefault<ZodArray<ZodType<TocBaseItem, ZodTypeDef, TocBaseItem>, "many">> }, "strip", ZodTypeAny, { delimiter: string; languageCode: string; meta: { subtitle?: string | undefined; published?: number | undefined; publisher?: string | undefined; keywords?: string[] | undefined; edition?: string | undefined; title: string; author: string; }; output: "jsdom" | "html"; preview: { isPreview: true; chaptersSlice: number; removeChapters: string[]; fullTextUrl: string; } | { isPreview: false; }; readingOrder: string[]; root: string; selectors: string[]; static: string[]; tocBase: TocBaseItem[] }, { delimiter: undefined | string; languageCode: undefined | string; meta: undefined | { subtitle?: string | undefined; published?: number | undefined; publisher?: string | undefined; keywords?: string[] | undefined; edition?: string | undefined; title: string; author: string; }; output: undefined | "jsdom" | "html"; preview: undefined | { chaptersSlice?: number | undefined; isPreview: true; removeChapters: string[]; fullTextUrl: string; } | { isPreview: false; }; readingOrder: undefined | string[]; root: undefined | string; selectors: undefined | string[]; static: undefined | string[]; tocBase: undefined | TocBaseItem[] }> = ...

Const metaDataSchema

metaDataSchema: ZodObject<{ author: ZodString; edition: ZodOptional<ZodString>; keywords: ZodOptional<ZodArray<ZodString, "many">>; published: ZodOptional<ZodNumber>; publisher: ZodOptional<ZodString>; subtitle: ZodOptional<ZodString>; title: ZodString }, "strip", ZodTypeAny, { author: string; edition: undefined | string; keywords: undefined | string[]; published: undefined | number; publisher: undefined | string; subtitle: undefined | string; title: string }, { author: string; edition: undefined | string; keywords: undefined | string[]; published: undefined | number; publisher: undefined | string; subtitle: undefined | string; title: string }> = ...

Const previewSchema

previewSchema: ZodDiscriminatedUnion<"isPreview", Primitive, ZodObject<{ chaptersSlice: ZodDefault<ZodOptional<ZodNumber>>; fullTextUrl: ZodString; isPreview: ZodLiteral<true>; removeChapters: ZodArray<ZodString, "many"> }, "strip", ZodTypeAny, { chaptersSlice: number; fullTextUrl: string; isPreview: true; removeChapters: string[] }, { chaptersSlice: undefined | number; fullTextUrl: string; isPreview: true; removeChapters: string[] }> | ZodObject<{ isPreview: ZodLiteral<false> }, "strip", ZodTypeAny, { isPreview: false }, { isPreview: false }>> = ...

Functions

default

  • Loads book config options from file

    The config is being created in following stages:

    1. First, the custom book options in the shape of PartialConfigWithDeprecated are loaded.
    2. Deprecated options are transformed to their new form and the config gets shape of PartialConfig.
    3. Config is acquired by parsing and applying defaults on PartialConfig with Preview options.
    4. Since config is guaranteed to have preview settings decided, the preview logic is applied on the config.

    Parameters

    • srcDir: PathLike

      directory where book config is located

    • Optional fullTextUrl: string

      link to the full book in case of preview feature active

    Returns Config | never

    a config object that is guaranteed to be valid against its predefined schema.

Const parseConfig

  • parseConfig(options: Partial<{ delimiter: string; languageCode: string; meta: { subtitle?: string | undefined; published?: number | undefined; publisher?: string | undefined; keywords?: string[] | undefined; edition?: string | undefined; title: string; author: string; }; output: "jsdom" | "html"; preview: { isPreview: true; chaptersSlice: number; removeChapters: string[]; fullTextUrl: string; } | { isPreview: false; }; readingOrder: string[]; root: string; selectors: string[]; static: string[]; tocBase: TocBaseItem[] }>): { delimiter: string; languageCode: string; meta: { subtitle?: string | undefined; published?: number | undefined; publisher?: string | undefined; keywords?: string[] | undefined; edition?: string | undefined; title: string; author: string; }; output: "jsdom" | "html"; preview: { isPreview: true; chaptersSlice: number; removeChapters: string[]; fullTextUrl: string; } | { isPreview: false; }; readingOrder: string[]; root: string; selectors: string[]; static: string[]; tocBase: TocBaseItem[] }
  • Parameters

    • options: Partial<{ delimiter: string; languageCode: string; meta: { subtitle?: string | undefined; published?: number | undefined; publisher?: string | undefined; keywords?: string[] | undefined; edition?: string | undefined; title: string; author: string; }; output: "jsdom" | "html"; preview: { isPreview: true; chaptersSlice: number; removeChapters: string[]; fullTextUrl: string; } | { isPreview: false; }; readingOrder: string[]; root: string; selectors: string[]; static: string[]; tocBase: TocBaseItem[] }>

    Returns { delimiter: string; languageCode: string; meta: { subtitle?: string | undefined; published?: number | undefined; publisher?: string | undefined; keywords?: string[] | undefined; edition?: string | undefined; title: string; author: string; }; output: "jsdom" | "html"; preview: { isPreview: true; chaptersSlice: number; removeChapters: string[]; fullTextUrl: string; } | { isPreview: false; }; readingOrder: string[]; root: string; selectors: string[]; static: string[]; tocBase: TocBaseItem[] }

    • delimiter: string
    • languageCode: string
    • meta: { subtitle?: string | undefined; published?: number | undefined; publisher?: string | undefined; keywords?: string[] | undefined; edition?: string | undefined; title: string; author: string; }
    • output: "jsdom" | "html"
    • preview: { isPreview: true; chaptersSlice: number; removeChapters: string[]; fullTextUrl: string; } | { isPreview: false; }
    • readingOrder: string[]
    • root: string
    • selectors: string[]
    • static: string[]
    • tocBase: TocBaseItem[]

Generated using TypeDoc