UNPKG

@mdfriday/foundry

Version:

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

248 lines 6.35 kB
import { Page as ContentPage, PageSource, WalkTaxonomyFunc } from '../content/type'; import { ReadableStream } from 'stream/web'; import { Fs } from '../fs/type'; /** * Services - TypeScript equivalent of Go's Services interface * Main service aggregation interface */ export interface Services extends ContentService, TranslationService, ResourceService, LanguageService, FsService, URLService, ConfigService, SitemapService { } /** * ConfigService - TypeScript equivalent of Go's ConfigService */ export interface ConfigService { configParams(): Record<string, any>; siteTitle(): string; menus(): Record<string, Menu[]>; baseUrl(): string; } /** * ContentService - TypeScript equivalent of Go's ContentService */ export interface ContentService { walkPages(langIndex: number, walker: WalkFunc): Promise<void>; getPageSources(page: ContentPage): Promise<PageSource[]>; walkTaxonomies(langIndex: number, walker: WalkTaxonomyFunc): Promise<void>; globalPages(langIndex: number): Promise<ContentPage[]>; globalRegularPages(): ContentPage[]; searchPage(pages: ContentPage[], page: ContentPage): Promise<ContentPage[]>; getPageFromPath(langIndex: number, path: string): Promise<ContentPage | null>; getPageFromPathSync(langIndex: number, path: string): ContentPage | null; getPageRef(context: ContentPage, ref: string, home: ContentPage): Promise<ContentPage | null>; } /** * TranslationService - TypeScript equivalent of Go's TranslationService */ export interface TranslationService { translate(lang: string, translationID: string, templateData: any): Promise<string>; } /** * ResourceService - TypeScript equivalent of Go's ResourceService */ export interface ResourceService { getResource(path: string): Promise<Resource | null>; getResourceWithOpener(path: string, opener: OpenReadSeekCloser): Promise<Resource>; } /** * LanguageService - TypeScript equivalent of Go's LanguageService */ export interface LanguageService { defaultLanguage(): string; languageKeys(): string[]; getLanguageIndex(lang: string): number; getLanguageName(lang: string): string; } /** * SitemapService - TypeScript equivalent of Go's SitemapService */ export interface SitemapService { changeFreq(): string; priority(): number; generateSitemap(): Promise<{ urls: any[]; }>; } /** * Walk function types */ export type WalkFunc = (page: ContentPage) => Promise<void>; /** * Menu - TypeScript equivalent of Go's Menu interface */ export interface Menu { name(): string; url(): string; weight(): number; } /** * Resource interface */ export interface Resource { name(): string; readSeekCloser(): Promise<ReadableStream<Uint8Array>>; targetPath(): string; } /** * OpenReadSeekCloser - TypeScript equivalent of Go's io.OpenReadSeekCloser */ export type OpenReadSeekCloser = () => Promise<ReadableStream<Uint8Array>>; /** * FsService - TypeScript equivalent of Go's FsService */ export interface FsService { publishFs(): Fs; staticFs(): Fs; copyStaticFiles(from: Fs, to: Fs): Promise<void>; workingDir(): string; } /** * URLService - TypeScript equivalent of Go's URLService */ export interface URLService { baseUrl(): string; } /** * Author interface */ export interface Author { name(): string; email(): string; } /** * Compiler interface */ export interface Compiler { version(): string; environment(): string; } /** * Site interface - minimal implementation for dependencies */ export interface Site { currentLanguage: string; baseURL(): string; } /** * RefArgs interface - TypeScript equivalent of valueobject.RefArgs */ export interface RefArgs { path: string; outputFormat: string; } /** * RefSite interface for Ref dependencies */ export interface RefSite { home: { page: ContentPage; }; sitePage(target: ContentPage): Promise<SitePage>; } /** * SitePage interface with permalink methods */ export interface SitePage { relPermalink(): string; permalink(): string; path?(): string; } /** * PageWrapper interface */ export interface PageWrapper { unwrapPage(): ContentPage; } /** * Position interface for error reporting */ export interface Position { isValid(): boolean; toString(): string; } /** * Positioner interface */ export interface Positioner { position(): Position; } /** * Menus interface - TypeScript equivalent of valueobject.Menus */ export interface Menus { [key: string]: any; } /** * BaseURL interface */ export interface BaseURL { protocol(): string; host(): string; hostname(): string; port(): string; pathname(): string; toString(): string; getRoot(path: string): string; basePathNoTrailingSlash: string; } /** * URLSite interface */ export interface URLSite { baseURL(): BaseURL; absURL(input: string): string; relURL(input: string): string; url: any; languagePrefix(): string; isMultipleLanguage(): boolean; } /** * Language - TypeScript equivalent of Go's Language interface */ export interface Language { location(): string; collator(): Collator; } /** * Collator interface for string comparison */ export interface Collator { compare(a: string, b: string): number; } /** * URL - TypeScript equivalent of Go's URL interface */ export interface URL { base: string; absURL(input: string): string; relURL(input: string): string; urlize(uri: string): string; } /** * Template - TypeScript equivalent of Go's Template interface */ export interface Template { lookupLayout(names: string[]): Promise<{ preparer: TemplatePreparer; found: boolean; }>; executeWithContext(preparer: TemplatePreparer, data: any): Promise<string>; } /** * TemplatePreparer interface */ export interface TemplatePreparer { name(): string; execute(data: any): Promise<string>; } /** * ContentSpec - TypeScript equivalent of Go's ContentSpec */ export interface ContentSpec { preparePages(): Promise<void>; renderPages(handler: RenderHandler): Promise<void>; } /** * RenderHandler function type */ export type RenderHandler = (kind: string, sections: string[], dir: string, name: string, content: string) => Promise<void>; //# sourceMappingURL=type.d.ts.map