-
-
Notifications
You must be signed in to change notification settings - Fork 495
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
11ty errors with "link.slice is not a function" #3472
Comments
I tried the different versions of 11ty, and found that with |
Happens for me too (fedora 40). Seems to be related to JSX, as for me it only happens when I have |
this could be an important clue, @tryoxiss, as I also add a template format in my config:
|
Definitely a bad error messaging issue. This is almost certainly due to a |
That would make sense, I do a few jank things with permalinks for backwards compatability. The most likely one is this: // `_source/en/en.11tydata.js` (My input dir is `_source`)
export default {
dir: "ltr",
locale: "en-CA",
tags: "en",
// layout: "base.njk",
// this is super complex and a bit spaghetti // (lol reading this after simplifying the code a lot makes this silly)
// basically:
//
// 1. Remove /en/
// 2. 11ty will complain when pagination is involved, since
// it tries to output many pages to the same file location.
// because we don't account for that
// (its all just /posts/index/ for example)
// 3. To make 11ty shut up we check if its paginated, and if
// so add the page number to the URL
// 4. but now /posts/ doesn't work, and I want it to. So now
// we remove /0/ if it exists.
//
// Possible TODO: Move this to another file so we can use this for other things?
permalink: function({ page, pagination }) {
// am I EVER going to localize any of this??? Good to have it *i guess* but still.
let newUrl = `${
page.filePathStem
// Make 'en' the default by excluding that segment
.replace("/en/", "/")
// If `index` shows anywhere, remove it.
// Example:
// /design/code/index
// to
// /design/code/
//
// I believe this gets both ones with and without trailing
// slashes properly
.replace("/index", "")
}/`;
// fileSlug? ionstead of filePathStem?
// Pagination handler moved to posts/index.webc
// console.log(`[cel] newurl for ${page.filePathStem} is ${newUrl}`)
return newUrl;
}
} I also set a permalink in JS frontmatter in ---javascript
{
dir: "ltr",
locale: "en-CA",
tags: "en",
testdata: [
"item 1",
"item 2",
"item 3",
],
pagination: {
data: 'testdata', // 'collections.post',
size: 2,
reverse: true,
generatePageOnEmptyData: true
},
// this is super complex and a bit spaghetti
// basically:
//
// 1. Remove /en/
// 2. 11ty will complain when pagination is involved, since
// it tries to output many pages to the same file location.
// because we don't account for that
// (its all just /posts/index/ for example)
// 3. To make 11ty shut up we check if its paginated, and if
// so add the page number to the URL
// 4. but now /posts/ doesn't work, and I want it to. So now
// we remove /0/ if it exists.
//
// Possible TODO: Move this to another file so we can use this for other things?
permalink: function({ page, pagination }) {
//let pageNumberString = if (pagination.pageNumber >= 0)
//if (pagination.pageNumber == 0) { return false }
//if (pagination.pageNumber >= 0) { return `/posts/` }
//return `/posts/${pagination.pageNumber}/`
let newUrl = `${page.filePathStem.replace("/en/", "/")}/`;
if (pagination)
{
newUrl = `${
page.filePathStem
.replace("/en/", "/")
.replace("index", pagination.pageNumber)
.replace("/0/", "/")
.replace("/1/", "/")
}/index.html`
}
//console.log(`[cel] newurl for ${page.filePathStem} is ${newUrl}`)
//console.log(`[cel] Implying default language for ${page.filePathStem}, its new url is ${newUrl}`)
return newUrl;
},
eleventyExcludeFromCollections: true,
}
--- I hope this helps, let me know if you need anything else! |
Hmm—I don’t see errors when trying to reproduce using a |
I get the same error when trying to upgrade from v2 to v3. The root cause appears to be the I have a bunch of code demos on my website that are like codepens. This is the folder structure. I shorten the url of these pages using a hash function in // demos.11tydata.js
const path = require("path");
const fs = require("fs-extra");
const utilities = require("../config/utilities");
module.exports = {
layout: "standalone.njk",
stylesheet: "styles.css",
permalink: (data) => {
let parentFolder = path.normalize(path.dirname(data.page.inputPath));
let id = utilities.generateId(parentFolder);
let url = `demos/${id}/`;
if (data.page.outputFileExtension !== "html") {
// dont write other files
url = false;
}
return url;
},
// yada yada
}; // eleventy.config.js
module.exports = function (config)
config.addTemplateFormats("js");
//yada yada
}; When I get a chance I can see if I can create a minimum viable case for this... |
similar to the above message, i experience this same error on 3.0 when i both:
notesit seems to be passing the function returned from the commenting out either the permalink workaroundi was able to workaround this issue by replacing the config.addExtension("scss", {
outputFileExtension: "css",
// override the glabal "permalink" data function to output the expeceted css file path instead.
async getData(inputPath) {
const permalink = path.parse(inputPath)
return {
permalink: path.format({
...permalink,
dir: "",
base: permalink.base.replace("scss", this.outputFileExtension),
}),
}
}, |
Hi, similar issue on my side when i use
in a 11tydata.js file (11ty 3.0.0 upgrade) Hope it helps to find the source of the issue |
Running into this too. Basically, I have an NJK file with this: Filter code:
I add a On v2.0.1 it correctly outputs the permalink string value - nothing like the above. Unfortunately I had to downgrade back to v2.0.1 since this is a total blocker. Let me know if I can help narrow it down. |
I was not not able to create a minimal test case for this. When I reduced the size of the codebase to the problematic area, the problem went away. It is a deeper issue. |
Hello everyone, I'm also having the same issue in my personal site project. I found out that this issue is happening when I add a JavaScript plugin to bundle JS assets with the I created this repo with a minimal setup to reproduce the issue. Removing this specific line, the issue goes away. I hope this helps to investigate the problem with permalink |
my use of
|
I also have an
and for me also, when I remove this line, the error goes away |
I see the issue now—thank you for the test case! There was a bug with how we were handling a Fix will be shipping with 3.0.1-alpha.1—thank you! |
Operating system
macOS Sonoma 14.5
Eleventy
3.0.0
Describe the bug
having just upgraded to 3.0.0, my
npx @11ty/eleventy --serve --port=8081
command produces the error:Reproduction steps
reproduction: I don’t know how to reproduce this
Expected behavior
expected behaviour: well, no error
Reproduction URL
No response
Screenshots
No response
The text was updated successfully, but these errors were encountered: