framework icon indicating copy to clipboard operation
framework copied to clipboard

Frontmatter permalink + plaintext not working for txt file outputs

Open joeyfigaro opened this issue 1 year ago • 2 comments

  • 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

joeyfigaro avatar Mar 21 '24 16:03 joeyfigaro

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

cossssmin avatar Mar 25 '24 17:03 cossssmin

This will be fixed in 5.0.0, unfortunately I don't have enough time to also fix it in v4.x sorry!

cossssmin avatar Jul 31 '24 10:07 cossssmin