Closed nilshoerrmann closed 2 years ago
I've seen there this note in the readme:
// Absolut path for location of redirects config
// Default: site/config/retour.yml
// (allows for yml and json files/formats)
It might be a good idea to disallow YAML completely for the redirects and always store in JSON format to prevent this issue.
As the errors occured on save and reading seems to be fine: maybe Retour could automatically convert retour.yml
to retour.json
if the later does not exist yet.
I've tried validating the YAML formatted by Prettier that Retour was not able to process correctly and it seems to be valid (the one with the empty line). So this might be a problem of the Kirby core as well when writing YAML.
Since I am simply using Kirby's Data
class to read and write the yaml file, I think this might be an issue of the Spyc
library that Kirby is using for YAML. But nothing that I would be able to fix for this plugin then.
It might be a good idea to disallow YAML completely for the redirects and always store in JSON format to prevent this issue.
Won't do this since people have existing YAML setups and some prefer it due to easier readability.
I am also not a big fan of reading YAML and then magically saving as JSON without the user knowing. I think a manual conversion from YAML to JSON should be the preferred way for users that are facing issues with a config file in YAML format.
We've got a list of old URLs from a legacy CMS that we'd like to add to Retour. Because of the number of routes, creating
retour.yml
in the editor was easier than using the interface. The editor formats YAML using Prettier resulting in the following example file:Everything load perfectly fine in the Retour interface. But after adding a new entry via the panel, the formatting changes on save:
When I now adjust any redirect in my editor, Prettier formats the content again (note the empty line that's added for whatever reason):
Saving again from the panel and now all the data is corrupted (check the gibberish in the second definition):