Skip to content

Commit

Permalink
Write template in place to support custom input in file
Browse files Browse the repository at this point in the history
  • Loading branch information
rphillips-nz committed Oct 4, 2021
1 parent 1efdcfc commit 67e34e0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
15 changes: 15 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
const { mkdirSync, writeFileSync } = require('fs');
const { dirname, join } = require('path');
const { getInfo } = require('./src/generator.js');
const { normalisePath, stringifyJson } = require('./src/utility.js');

const input = process.env.CC_ELEVENTY_INPUT || '';

const infoTemplate = `---
eleventyExcludeFromCollections: true
permalink: /_cloudcannon/info.json
layout: null
---
{% ccInfo %}
`;

// defaultConfig should match the return value from https://www.11ty.dev/docs/config/
module.exports = function (eleventyConfig, defaultConfig = {}) {
const config = {
Expand All @@ -16,6 +26,11 @@ module.exports = function (eleventyConfig, defaultConfig = {}) {
}
};

// Create the template file for Eleventy to process and call the ccInfo tag
const templatePath = join(config.dir.input, 'cloudcannon/info.liquid');
mkdirSync(dirname(templatePath), { recursive: true });
writeFileSync(templatePath, infoTemplate);

eleventyConfig.addLiquidTag('ccInfo', function (liquidEngine) {
return {
parse: function () {},
Expand Down
6 changes: 0 additions & 6 deletions cloudcannon/info.liquid

This file was deleted.

File renamed without changes.

0 comments on commit 67e34e0

Please sign in to comment.