3.0.1 • Published 6 years ago

noddity-render-static v3.0.1

Weekly downloads
8
License
WTFPL
Repository
github
Last release
6 years ago

Render static HTML from a Noddity post.

Usage

const render = require('noddity-render-static')
const Butler = require('noddity-butler')
const Linkifier = require('noddity-linkifier')

const butler = new Butler(noddityUrlString | noddityRetrieval, levelUpDb, [options])
const linkifier = new Linkifier('#/myposts/')

const options = {
	butler: butler,
	linkifier: linkifier,
	data: {
		config: {
			configProperty: 'configValue'
		},
		arbitraryValue: 'lol'
	}
}

const html = await render('template.md', 'excellent-missive.md', options)

console.log(html)

htmlPromise = render(template, post, options)

  • template: either a Noddity post object, or file name of a post, to be used as the template into which the current post will be injected. Should have {{>current}} in it somewhere - this is where the current/main post will show up.
  • post: either a Noddity post object, or the file name of a post to be loaded
  • options: all the other arguments - butler: a Noddity Butler - linkifier: a Noddity Linkifier - data: Any properties on the data object will be made available to the templates. - convertToHtml: don't turn the markdown into html

Values accessible in Ractive expressions

  • postList: an array of post objects that have dates, ordered by date descending. Metadata is accessible on the object iself without having to use the metadata property
  • posts: an object whose keys are the post file names, and whose value is the post object. Right now the keys all have periods . stripped from them due to an issue with Ractive
  • removeDots: a function that takes a string as input and returns a version with dots . removed
  • current: the file name of the currently displayed post (the one specified in the url)

License

WTFPL

3.0.1

6 years ago

3.0.0

6 years ago

2.4.3

7 years ago

2.4.1

7 years ago

2.4.0

7 years ago

2.3.0

7 years ago

2.2.4

8 years ago

2.2.3

8 years ago

2.2.2

8 years ago

2.2.1

9 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.2.0

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago