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

Two tags that differ only in case cause a crash during build #1942

Closed
ijager opened this issue Aug 20, 2021 · 2 comments
Closed

Two tags that differ only in case cause a crash during build #1942

ijager opened this issue Aug 20, 2021 · 2 comments

Comments

@ijager
Copy link

ijager commented Aug 20, 2021

Two tags that differ only in case cause a crash during build. 11ty will make the tags lower case and try to make the same tag page twice, which causes an error.

For example tags:
adc and ADC
or Example and example

To Reproduce
Steps to reproduce the behavior:

  1. Start with the eleventy base blog: git clone git@github.com:11ty/eleventy-base-blog.git

  2. In first post add tag adc:

---
title: This is my first post.
description: This is a post on My Blog about agile frameworks.
date: 2018-05-01
tags:
  - adc
layout: layouts/post.njk
---
  1. In the second post add tag ADC
---
title: This is my second post.
description: This is a post on My Blog about leveraging agile frameworks.
date: 2018-07-04
tags:
  - ADC
layout: layouts/post.njk
---
  1. build the project:
npm install
npm run build

The output is:

$ npm run build

> eleventy-base-blog@5.0.2 build ~/eleventy-tag-bug
> eleventy

Problem writing Eleventy templates: (more in DEBUG output)
> Output conflict: multiple input files are writing to `_site/tags/adc/index.html`. Use distinct `permalink` values to resolve this conflict.
  1. ./tags.njk
  2. ./tags.njk

`DuplicatePermalinkOutputError` was thrown:
    (Repeated output has been truncated…)
        at TemplateMap.checkForDuplicatePermalinks (~/eleventy-tag-bug/node_modules/@11ty/eleventy/src/TemplateMap.js:547:13)
        at TemplateMap.cache (~/eleventy-tag-bug/node_modules/@11ty/eleventy/src/TemplateMap.js:308:10)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
        at async TemplateWriter._createTemplateMap (~/eleventy-tag-bug/node_modules/@11ty/eleventy/src/TemplateWriter.js:170:5)
        at async TemplateWriter.writeTemplates (~/eleventy-tag-bug/node_modules/@11ty/eleventy/src/TemplateWriter.js:203:5)
        at async TemplateWriter.write (~/eleventy-tag-bug/node_modules/@11ty/eleventy/src/TemplateWriter.js:254:25)
        at async Eleventy.write (~/eleventy-tag-bug/node_modules/@11ty/eleventy/src/Eleventy.js:743:13)
Copied 3 files / Wrote 0 files in 0.23 seconds (v0.12.1)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! eleventy-base-blog@5.0.2 build: `eleventy`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the eleventy-base-blog@5.0.2 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

It is trying to create this tag page twice: _site/tags/adc/index.html. And then errors.

Expected behavior

I would expect it to

  1. First convert tags to lower case,
  2. then merge/deduplicate,
  3. then generate tag pages

Environment:

  • OS and Version: MacOS 10.15.7
  • Eleventy Version 0.12.1
  • NodeJS v12.16.1
@ijager
Copy link
Author

ijager commented Aug 20, 2021

Oh my bad, I think it is actually a bug in https://github.com/11ty/eleventy-base-blog

Work around, add a to tag.toLowerCase in the tagList function:

  // Create an array of all tags
  eleventyConfig.addCollection("tagList", function(collection) {
    let tagSet = new Set();
    collection.getAll().forEach(item => {
      (item.data.tags || []).forEach(tag => {
        if (tag) {
          tag = ''+tag;
          tagSet.add(tag.toLowerCase());
        }
      })
    });

    return filterTagList([...tagSet]);
  });

@zachleat
Copy link
Member

#2462 is the new home base for this!

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

No branches or pull requests

2 participants