sass-site/source/helpers/engines.ts
2023-04-21 21:01:43 +02:00

40 lines
1.0 KiB
TypeScript

import { Liquid } from 'liquidjs';
import markdown, { PluginWithOptions } from 'markdown-it';
import markdownItAttrs from 'markdown-it-attrs';
import markdownDefList from 'markdown-it-deflist';
import path from 'path';
import { renderPermalink } from './components/anchors';
/**
* Returns Markdown engine with custom configuration and plugins.
*
* @see https://github.com/markdown-it/markdown-it
* @see https://github.com/markdown-it/markdown-it-deflist
* @see https://github.com/arve0/markdown-it-attrs
*/
export const markdownEngine = markdown({
html: true,
typographer: true,
})
.use(markdownDefList)
.use(markdownItAttrs)
.use(require('markdown-it-anchor') as PluginWithOptions, {
permalink: renderPermalink,
});
/**
* Returns LiquidJS engine with custom configuration.
*
* @see https://liquidjs.com/
*/
export const liquidEngine = new Liquid({
root: [
path.resolve(__dirname, '../_includes/'),
path.resolve(__dirname, '../'),
],
extname: '.liquid',
strictFilters: true,
jsTruthy: true,
});