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

Frontmatter permalink + plaintext not working for txt file outputs #1221

Open
joeyfigaro opened this issue Mar 21, 2024 · 1 comment
Open

Comments

@joeyfigaro
Copy link
Sponsor

joeyfigaro commented Mar 21, 2024

  • Maizzle Version: 4.8.2
  • Node.js Version: 9.5.1 (Node v18.16.0)

Reproduction Repository


Problem

Using plaintext in a template's frontmatter where you've also specified a different destination filename via permalink doesn't produce a renamed txt file. It only applies the permalink configuration to the html output.

Steps

  1. Configure plaintext in your maizzle config to produce html and plaintext templates:
/** @type {import('@maizzle/framework').Config} */
module.exports = {
  build: {
    posthtml: {
      options: {
        decodeEntities: true,
        replaceQuote: false,
      },
    },
    browsersync: {},
    templates: {
      source: "src/templates",
      plaintext: {
        skipHtmlDecoding: true,
        destination: {
          path: "build_local",
          extension: "txt",
        },
      },
      destination: {
        path: "build_local",
      },
      omit: ["src/**/.archive/*"],
      assets: [
        {
          destination: "images",
          source: "src/images",
        },
      ],
    },
  },
};
  1. Add empty production config
/*
|-------------------------------------------------------------------------------
| Production config                       https://maizzle.com/docs/environments
|-------------------------------------------------------------------------------
|
| This is where you define settings that optimize your emails for production.
| These will be merged on top of the base config.js, so you only need to
| specify the options that are changing.
|
*/

// since the base config is merged in with this during production builds
// *and* our base config uses env vars for configuring, we don't need overrides for production
module.exports = {};
  1. Create a testing.html template and configure permalink and plaintext in its frontmatter:
---
permalink: permalink_testing_build/permalink-override.html
plaintext: true
---

<x-main>
  <h1>Permalink + Plaintext Reproduction</h1>
  <p>This template ends up in permalink_testing_build/permalink-override.html</p>
  <p>its plaintext version ends up living in build_local/testing.txt, though</p>
</x-main>
  1. Run a production build
    maizzle build production

  2. Observe permalink-override.html at the provided permalink path and a testing.txt file in the original build_local directory


Day late, but here's the repro I put together: https://github.com/joeyfigaro/maizzle-permalink-repro

Build results for .txt and .html outputs

image

@cossssmin
Copy link
Member

Thanks for the detailed report Joey, looks like a bug indeed. Will look into it and fix it 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants