johannschopplich / kirby-serp-preview

🔍 Kirby Panel plugin for search engine result page previews
https://kirbyseo.com
MIT License
17 stars 2 forks source link

Correct links on multilingual setups & case sensitivity on content keys #4

Closed grommasdietz closed 8 months ago

grommasdietz commented 8 months ago

Hi Dennis & Johann,

Thanks for your great plugin, nice to have the preview section as a standalone for custom workflows. Testing it for the first time I noticed that the preview url is showing the url with language code instead of its defined url. This leads to wrong urls, when the default url is not having the language code (and probably on any other definition). Like in this example:

return [
    'code' => 'de',
    'default' => true,
    'direction' => 'ltr',
    'locale' => [
        'LC_ALL' => 'de_DE'
    ],
    'name' => 'Deutsch',
    'url' => '/', // this one
];

Besides of that I noticed that the values of titleContentKey and descriptionContentKey have to be lowercase to work. Corrected that in the readme as well. Hope you are fine with this pull request, have a nice week!

johannschopplich commented 8 months ago

Thanks a lot for the PR and the effort behind it! Greatly appreciated.

johannschopplich commented 8 months ago

I have simplified the logic a lot. In the previous version, the model's URL was split and then joined again... Which can be circumvented by relying on Kirby's previewUrl field. This should include the correct language slug for multi-lang setups: https://github.com/johannschopplich/kirby-serp-preview/commit/e6aaaa29d9544af7e98c4b4505888a2f4f1fc983

Thanks again for your work. @grommasdietz Even if I don't merge this now, I appreciate a PR much more than an issue. It's so much easier moving forward.

johannschopplich commented 8 months ago

P.S.: If any issues occur with the latest implementation, feel free to reach out! 🙂

grommasdietz commented 8 months ago

Perfect, thank you!