Home Manual Reference Source Test Repository

Function

Static Public Summary
public

ApiService(reptar: *): *

public

addCollections(reptar: *)

public

async addDataFiles(reptar: *)

public

addTemplateFilter(env: Object, name: string, func: Function, async: boolean)

Allow adding custom filters to the template engine.

public

async build(options: *)

public

async clean()

public

Exposed method to configure template engine.

public

Create checksum hash of input.

public

createCollection(name: *, collectionConfig: *, config: *, renderer: *): *

public

Create our Markdown engine.

public

This is a fast way to check if a file has frontmatter without reading all of its contents into memory.

public

futureDatesFilter(file: File, filterConfig: Object): boolean

Future date filter.

public

async init()

public

metadataFilter(file: File, filterConfig: Object): boolean

Metadata filter.

public

async new(args: *)

public

parse(str: string, options: Object): JSON

Parse a file with front matter.

public

Parse a YAML string into an object.

public

Given an obj it'll prune any properites that start with _.

public

async readDataFiles(dataPath: string): Object

Load all files in the given dataPath file and parse them into a JS object.

public

Render a piece of string from Markdown to HTML.

public

renderTemplate(env: Object, template: string, variables: object): string

Render a template with given context variables.

public

renderTemplateString(env: Object, str: string, variables: object): string

Render a string template with given context variables.

public

async serve()

public

Stringify an object to a YAML string.

public

stringify(str: string, data: Object): string

Stringify a document.

public

async watch(options: {})

Static Public

public ApiService(reptar: *): * source

import {ApiService} from 'reptar/lib/server/api.js'

Params:

NameTypeAttributeDescription
reptar *

Return:

*

public addCollections(reptar: *) source

import addCollections from 'reptar/lib/collection/index.js'

Params:

NameTypeAttributeDescription
reptar *

public async addDataFiles(reptar: *) source

import addDataFiles from 'reptar/lib/data-files.js'

Params:

NameTypeAttributeDescription
reptar *

public addTemplateFilter(env: Object, name: string, func: Function, async: boolean) source

import {addTemplateFilter} from 'reptar/lib/renderer/template.js'

Allow adding custom filters to the template engine.

Params:

NameTypeAttributeDescription
env Object

Nunjucks instance;

name string

Filter name.

func Function

Filter function.

async boolean

Whether the filter should be async.

See:

  • http://mozilla.github.io/nunjucks/api#custom-filters

public async build(options: *) source

import build from 'reptar/lib/cli/build.js'

Params:

NameTypeAttributeDescription
options *

public async clean() source

import clean from 'reptar/lib/cli/clean.js'

public configureTemplateEngine(options: Object): Object source

import {configureTemplateEngine} from 'reptar/lib/renderer/template.js'

Exposed method to configure template engine.

Params:

NameTypeAttributeDescription
options Object

Options object with following properties:

options.config Object

Config object.

options.paths string | Array<string>

Either an array of paths or a singular path that we can load templates from.

options.noCache boolean

Whether our template engine should cache its templates. Only set to true when in watch mode.

Return:

Object

Nunjucks instance.

public createChecksum(input: string): string source

import createChecksum from 'reptar/lib/checksum.js'

Create checksum hash of input.

Params:

NameTypeAttributeDescription
input string

Input to hash.

Return:

string

Example:

  '50de70409f11f87b430f248daaa94d67'

public createCollection(name: *, collectionConfig: *, config: *, renderer: *): * source

import {createCollection} from 'reptar/lib/collection/index.js'

Params:

NameTypeAttributeDescription
name *
collectionConfig *
config *
renderer *

Return:

*

public createMarkdownEngine(options: Object): Object source

import {createMarkdownEngine} from 'reptar/lib/renderer/markdown.js'

Create our Markdown engine.

Params:

NameTypeAttributeDescription
options Object

Configuration object.

Return:

Object

Returns markdown engine instance.

public fileHasFrontmatter(filePath: string): Promise<boolean> source

import {fileHasFrontmatter} from 'reptar/lib/parse/front-matter.js'

This is a fast way to check if a file has frontmatter without reading all of its contents into memory.

Params:

NameTypeAttributeDescription
filePath string

Path to file on the file system.

Return:

Promise<boolean>

Promise which resolves to true if the file has frontmatter.

public futureDatesFilter(file: File, filterConfig: Object): boolean source

import futureDatesFilter from 'reptar/lib/filter/future-date.js'

Future date filter. Checks if a file's date occurs in the future.

Params:

NameTypeAttributeDescription
file File

File we're checking.

filterConfig Object

Filter config object.

Return:

boolean

If the File's date is in the future

public async init() source

import init from 'reptar/lib/cli/init.js'

public metadataFilter(file: File, filterConfig: Object): boolean source

import metadataFilter from 'reptar/lib/filter/metadata.js'

Metadata filter. Checks if a file.data object matches all the configured filter options.

Params:

NameTypeAttributeDescription
file File

File we're checking.

filterConfig Object

Filter config object.

Return:

boolean

If the File matches the filterConfig object.

Example:

let filterConfig = {
  draft: true
};
file.data = {
  title: 'foo',
  draft: true
};
metadataFilter(filterConfig, file); // true

public async new(args: *) source

import new from 'reptar/lib/cli/new.js'

Params:

NameTypeAttributeDescription
args *

public parse(str: string, options: Object): JSON source

import {parse} from 'reptar/lib/parse/front-matter.js'

Parse a file with front matter.

Params:

NameTypeAttributeDescription
str string

String to parse.

options Object

Additional options.

Return:

JSON

JSON object.

public parse(str: string): Object source

import {parse} from 'reptar/lib/parse/yaml.js'

Parse a YAML string into an object.

Params:

NameTypeAttributeDescription
str string

String containing YAML information.

Return:

Object

Parsed YAML object.

public prunePrivateProperties(obj: Object, isPrivate: Function): Object source

import prunePrivateProperties from 'reptar/lib/server/prune-private-properties.js'

Given an obj it'll prune any properites that start with _.

Params:

NameTypeAttributeDescription
obj Object

POJO.

isPrivate Function

Function that prunes properties.

Return:

Object

Pruned object.

public async readDataFiles(dataPath: string): Object source

import {readDataFiles} from 'reptar/lib/data-files.js'

Load all files in the given dataPath file and parse them into a JS object. Then depending on the directory path structure and the name of the file set the files contents in that path on an object.

Params:

NameTypeAttributeDescription
dataPath string

Path to data files.

Return:

Object

public renderMarkdown(md: Object, str: string): string source

import {renderMarkdown} from 'reptar/lib/renderer/markdown.js'

Render a piece of string from Markdown to HTML.

Params:

NameTypeAttributeDescription
md Object

Markdown engine instance.

str string

String to parse.

Return:

string

Parsed Markdown.

public renderTemplate(env: Object, template: string, variables: object): string source

import {renderTemplate} from 'reptar/lib/renderer/template.js'

Render a template with given context variables.

Params:

NameTypeAttributeDescription
env Object

Nunjucks instance;

template string

Template name, excluding the extension.

variables object

Object of variables to interpolate in the template.

Return:

string

Rendered template.

public renderTemplateString(env: Object, str: string, variables: object): string source

import {renderTemplateString} from 'reptar/lib/renderer/template.js'

Render a string template with given context variables.

Params:

NameTypeAttributeDescription
env Object

Nunjucks instance;

str string

Template string.

variables object

Object of variables to interpolate in the template.

Return:

string

Rendered template.

public async serve() source

import serve from 'reptar/lib/cli/serve.js'

public stringify(obj: Object): string source

import {stringify} from 'reptar/lib/parse/yaml.js'

Stringify an object to a YAML string.

Params:

NameTypeAttributeDescription
obj Object

JavaScript object.

Return:

string

YAML document.

public stringify(str: string, data: Object): string source

import {stringify} from 'reptar/lib/parse/front-matter.js'

Stringify a document.

Params:

NameTypeAttributeDescription
str string

Content to append to YAML.

data Object

Data to convert to YAML and prepend to document.

Return:

string

Content with prepended YAML data.

public async watch(options: {}) source

import watch from 'reptar/lib/cli/watch.js'

Params:

NameTypeAttributeDescription
options {}
  • optional
  • default: {}