Open stevenwoodson opened 1 year ago
@stevenwoodson i think you are right - i dug around more and after some superficial testing and logging i used pnpm patch
to only return the nested prop evaluatedString.returns
there and now all of my files are being written. nothing broke as far as i can tell.
since the whole package is apparently being pulled into @11ty/eleventy
(and also i don't know about further repercussions) i didn't create a PR.
I discovered a workaround that has worked for me, which involves utilizing JavaScript-rendered front matter. hope this helps.
---js
{
pagination: {
data: "pages",
size: 1,
alias: "static_page"
},
permalink: function(args) {
const { static_page } = args;
return `/${static_page.slug.current}/`;
}
}
---
When you use a string we do attempt to parse this as a dynamic script: https://github.com/11ty/eleventy-plugin-webc/blob/b5d39d55b330990280a9fea34dbf4fcd3d3d25a6/src/eleventyWebcTemplate.js#L75-L92
It’s may be more straightforward though to use ---js
as @derron1 suggested (or ---node
in 3.0 canaries) to use a permalink
function instead.
e.g. this WebC template:
---node
function permalink(data) {
}
---
(Originally posted in help on Discord @ https://discord.com/channels/741017160297611315/1129393478963568702)
Scenario
I'm running 11ty 2.0.1 and WebC 0.11.1.
I'm attempting to create a paginated WebC page template based on data (like https://www.11ty.dev/docs/pages-from-data/). The paginated data is being generated in a custom JS file in my _data folder such that I have access to data called
components.components
. My front matter in the WebC page template is:Problem
Currently, that page template is completely ignored, no errors but also no pages generated. When I remove permalink I start to get pages but they're in the dist folder as
dist/design-system/components-full-pages/1/index.html
,dist/design-system/components-full-pages/2/index.html
, etc.So I know the data is working and the pages are getting generated, there's just something wrong with the permalink syntax. I've also tried many other formats I found in the Github issues comments from https://github.com/11ty/eleventy-plugin-webc/issues/42#issuecomment-1374152043 and https://github.com/11ty/eleventy-plugin-webc/issues/36#issuecomment-1355594799 to no avail. Including:
and even
Everything I've tried either silently fails or gives me the duplicate output conflict error like this one
Debugging
After stepping away for a bit and coming back to try again, I tried to dig in a little deeper by debugging (both with IDE debugger and the 11ty debugger mode on). I converted my template from WebC to Nunjucks so I could compare the same thing with two different template languages. Results below
Nunjucks successful template debug output
WebC failed template debug output
Theory
I don't have enough context of all the internals but my theory is that
evaluatedString
linked below should be returning just the permalink string but is returning an object with the string underreturns
as well as anothercontext
object. https://github.com/11ty/eleventy-plugin-webc/blob/47bfcd1f000502fb47a3b481472a964e89eaedb0/src/eleventyWebcTemplate.js#L87So the parser doesn't know what to do with it and moves on silently with a final debug output of