domain/loaders/anatomy.loader.ts

domain/loaders/anatomy.loader.ts is a file in Bane's Lab Site. 23 lines of code and 2 definitions.

import type { DefinitionBlock, SourceBlock } from "#types/block.types";
import type { DefinitionLocation } from "#types/anatomy.types";
import { languageOf } from "#domain/converters/source.converter";
import { sourceEntryOf } from "#core/loaders/walk.loader";

export const citedSource = function citedSource(
    block: DefinitionBlock,
): { readonly block: SourceBlock; readonly location: DefinitionLocation } | null {
    const entry = block.file === null ? null : sourceEntryOf(block.file);
    if (block.file === null || block.line === null || entry === null) {
        return null;
    }
    return {
        block: {
            kind: "source",
            language: languageOf(block.file),
            path: block.file,
            ...(entry.references === null ? {} : { references: entry.references }),
            source: entry.source,
            title: block.title,
        },
        location: { file: block.file, line: block.line, name: block.name },
    };
};