Custom Output JavaScript, characters getting escaped

Hello.

I’m trying to create custom outputs and having some problem with the same.

I have the following in the config.toml:

[outputFormats]
  [outputFormats.Logic]
    baseName = "logic"
    mediaType = "application/javascript"
    path = "js"

[outputs]
  home = ["HTML", "Logic"]

Then, I have my JavaScript code in layouts/index.logic.js. In that file, I have a comparision operation like this: if (window.innerWidth < 640) {... /* rest of the code */ ...}, however, while exporting (and in server), that condition is getting converted to if (window.innerWidth &lt; 640) {... /* rest of the code */ ...} which is causing a syntax error in JavaScript. I tried changing the condition like if (window.innerWidth >= 640) {... /* rest of the code */ ...} and then, it worked but the next condition then got its characters escaped which were previously fine. I also tried creating another layout and added a simple code: if (1 > 2) {alert("hello")} and the characters didn’t get escaped here.

I’ve no clue what I’m doing wrong.

Here’s the repo: https://github.com/Hrishikesh-K/Portfolio/tree/v2

Adding isPlainText = true to this definition fixed it for me.

-j

1 Like

Oh yeah, I had tried it before but couldn’t get it to work so I thought it doesn’t work for this task and didn’t try it again.

Thanks for the help!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.