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

Strip date from directory slugs when calculating page.fileSlug #2111

Merged

Conversation

AleksandrHovhannisyan
Copy link
Contributor

@AleksandrHovhannisyan AleksandrHovhannisyan commented Nov 20, 2021

Closes #1947

2021-11-20-my-awesome-post/index.md gets a slug of my-awesome-post rather than 2021-11-20-my-awesome-post.

@zachleat zachleat added the breaking-change This will have to be included with a major version as it breaks backwards compatibility. label Feb 18, 2022
@zachleat zachleat added this to the Eleventy 2.0.0 milestone Feb 18, 2022
@zachleat
Copy link
Member

Agree with this one but (as you said in #1947) it is a breaking change, so it will need to wait until 2.0—sorry!

@Brixy
Copy link

Brixy commented Mar 10, 2022

This would be great for a 2.0 release.

Sorry to barge in like this, but wouldn’t this (only) make sense if images and other assets were supported in the content folders—particularly for people coming from other SSGs like Hugo or Jekyll.

src/posts/
         /(2022-03-10-)some-title/
                    /index.html
                    /cover.png
                    /image.jpg
         /(2022-03-10-)good-title/
                    /index.html
                    /cover.png

This would resolve #1140 and many other issues, I guess.

Thanks, guys!

@AleksandrHovhannisyan
Copy link
Contributor Author

@zachleat Is there anything I can do to reduce the impact of merging this PR? Would it be better if we added a new flag to 11ty to opt into this behavior? If so, any pointers on where I should look for that and how to mock it in tests?

@zachleat zachleat merged commit bf79be5 into 11ty:master May 10, 2022
@zachleat
Copy link
Member

Merging this one! It’ll ship with 2.0.0-canary.10. Thank you @AleksandrHovhannisyan!

@zachleat zachleat removed the on-hold label May 10, 2022
zachleat added a commit that referenced this pull request May 10, 2022
@AleksandrHovhannisyan AleksandrHovhannisyan deleted the directory-slug-strip-out-date branch May 10, 2022 17:10
@zachleat zachleat changed the title Strip date from directory slugs Strip date from directory slugs when calculating page.fileSlug Jan 10, 2023
@zachleat
Copy link
Member

For future visitors curious about page.fileSlug, docs are here: https://www.11ty.dev/docs/data-eleventy-supplied/#page-variable

zachleat added a commit to 11ty/11ty-website that referenced this pull request Jan 17, 2023
@mahnunchik
Copy link

It would be helpful to strip date from filename if it is separated from title by space too.

myDir/2018-01-01 index.md => myDir
2018-01-01 myDir/index.md => myDir

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will have to be included with a major version as it breaks backwards compatibility.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

page.fileSlug and directory index files: date doesn't get stripped out
4 participants