UNPKG

@mdfriday/foundry

Version:

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

154 lines (153 loc) 4.53 kB
export interface PathProcessor { parse(component: string, path: string): Path; parseIdentity(component: string, path: string): StringIdentity; parseBaseAndBaseNameNoIdentifier(component: string, path: string): [string, string]; } export interface Path extends PathInfo, PathOperations, PathMetadata { unnormalized(): Path; } export interface PathInfo { component(): string; path(): string; name(): string; nameNoExt(): string; nameNoLang(): string; dir(): string; ext(): string; lang(): string; section(): string; sections(): string[]; container(): string; containerDir(): string; } export interface PathOperations { base(): string; baseNoLeadingSlash(): string; baseNameNoIdentifier(): string; nameNoIdentifier(): string; pathNoLang(): string; pathNoIdentifier(): string; pathRel(owner: Path): string; baseRel(owner: Path): string; trimLeadingSlash(): Path; identifier(index: number): string; identifiers(): string[]; } export interface PathMetadata { bundleType(): PathType; isContent(): boolean; isBundle(): boolean; isBranchBundle(): boolean; isLeafBundle(): boolean; isHTML(): boolean; disabled(): boolean; forBundleType(type: PathType): Path; } export interface StringIdentity { identifierBase(): string; } export declare enum PathType { File = 0, ContentResource = 1, ContentSingle = 2, Leaf = 3, Branch = 4 } export interface PathParserConfig { normalize?: boolean; replaceSpaces?: boolean; normalizer?: (path: string) => string; } export interface LowHigh { low: number; high: number; } export interface PathComponents { original: string; normalized: string; positions: PathPositions; identifiers: LowHigh[]; bundleType: PathType; disabled: boolean; component?: string | undefined; } export interface PathPositions { containerLow: number; containerHigh: number; sectionHigh: number; identifierLanguage: number; } export interface PathNormalizer { normalize(path: string): string; } export interface BasicPathNormalizer extends PathNormalizer { toLowerCase: boolean; replaceSpaces: boolean; } export interface PathValidator { validate(path: string): ValidationResult; } export interface ValidationResult { valid: boolean; errors: string[]; warnings: string[]; } export interface FileExtensionChecker { isContentExt(ext: string): boolean; isHTML(ext: string): boolean; hasExt(path: string): boolean; } export interface PathFactory { create(component: string, path: string, config?: PathParserConfig): Path; createFromComponents(components: PathComponents): Path; } export interface PathPool { get(): Path; put(path: Path): void; } export interface PathVisitor<T> { visit(path: Path): T; } export interface PathFilter { accept(path: Path): boolean; } export interface PathTransformer { transform(path: Path): Path; } export declare class PathError extends Error { readonly path?: string | undefined; constructor(message: string, path?: string | undefined); } export declare class PathParseError extends PathError { constructor(message: string, path?: string); } export declare class PathValidationError extends PathError { readonly validationErrors?: string[] | undefined; constructor(message: string, path?: string, validationErrors?: string[] | undefined); } export type PathResult<T> = { success: true; data: T; } | { success: false; error: PathError; }; export declare const PATH_CONSTANTS: { readonly CONTENT_EXTENSIONS: readonly [".md", ".markdown", ".mdown", ".mkd", ".mkdn", ".html", ".htm", ".xml"]; readonly HTML_EXTENSIONS: readonly [".html", ".htm"]; readonly INDEX_NAMES: readonly ["index", "_index"]; readonly PATH_SEPARATOR: "/"; readonly EXTENSION_SEPARATOR: "."; readonly LANGUAGE_SEPARATOR: "."; readonly SYSTEM_PATH_SEPARATOR: any; readonly COMPONENT_FOLDER_CONTENT: "content"; readonly COMPONENT_FOLDER_STATIC: "static"; readonly COMPONENT_FOLDER_LAYOUTS: "layouts"; readonly COMPONENT_FOLDER_ARCHETYPES: "archetypes"; readonly COMPONENT_FOLDER_DATA: "data"; readonly COMPONENT_FOLDER_ASSETS: "assets"; readonly COMPONENT_FOLDER_I18N: "i18n"; readonly normalizePath: (path: string) => string; }; export type HasExtFunction = (path: string) => boolean; export type NormalizePathFunction = (path: string) => string;