How to use the @frctl/nunjucks function in @frctl/nunjucks

To help you get started, we’ve selected a few @frctl/nunjucks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wellcometrust / wellcomecollection.org / cardigan / fractal-app.js View on Github external
import {Map} from 'immutable';
import filters from '../server/filters';
import extensions from '../server/extensions';
import {getEnvWithGlobalsExtensionsAndFilters} from '../server/view/env-utils';
import {createPageConfig} from '../server/model/page-config';
import statuses from './config/statuses';

const fractal = Fractal.create();
const root = serverDir('views');

// We need to set this up because Fractal doesn't allow us to specify our own
// nunjucks env, but rather uses config to set it up.
const nunjucksEnv = getEnvWithGlobalsExtensionsAndFilters(root, Map());
const extensionsWithEnv = extensions.map(Extension => new Extension(nunjucksEnv));

const nunjucks = Nunjucks({
  paths: ['./../server', root],
  filters: filters.toJS(),
  extensions: extensionsWithEnv.toJS(),
  globals: {
    pageConfig: createPageConfig({ title: 'Cardigan', inSection: 'explore', path: '/' })
  }
});
fractal.components.engine(nunjucks);

fractal.set('project.title', 'Design system');

fractal.components.set('path', root);
fractal.components.set('statuses', statuses);
fractal.components.set('default.status', 'wip');
fractal.components.set('ext', '.njk');
fractal.components.set('default.preview', '@preview');

@frctl/nunjucks

Nunjucks template adapter for Fractal.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis

Popular @frctl/nunjucks functions

Similar packages