diesdasdigital / kirby-meta-knight

🔍 Meta Knight – SEO & Social Media Sharing Plugin for Kirby.
MIT License
108 stars 18 forks source link

feat: add more comprehensive preview implementation #59

Open jonaskuske opened 2 years ago

jonaskuske commented 2 years ago

After declaring default images/descriptions for SEO snippets using Page Models as described in #58, I noticed the preview snippets don't show these defaults. So I looked into that and found some more problems:

This is a refactor of the way data is passed to the preview snippets fixing the above as well as making sure that Page Model overrides are reflected in the previews.

All data is now loaded from the server on load. When there are changes to the page fields in the panel, those are reflected immediately (using the reactive values from the store), but on save server data is re-fetched to ensure consistency.




Considerations:

Because the panel can't call methods on the page model and the server can't see unsaved changes (they only exist in the browser's localStorage), there's no single source of truth during edits and some incorrect previews are still possible – though only during live editing, re-fetching after saves makes sure the previews eventually show up in the correct way, no matter what.

I think this approach is a good compromise given Kirby's current architecture. (afaik there are plans to move dirty/changed state to server as well, which would allow fixing these inaccuracies in the future)