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

.editorconfig's use of tabs instead of spaces causes eleventyNavigation to fail #171

Open
jayjansheski opened this issue Feb 25, 2024 · 4 comments

Comments

@jayjansheski
Copy link

jayjansheski commented Feb 25, 2024

First, thanks for 11ty!

Here's an issue I'm seeing: .editorconfig was changed to use tabs instead of spaces, but that seems to cause eleventyNavigation to fail. (Tabs are forbidden in YAML.)

Here's how the issue can be reproduced:

  1. git clone https://github.com/11ty/eleventy-base-blog.git
  2. cd eleventy-base-blog
  3. npm install
  4. Add books/index.md parallel to about/index.md
  5. Select and copy the contents of about/index.md to books/index.md, changing key to Books and order to 4. Optionally, change the markdown content. I'm using VSCode on macOS.
layout: layouts/base.njk
eleventyNavigation:
	key: "Books"
	order: 4
---
# Books

I am a person that reads stuff.
  1. npm start and visit the site at localhost:8080; notice Books doesn't show up in the menu.

Change the tabs before key and order to spaces and it'll work fine.

@fapdash
Copy link

fapdash commented Jun 1, 2024

Another example from this repo, changed spaces to tabs in the frontmatter of thirdpost.md (my editor inserts tabs automatically for indentation bc of the .editorconf):

---
title: This is my third post.
description: This is a post on My Blog about win-win survival strategies.
date: 2018-08-24
tags:
	- second tag
	- posts with two tags
---
Leverage agile frameworks to provide a robust synopsis for high level overviews. Iterative approaches to corporate strategy foster collaborative thinking to further the overall value proposition. Organically grow the holistic world view of disruptive innovation via workplace diversity and empowerment.

Error:

[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] 1. Having trouble reading front matter from template ./content/blog/thirdpost.md (via TemplateContentFrontMatterError)
[11ty] 2. end of the stream or a document separator is expected at line 7, column 2:
[11ty]          - posts with two tags
[11ty]      ^ (via YAMLException)
[11ty] 
[11ty] Original error stack trace: YAMLException: end of the stream or a document separator is expected at line 7, column 2:
[11ty]          - posts with two tags
[11ty]      ^
[11ty]     at generateError (/home/fap/repos/eleventy-base-blog/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
[11ty]     at throwError (/home/fap/repos/eleventy-base-blog/node_modules/js-yaml/lib/js-yaml/loader.js:173:9)
[11ty]     at readDocument (/home/fap/repos/eleventy-base-blog/node_modules/js-yaml/lib/js-yaml/loader.js:1545:5)
[11ty]     at loadDocuments (/home/fap/repos/eleventy-base-blog/node_modules/js-yaml/lib/js-yaml/loader.js:1588:5)
[11ty]     at load (/home/fap/repos/eleventy-base-blog/node_modules/js-yaml/lib/js-yaml/loader.js:1614:19)
[11ty]     at Object.safeLoad (/home/fap/repos/eleventy-base-blog/node_modules/js-yaml/lib/js-yaml/loader.js:1637:10)
[11ty]     at module.exports (/home/fap/repos/eleventy-base-blog/node_modules/gray-matter/lib/parse.js:12:17)
[11ty]     at parseMatter (/home/fap/repos/eleventy-base-blog/node_modules/gray-matter/index.js:109:17)
[11ty]     at matter (/home/fap/repos/eleventy-base-blog/node_modules/gray-matter/index.js:50:10)
[11ty]     at file:///home/fap/repos/eleventy-base-blog/node_modules/@11ty/eleventy/src/TemplateContent.js:201:13

Sadly I don't think .editorconf spec and implementations support mixing spaces and tabs in the same file type based on further rules?
@jayjansheski Since editorconf plugins usually don't replace existing indentations it's possible to "manually" add indentation with spaces, which works fine, no?

@jayjansheski
Copy link
Author

@fapdash yes, easy fix! But I don't understand why it was switched to tabs... seems like it breaks stuff with no upside other than maybe somebody's personal preference?

@fapdash
Copy link

fapdash commented Jun 1, 2024

@jayjansheski zachleat shared this link back then when the change happened: https://adamtuttle.codes/blog/2021/tabs-vs-spaces-its-an-accessibility-issue/, see e6dc55c#commitcomment-99554645

@jayjansheski
Copy link
Author

@fapdash I think that's a fine argument (the argument is that tabs allow people to choose their own indentation width) but if tabs break the build, it seems like an odd change to make. For anyone using an editor that respects .editorconfig (which is the whole point of .editorconfig) they would have to revert this change locally after checking the project out, which is possibly a bigger impediment to working with 11ty than squinting to see the indentation.

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