Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #22

Merged
merged 1 commit into from
Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const config = require("./config");
const prettier = require("prettier");
const liquidjs = require('liquidjs');
const nanomatch = require("nanomatch");
import config from "./config.js";
import { format } from "prettier";
import { defaultOperators } from 'liquidjs';
import nanomatch from "nanomatch";
import prettierXml from "@prettier/plugin-xml";

module.exports = function (eleventyConfig) {
export default function (eleventyConfig) {
Object.entries(config).forEach(([key, value]) =>
eleventyConfig.addGlobalData(key, value));

Expand All @@ -22,7 +23,7 @@ module.exports = function (eleventyConfig) {
eleventyConfig.setLiquidOptions({
...config.liquid,
operators: {
...liquidjs.defaultOperators,
...defaultOperators,
'+': (a, b) => a + b,
'mod': (a, b) => a % b,
'inCol': (elem, collection) =>
Expand Down Expand Up @@ -101,15 +102,16 @@ module.exports = function (eleventyConfig) {
});
return colCopy;
});
eleventyConfig.addTransform("prettier", (content, outputPath) => {
eleventyConfig.addTransform("prettier", async (content, outputPath) => {
const excluded = nanomatch(outputPath, config.prettierExclude);
if (excluded.length) { // empty if outputPath is not excluded
return content.trimStart();
}
const text = content.trim(); // prettier fails on leading newline
return prettier.format(text, {
return await format(text, {
...config.prettier,
filepath: outputPath,
plugins: [prettierXml]
});
});

Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
export default {
address: {
name: "Lars Bodewig",
careOf: "c/o Block Services",
Expand Down
Loading
Loading