# domain/converters/chapter.converter.ts

> 28 lines of code and 3 definitions.

Tree: Site tree
Language: typescript
Layer: processing
Canonical: https://banes-lab.com/anatomy/tree#file-domain-converters-chapter-converter-ts
Source text: https://banes-lab.com/assets/sources/source.ff6afdce80ffa72683687a663b371dbdc618b3ace316abacf234718fadf22636.generated.txt

## Definitions

- `chapterRef` (lexical_declaration, line 9, exported)
- `chapterVocabulary` (lexical_declaration, line 18, exported)
- `ANCHOR` (lexical_declaration, line 7)

## Uses

- [core/assets/link.assets.ts](https://banes-lab.com/source/tree/core/assets/link.assets.ts.md)

## Used by

- [domain/converters/link.converter.ts](https://banes-lab.com/source/tree/domain/converters/link.converter.ts.md)

## Source

```typescript
import { CHAPTER_FACE, CHAPTER_KIND } from "#configuration/constants/vocabulary.constants";
import type { PageContent, VocabularyEntry } from "#types/vocabulary.types";
import { FACE_SEPARATOR } from "@govlab/constants";
import type { Tab } from "#types/document.types";
import { tabPath } from "#assets/link.assets";

const ANCHOR = "#";

export const chapterRef = function chapterRef(
    page: string,
    tabs: readonly Tab[],
    tab: string,
    section: string,
): string {
    return CHAPTER_FACE + FACE_SEPARATOR + tabPath(page, tabs, tab) + ANCHOR + section;
};

export const chapterVocabulary = function chapterVocabulary(pages: readonly PageContent[]): readonly VocabularyEntry[] {
    return pages.flatMap(({ page, tabs }) =>
        tabs.flatMap((tab) =>
            tab.sections.map((section) => ({
                code: null,
                kind: CHAPTER_KIND,
                layer: null,
                phrase: section.title,
                prose: true,
                ref: chapterRef(page, tabs, tab.id, section.id),
            })),
        ),
    );
};
```
