norska comes bundled with a set of methods directly available in your Pug
First of all,
lodash is available through the
_ variable. I find
well into Pug templates
By default, Pug has an
include statement, but no
include() methods, which
means you cannot include files dynamically (when the path is saved into
norska adds this missing piece of functionality. Just
include('path/to/file.svg') whenever you need to include another file.
Paths are considered relative to the
Also note that you can recursively include
.pug files, and they will be
correctly compiled and transformed to HTML.
markdown() methods converts any Markdown text into its HTML version. This
can prove incredibly useful when a simple
.md file is not enough and you need
to add some Markdown content as part of a more complex layout.
The optional second argument,
options can accept the following keys
|Prefix to add to all
src values, for when image links are relative
screenshot() methods returns the URL to an image representing a screenshot
of the specified page. If no argument is passed, it will use the current page.
norska uses it internally for building OpenGraph previews of pages, but you
can use it for any URL.
It internally uses microlink to take the screenshot.
As its name implies, the
link() method will return the shortest link to the
target. It will always return a relative link from the page calling it to the
Any target starting with a
/ is considered relative to the
otherwise it's handled as relative to the file doing the
This helper will return
true if the target is the same as the page calling the
method. It's smart enough to understand all variations of
target (with or
index.html, relative or absolute paths, etc).
Use this to style links to the current page, for example.
img() method can be used to get the URL of any image (either local or
options argument can be used to pass additional transformation to
If you just need to display an
<img> tag, you should use the
instead. It accepts the exact same arguments, but will also lazy load the image