UNPKG

@mdfriday/foundry

Version:

The core engine of MDFriday. Convert Markdown and shortcodes into fully themed static sites – Hugo-style, powered by TypeScript.

241 lines 7.1 kB
import { Path } from '../../domain/paths'; import { Fs, FileMetaInfo, WalkCallback, WalkwayConfig } from '../../domain/fs'; import { Result as MarkdownResult, RenderContext, DocumentContext, ParsedContentResult, ContentResult, ParseAndRenderOptions, RenderableDocument, MarkdownRenderer } from '../../domain/markdown'; import { Scratch } from '../../../pkg/maps/scratch'; export interface ComponentPath { component(): string; path(): string; } export interface Services extends LangService, FsService, TaxonomyService { markdown(): MarkdownRenderer; } export interface FsService { newFileMetaInfo(filename: string): FileMetaInfo; newFileMetaInfoWithContent(content: string): FileMetaInfo; contentFs(): Fs; walkContent(start: string, cb: WalkCallback, conf: WalkwayConfig): Promise<void>; } export interface LangService { isLanguageValid(lang: string): boolean; getSourceLang(source: string): [string, boolean]; getLanguageIndex(lang: string): number; getLanguageByIndex(idx: number): string; defaultLanguage(): string; languageIndexes(): number[]; } export interface TaxonomyService { views(): TaxonomyView[]; } export interface TaxonomyView { singular(): string; plural(): string; } export interface Converter { convert(dc: DocumentContext, rc: RenderContext): Promise<MarkdownResult>; parseContent(source: Uint8Array): Promise<ParsedContentResult>; parseAndRenderContent(source: Uint8Array, options?: ParseAndRenderOptions): Promise<ContentResult>; prepareRender(source: Uint8Array): Promise<RenderableDocument>; } export interface PageIdentity { identifierBase(): string; pageLanguage(): string; pageLanguageIndex(): number; markStale(): void; isStale(): boolean; clearStale(): void; } export interface PageSource { pageIdentity(): PageIdentity; pageFile(): File; staleVersions(): number[]; section(): string; paths(): Path; path(): string; } export interface FileProvider { file(): File; } export interface Keyword { toString(): string; } export interface IndicesConfig extends Array<IndexConfig> { } export interface IndexConfig { name(): string; type(): string; applyFilter(): boolean; pattern(): string; weight(): number; cardinalityThreshold(): number; toLower(): boolean; toKeywords(v: any): Promise<Keyword[]>; } export interface PageMeta { description(): string; params(): Record<string, any>; pageWeight(): number; pageDate(): Date; publishDate(): Date; relatedKeywords(cfg: IndexConfig): Promise<Keyword[]>; shouldList(global: boolean): boolean; shouldListAny(): boolean; noLink(): boolean; } export interface PageOutput { targetFileBase(): string; targetFilePath(): string; targetSubResourceDir(): string; targetPrefix(): string; content(): Promise<any>; summary(): Promise<string>; tableOfContents(): string; result(): MarkdownResult; readingTime(): Promise<number>; wordCount(): Promise<number>; } export interface RawContentProvider { rawContent(): string; } export interface PagerManager { current(): Promise<Pager>; setCurrent(current: Pager): void; paginator(): Promise<Pager>; paginate(groups: PageGroups): Promise<Pager>; } export interface Pagers extends Array<Pager> { } export interface Pager { pageNumber(): number; totalPages(): number; url(): string; pages(): Pages; pagers(): Pagers; first(): Pager; last(): Pager; hasPrev(): boolean; prev(): Pager | null; hasNext(): boolean; next(): Pager | null; } export interface PageGroups extends Array<PageGroup> { len(): number; } export interface PageGroup { key(): string; pages(): Pages; append(page: Page): Pages; } export interface Pages extends Array<Page> { len(): number; } export interface PageContext { posOffset(offset: number): Promise<Position>; } export interface Page extends RawContentProvider, PageSource, PageMeta, PagerManager, FileProvider, PageContext { name(): string; title(): string; kind(): string; isHome(): boolean; isPage(): boolean; isSection(): boolean; isAncestor(other: Page): boolean; eq(other: Page): boolean; layouts(): string[]; output(): PageOutput; truncated(): boolean; parent(): Page | null; pages(): Promise<Pages>; prevInSection(): Page | null; nextInSection(): Page | null; sections(langIndex: number): Pages; regularPages(): Promise<Pages>; regularPagesRecursive(): Pages; terms(langIndex: number, taxonomy: string): Promise<Pages | null>; isTranslated(): boolean; translations(): Pages; paths(): Path; isBundled(): boolean; scratch(): Scratch; } export declare const PageKind: { readonly PAGE: "page"; readonly HOME: "home"; readonly SECTION: "section"; readonly TAXONOMY: "taxonomy"; readonly TERM: "term"; readonly RSS: "rss"; readonly SITEMAP: "sitemap"; readonly SITEMAP_INDEX: "sitemapindex"; readonly ROBOTS_TXT: "robotstxt"; readonly STATUS_404: "404"; }; export type PageKindType = typeof PageKind[keyof typeof PageKind]; export interface File extends FileOverlap, FileWithoutOverlap { open(): Promise<any>; paths(): any; isBranchBundle(): boolean; baseFileName(): string; root(): string; type(): string; } export interface FileOverlap { relPath(): string; section(): string; isZero(): boolean; } export interface FileWithoutOverlap { filename(): string; dir(): string; ext(): string; logicalName(): string; baseFileName(): string; translationBaseName(): string; contentBaseName(): string; uniqueID(): string; fileInfo(): FileMetaInfo; } export interface Position { filename: string; lineNumber: number; columnNumber: number; offset: number; } export interface FrontMatter { path: string; lang: string; kind: string; title: string; weight: number; date: Date; terms: Record<string, string[]>; params?: Record<string, any> | undefined; } export interface FrontMatterParser { params: Record<string, any> | undefined; langSvc: LangService; taxonomySvc: TaxonomyService; } export interface Template { execute(templateName: string, data: any): Promise<string>; } export type PageBy = (p1: Page, p2: Page) => boolean; export interface PageSorter { len(): number; swap(i: number, j: number): void; less(i: number, j: number): boolean; } export type CollatorStringCompare = (getString: (page: Page) => string, p1: Page, p2: Page) => number; /** * OrdinalWeightPage - TypeScript equivalent of Go's OrdinalWeightPage interface */ export interface OrdinalWeightPage { weight(): number; ordinal(): number; page(): Page; owner(): Page; } /** * WalkTaxonomyFunc - TypeScript equivalent of Go's WalkTaxonomyFunc */ export type WalkTaxonomyFunc = (taxonomy: string, term: string, page: OrdinalWeightPage) => Promise<void>; //# sourceMappingURL=type.d.ts.map