-
From the Discord server I was pointed to ask this here instead: So, I was trying to define a conditional html structure based on the template language being used for specific blog posts (some are .md -for simple articles- and some .njk for articles with extra functionality). I could not find this data value so I created a shortcode that uses the But... by dumping all the values for page I could find a I wonder if is it safe to use this value? Is it documented and I just could not find where? FYI: I am using [email protected]. Thanks a lot. I'm new to 11ty but already a fan! Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@pdehaan refers to it in this discussion: #2768 He's great at responding to this kind of question. I'm guessing that it is safe to use, but I can't say for sure. |
Beta Was this translation helpful? Give feedback.
-
I imagine it's safe to use… Or at least still seemed to still be in Eleventy v3.0.0-alpha.5 (via npm i @11ty/eleventy@canary) -- which means it possibly wasn't Edge-template specific. grep "templateSyntax:" www-201/*/index.html
www-201/liquid/index.html: templateSyntax: 'liquid',
www-201/markdown/index.html: templateSyntax: 'liquid,md',
www-201/nunjucks/index.html: templateSyntax: 'njk', Where my src/liquid.liquid template looks like this: ---
title: LiquidJS
---
<pre>
{{ page | inspect }}
</pre> And my custom const { inspect } = require("node:util");
/**
* @param {import("@11ty/eleventy/src/UserConfig")} eleventyConfig
* @returns {ReturnType<import("@11ty/eleventy/src/defaultConfig")>}
*/
module.exports = function (eleventyConfig) {
eleventyConfig.addFilter("inspect", function (data) {
return inspect(data, { sorted: true, depth: 5 });
});
return {
dir: {
input: "src",
output: "www",
}
};
}; And the output from src/markdown.md (with the same contents as src/liquid.liquid above) looks like this: <pre>
{
date: 2024-03-21T23:14:30.052Z,
filePathStem: '/markdown',
fileSlug: 'markdown',
inputPath: './src/markdown.md',
outputFileExtension: 'html',
outputPath: 'www/markdown/index.html',
templateSyntax: 'liquid,md',
url: '/markdown/'
}
</pre> |
Beta Was this translation helpful? Give feedback.
I imagine it's safe to use… Or at least still seemed to still be in Eleventy v3.0.0-alpha.5 (via npm i @11ty/eleventy@canary) -- which means it possibly wasn't Edge-template specific.
Although curiously when I checked the templateSyntax for a .md template, it gave me "liquid,md" since it uses LiquidJS to preprocess Markdown files.
Where my src/liquid.liquid template looks like this:
And my custom
inspect
filter in my eleven…