Filters
LFP Docs exposes a couple of new filters. Filters are a language feature of Eleventy's template languages Nunjucks and Liquid.
absolute
absolute constructs a valid absolute URL from a given relative path and the value for baseUrl set in the project's configuration.
| Argument | Type |
|---|---|
| input | string |
getNextByUrl
Gets the next item in a list of object's, where each object contains a key url with a string value, next meaning the item with index idx + 1. Returns false if idx === collection.length.
Used in each page's pagination navigation component.
| Argument | Type |
|---|---|
| collection | Record<string, unknown & { url: string}> |
| url | string |
getPreviousByUrl
Gets the previous item in a list of object's, where each object contains a key url with a string value, previous meaning the item with index idx - 1. Returns false if idx === 0.
Used in each page's pagination navigation component.
| Argument | Type |
|---|---|
| collection | Record<string, unknown & { url: string}> |
| url | string |
headings
Naïvely counts headings in Markdown source. Use like this:
{% set hasHeadings = page.rawInput | headings %}
| Argument | Type |
|---|---|
| input | string |
hostname
Returns the hostname segment of a given URL. Throws error, if URL is invalid or malformed.
| Argument | Type |
|---|---|
| url | string |
minifyInlineCSS
Accepts a string consisting of valid CSS and returns <style><!-- minified input --></style>. Uses lightningcss under the hood.
| Argument | Type |
|---|---|
| input | string |
packageLink
Creates a set of HTML elements with the package provider's logo. Used to render the default theme's package link in the header menu. Currently supported package providers:
- npm
If no approbriate provider available, defaults to simple text link.
| Argument | Type |
|---|---|
| url | string |
renderMd
Uses the theme's default Markdown rendering instance (that is also used for parsing main content) and returns Markdown block statements. See renderMdInline for inline rendering.
| Argument | Type |
|---|---|
| input | string |
renderMdInline
Uses the theme's default Markdown rendering instance (that is also used for parsing main content) and returns Markdown inline statements (without surrounding p-tags). See renderMd for block rendering.
| Argument | Type |
|---|---|
| input | string |
sourceCodeLink
Creates a set of HTML elements with the package provider's logo. Used to render the default theme's repository link in the header menu. Currently supported source control providers:
- Codeberg
- GitHub
- Gitlab
If no approbriate provider available, defaults to simple text link.
| Argument | Type |
|---|---|
| url | string |