11ty/eleventy-navigation

Error: Node does not exist: en_demo

Dexus opened this issue · 0 comments

Dexus commented
#/index.njk
---
layout: false
permalink: /index.html
title: "Layout"
locale: en
dir: ltr
eleventyNavigation:
  key: en
  title: Start Page
---
#/test2.njk
---
layout: false
permalink: /test2.html
title: "Layout"
locale: en
dir: ltr
eleventyNavigation:
  key: demo
  title: Demo
---
/*eleventryComputed.js*/
module.exports = {
  locale: (data) => {
    return data.locale || 'en'
  },
  eleventyNavigation: {
    key: (data) => {
      if (data.eleventyNavigation.key || data.translationKey) {
        return (
          data.locale +
          '_' +
          (data.eleventyNavigation.key || data.translationKey)
        )
      }

      let tk = data.page.inputPath.split('/').slice(3).join('/')
      return tk
    },
    title: (data) => data.eleventyNavigation.title || data.title,
    parent: (data) => {
      if (data.eleventyNavigation.parent || data.parent) {
        return (
          data.locale + '_' + (data.eleventyNavigation.parent || data.parent)
        )
      }
      return data.locale
    },
  },
  sitemap: (data) => {
    data.priority = data.priority || 0.5
    data.changefreq = data.changefreq || 'monthly'
    return ''
  },
  translationKey: (data) => {
    // remove "./src/{{locale}}" from path

    if (data.translationKey) {
      return data.translationKey
    }
    let tk = data.page.inputPath.split('/').slice(3).join('/')
    return tk
  },
}