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

compileOptions.permalink default changed from true to "raw" for Custom Template Syntaxes #2780

Closed
danburzo opened this issue Jan 28, 2023 · 4 comments
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility. bug: API design misstep Bugs caused by a bad default feature: 🤟 custom template languages eleventyConfig.addExtension API needs-documentation Documentation for this issue/feature is pending!

Comments

@danburzo
Copy link
Contributor

Operating system

macOS Ventura 13.1

Eleventy

^2.0.0-beta.2 / 1.0.2

Describe the bug

Found while poking around replacing the built-in Markdown engine (see #2777) that when setting a replacement with .addExtension('md', { ... }), as exemplified in the docs, any explicit permalinks present in the frontmatter of .md sources will get processed with the replacement engine, as observed a while back (#1019).

This is a problem because most Markdown processors (including marked and remark) will wrap a plain string such as /path/to/output/ in <p> tags, thus breaking the output. I'm not sure if the default engine skips the Markdown step or whether markdown-it simply doesn't wrap a plain string, but the issue only manifests when changing to a different engine.

Reproduction steps

Eleventy config:

const marked = require('marked');
module.exports = config => {
	config.addExtension("md", {
		compile: inputContent => data => marked.parse(inputContent)
	});
};

Content file:

---
title: Hello world
permalink: hello-world/
---

## Heading

Paragraph.

Running Eleventy outputs the HTML to _site / <p>hello-world / < / p>.

Expected behavior

If permalinks passing through the Markdown engine is inevitable, it would be great to get enough arguments to the compile() function for authors to be able to discern when to skip Markdown processing.

Reproduction URL

No response

Screenshots

No response

@danburzo
Copy link
Contributor Author

The workaround is to use the compileOptions.permalink option, which can be set to "raw" in case all permalinks in the project are static.

For dynamic permalinks, the solution depends on a fix to #2777, as they are not currently pre-processed with Liquid/Nunjucks when the Markdown template engine is swapped.

@zachleat zachleat added this to the Eleventy 3.0.0 milestone Feb 7, 2023
@zachleat zachleat added bug: API design misstep Bugs caused by a bad default breaking-change This will have to be included with a major version as it breaks backwards compatibility. and removed needs-triage labels Feb 7, 2023
@zachleat
Copy link
Member

zachleat commented Feb 7, 2023

I think a very good case can be made to make the default raw and encourage permalink callback functions in custom syntaxes by default!

@zachleat zachleat changed the title When replacing built-in Markdown engine, permalinks in frontmatter are processed as Markdown compileOptions.permalink default changed from true to "raw" Jun 11, 2024
@zachleat zachleat added the feature: 🤟 custom template languages eleventyConfig.addExtension API label Jun 11, 2024
@zachleat zachleat changed the title compileOptions.permalink default changed from true to "raw" compileOptions.permalink default changed from true to "raw" for Custom Template Syntaxes Jun 11, 2024
@zachleat zachleat added the needs-documentation Documentation for this issue/feature is pending! label Jun 11, 2024
@zachleat
Copy link
Member

Shipping with 3.0.0-alpha.13

@zachleat
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility. bug: API design misstep Bugs caused by a bad default feature: 🤟 custom template languages eleventyConfig.addExtension API needs-documentation Documentation for this issue/feature is pending!
Projects
None yet
Development

No branches or pull requests

2 participants