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

Permalink is not available for WebC files #52

Closed
pepelsbey opened this issue Jan 17, 2023 · 2 comments
Closed

Permalink is not available for WebC files #52

pepelsbey opened this issue Jan 17, 2023 · 2 comments

Comments

@pepelsbey
Copy link

pepelsbey commented Jan 17, 2023

I can’t seem to make WebC files use permalink to output files to a different location. You can checkout the sample barebone project or use these steps to reproduce.

upd: Ouch, this is probably an issue for the eleventy-plugin-webc, please move it

Steps to reproduce

1. Set up a sample project:

mkdir webc-permalink
cd webc-permalink
npm init -y
npm i --save-dev @11ty/eleventy@v2.0.0-canary.31 @11ty/eleventy-plugin-webc

2. Create eleventy.config.js with the following content:

const webc = require('@11ty/eleventy-plugin-webc');

module.exports = (config) => {
    config.addPlugin(webc);
};

3. Create page.liquid with the following content

---
permalink: 'index.html'
---
<p>11</p>

4. Run npx @11ty/eleventy
5. Rename page.liquid to page.webc
6. Run npx @11ty/eleventy

Expected behavior

File _site/index.html on steps 4 and 6

Actual behavior

Error on step 6: Cannot read properties of undefined (reading 'html')

Full error output
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] Cannot read properties of undefined (reading 'html') (via TypeError)
[11ty]
[11ty] Original error stack trace: evalmachine.<anonymous>:1
[11ty] index.html
[11ty]       ^
[11ty]
[11ty] TypeError: Cannot read properties of undefined (reading 'html')
[11ty]     at evalmachine.<anonymous>:1:7
[11ty]     at Script.runInContext (node:vm:141:12)
[11ty]     at Script.runInNewContext (node:vm:146:17)
[11ty]     at Object.runInNewContext (node:vm:306:38)
[11ty]     at Function.evaluateScript (/Users/pepelsbey/Desktop/webc-permalink/node_modules/@11ty/webc/src/moduleScript.cjs:62:25)
[11ty]     at Object.<anonymous> (/Users/pepelsbey/Desktop/webc-permalink/node_modules/@11ty/eleventy-plugin-webc/src/eleventyWebcTemplate.js:70:26)
[11ty]     at Template._renderFunction (/Users/pepelsbey/Desktop/webc-permalink/node_modules/@11ty/eleventy/src/TemplateContent.js:398:27)
[11ty]     at Template.renderPermalink (/Users/pepelsbey/Desktop/webc-permalink/node_modules/@11ty/eleventy/src/TemplateContent.js:447:19)
[11ty]     at async Template._getLink (/Users/pepelsbey/Desktop/webc-permalink/node_modules/@11ty/eleventy/src/Template.js:252:24)
[11ty]     at async Template.getOutputLocations (/Users/pepelsbey/Desktop/webc-permalink/node_modules/@11ty/eleventy/src/Template.js:302:16)
@zachleat zachleat transferred this issue from 11ty/webc Feb 10, 2023
@zachleat
Copy link
Member

Some overlap here with #32 (comment)

@zachleat zachleat added this to the Eleventy WebC Plugin v0.9.0 milestone Feb 22, 2023
@zachleat
Copy link
Member

I think we’ll change the failure case here to return the raw content. Right now we attempt to evaluate the permalink as JavaScript—but it just throws an error if that fails. I’d like to change that to be more straightforward/friendly in WebC v0.9.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants