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

Data file format won't handle Washington DC #73

Closed
mattstratton opened this issue Mar 7, 2016 · 6 comments
Closed

Data file format won't handle Washington DC #73

mattstratton opened this issue Mar 7, 2016 · 6 comments
Assignees
Labels

Comments

@mattstratton
Copy link
Member

Unless we name the city WashingtonDC, it will bail. It doesn't like the dashes.

@mattstratton
Copy link
Member Author

Actually this happens for any events that have a space in their city name (New York, Salt Lake City, etc).

Will need to add the "eventname" to the content files again, so that the files can find their datafile. Or possibly just remove all the spaces...

@bridgetkromhout
Copy link
Collaborator

We definitely need to be able to have cities with spaces and even commas in their display name. Is the issue with the event name for the URL? The URL historically hasn't matched the display name perfectly (see: New York, Denver, etc).

@mattstratton
Copy link
Member Author

It's an issue with the URL, and the problem is slightly goofy. In a previous version (i.e., before a lot of the code I wrote last night), every page in an event had in its frontmatter what was called the "event", i.e. "2016chicago", which referred to the datafile that it should use (in this case, it would refer to a datafile called 2016chicago.yml.

When working on some stuff last night, I "realized" that since every page already had the City and Year parameters in its frontmatter, I could just smush them together to discover what the datafile should be called. This of course worked fine because Chicago was my example :)

Initially I was just thinking we would have to add the "event" back to the frontmatter of all the pages, but I'm wondering now if I could extract the URL and split on it. This would definitely require Washington DC to have /events/2016-washingtondc/ as the url instead of /events/2016-washington-dc/, although there IS a way to keep a redirect for the latter since it already does exist.

@mattstratton mattstratton self-assigned this Mar 7, 2016
@mattstratton
Copy link
Member Author

OK, so the bug where the data files couldn't have spaces in them has gone away. Whew. So now I can refactor this to simply grab the event slug (2016-washington-dc, for example) and as long as the data file is named the same, everything is happy.

@mattstratton
Copy link
Member Author

So it was not nearly as simple as I had thought. The solution I proposed works great in templates, but not in shortcodes. And I use shortcodes a lot in the content files.

Currently the best workaround is to add the "event" parameter back to the frontmatter, and it is set to whatever the name of the datafile is (minus the yml) which would also then have to match the directory. The good part is that the bug where you couldn't use dashes in the yml file names seems to be gone, so this will be fine.

I don't like the workaround because I hate having people have to create more params than necessary in frontmatter on every page (it's very non DRY) but it will work for now.

Would be way nicer if we could whack as much frontmatter as possible, for migration purposes though.

@mattstratton
Copy link
Member Author

And, with more hackery and help from the esteemed @bep on the hugo forums, I did get it working with the paths and stuff. Hooray! Docs need updating but it seems to work.

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

No branches or pull requests

2 participants