Skip to content

Enhancement: frontmatter.js configuration #553

Description

@davidsneighbour

This would be a "nice to have" feature. Enabling us to have some Javascript create a configuration object that is then exported.

Use case: My local development server (preview server) has changing IP addresses and ports depending on the machine they run on. Having IP and port configuration in .env and then the javascript retrieve that via dotenv to create "frontMatter.preview.host": "http://192.168.1.201:1313" would increase the portability of the configuration.

Something like this:

require('dotenv').config(); // load environment variables from .env file

const envvars = {
  ip: process.env.IP_ADDRESS || '127.0.0.1', // use IP address from environment variable or default to localhost
  port: process.env.PORT || 3000 // use port from environment variable or default to 3000
};

const config = {
  // other configs
  "frontMatter.preview.host": "https://" + envvars.ip + ":" + envvars.port
  // other configs
}

module.exports = config;

I am not sure in how far this breaks the concept of extensions inside .frontmatter folders, but this would be only for the frontmatter.json file in the root of the project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions