-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
Error: Node not found: KeyName #23
Comments
I have the same issue with this which I cannot wrap my head round I'm trying to generate the breadcrumb trail to the current displayed page which I'm guessing is your exact use case too. I try to use
It keeps telling me that the node bearing the node |
Similar issue for me. I'm trying to generate breadcrumbs for a page generated in a global data file (pulling from an API). I define an Perhaps it's a data cascade issue - the parent page is built from a |
{% set navPages = collections.all | eleventyNavigationBreadcrumb(eleventyNavigation.key, { includeSelf: true }) %} works for me |
I also experienced this error and narrowed it down to using the I'm preparing a PR to allow the |
I run in the same issue. @noelleleigh could you describe your workaround more in detail, please? This is what I'm trying:
|
This isn't a workaround so much as a patch until my PR is accepted. ProjectHere's a simplified version of my project: .eleventy.js const eleventyNavigationPlugin = require("@11ty/eleventy-navigation");
module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(eleventyNavigationPlugin);
}; _includes/base.njk <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{title}}</title>
</head>
<body>
<img src="header.png" alt="My Site">
{% set navPages = collections.all | eleventyNavigationBreadcrumb(eleventyNavigation.key) %}
{{ navPages | dump | safe }}
{{content | safe}}
</body>
</html> 404.md ---
layout: base.njk
title: Not Found
eleventyExcludeFromCollections: true
eleventyNavigation:
key: "404"
---
Page not found ErrorWhen building, I get this error:
This is caused by this code for the eleventy-navigation/eleventy-navigation.js Lines 49 to 54 in 18cfb4d
When FixMy workaround was to fork eleventy-navigation and add an option to Change in forked plugin code: diff --git a/eleventy-navigation.js b/eleventy-navigation.js
index 7d0637c..46ffc0a 100644
--- a/eleventy-navigation.js
+++ b/eleventy-navigation.js
@@ -48,6 +48,10 @@ function getDependencyGraph(nodes) {
function findBreadcrumbEntries(nodes, activeKey, options = {}) {
let graph = getDependencyGraph(nodes);
+ if (options.handleMissing && !graph.hasNode(activeKey)) {
+ // Fail gracefully if the key isn't in the graph
+ return [];
+ }
let deps = graph.dependenciesOf(activeKey);
if(options.includeSelf) {
deps.push(activeKey); Then I replaced <body>
<img src="header.png" alt="My Site">
- {% set navPages = collections.all | eleventyNavigationBreadcrumb(eleventyNavigation.key) %}
+ {% set navPages = collections.all | eleventyNavigationBreadcrumb(eleventyNavigation.key, {handleMissing: true}) %}
{{ navPages | dump | safe }}
{{content | safe}}
</body> |
Fixed by #39. Thank you! Shipping with 0.3.3 |
Thanks for this thread, for casual viewers, note that the released key name in 3.3+ is: 'allowMissing' (not 'handleMissing') |
Error Output
Template File
QuestionWhat or where should I look? |
@inetbiz Sounds like you might have forgot to (next time please file a new issue so folks don’t get emails on these old issues!) |
Hi, thank you for this fix. I encountered the issue, which was indeed fixed by the allowMissing flag ;) In my case, it turned out that my page hierarchy was wrong. On the top of the navigation tree, I had a reference to a non existing parent, which caused the error. Because of it, all pages in the faulty branch are missing the breadcrumbs. Additional symptom is the this branch did not appear in the content generated by the eleventyNavigationToHtml filter neither. Hope this helps |
Exhausted all thoughts on what could be causing this, and wondering if anyone else has a hint.
My front matter has this:
I've tested this and it works fine, returning all children, including Alphabet:
But this breaks & gives me "Error: Node does not exist: Alphabet":
Sadly its the latter that I'm after, for my breadcrumb navigation.
Thanks in advance if anyone has any useful suggestions or ideas why this could be breaking.
The text was updated successfully, but these errors were encountered: