Options
All
  • Public
  • Public/Protected
  • All
Menu

Takes care of actually injecting in the template the content from a given file and saves to disk the resulting page.

Hierarchy

  • TemplateToHtmlFiles

Index

Constructors

constructor

Properties

Private configOptions

configOptions: YassbConfig

the full YASSB config Object

Private dirSourcePath

dirSourcePath: string

Dir where to look for source files.

Private directiveFullString

directiveFullString: string

Full string of the directive in the template body to determine the source folder.

Private pathToTemplate

pathToTemplate: string

the full absolute path to the template

Private supportedFilesPaths

supportedFilesPaths: Array<string> = []

List of paths to all the cupported files found at dirSourcePath, including subdirectories.

Private templateContents

templateContents: string

Contents of the templte before content is injected.

Static regex

regex: RegExp = /<!--\s*generate-from-files\s*=\s*".+"\s*-->/g

Regex to match the comments to invoke the directive.

Methods

Private buildNewFileName

  • buildNewFileName(content: string, data: GrayMatterFile<string>["data"], pathToFile: string): string
  • Builds the file name for the file. If in Front Matter a slug is provided, that is preferred. If not, a slug is generated from the title in Front Matter. If no title is found in Front Matter, the title is extracted from the file. If not tile has been found, it falls back to the filename of the data source file.

    Parameters

    • content: string

      content of the generated page.

    • data: GrayMatterFile<string>["data"]
    • pathToFile: string

      the full path to the file bein processed.

    Returns string

    new file name .

Private buildOutPath

  • buildOutPath(pathToFile: string): string

Private createNewPageFromFile

  • createNewPageFromFile(pathToFile: string): void

Private extractCompnents

  • extractCompnents(text: string): void

init

  • init(): void
  • Inits template to html files. The operation is aborted if no directive is found in the template or no file is found in the dirSourcePath. Else, for each file found a new page is generated based on the template with the contents of the file.

    Returns void

    init

Private setDirSourcePath

  • setDirSourcePath(): void