Skip to content

Run yaml files through template engine? #1859

Answered by pdehaan
madsem asked this question in Q&A

You must be logged in to vote

Possibly a better way to do this, but what about just putting the config in a JavaScript/JSON object and then convert to YAML to avoid having to think about indenting.

// ./src/config.11ty.js

const yaml = require("js-yaml");

class Config {
  get data() {
    return {
      permalink: "/admin/config.yml",
      eleventyHideFromCollections: true,
      hide_from_sitemap: true,
    };
  }

  async render(data) {
    const backend = {
      site_url: data.site?.url,
      display_url: data.site?.url,
      branch: "master",
      name: "git-gateway",
      publish_mode: "editorial_workflow",
    };
    // If this is a development build, adjust a few more properties.
    if (process.env.ELEV…

Replies: 1 comment 4 replies

You must be logged in to vote
4 replies
@madsem

@pdehaan

pdehaan Jun 25, 2021
Collaborator

@madsem

@pdehaan

pdehaan Jun 25, 2021
Collaborator

Answer selected by madsem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants