maizzle / framework

Quickly build HTML emails with Tailwind CSS.
https://maizzle.com
MIT License
1.24k stars 49 forks source link

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

Open joeyfigaro opened 7 months ago

joeyfigaro commented 7 months ago

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",
        },
      ],
    },
    },
    };
  2. 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 = {};


3. Create a `testing.html` template and configure `permalink` and `plaintext` in its frontmatter:
```html
---
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 commented 7 months ago

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

cossssmin commented 3 months ago

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