sveltia / sveltia-cms

Alternative to Netlify/Decap CMS. Fast, lightweight, Git-based headless CMS. Modern UX, first-class i18n support, open source & free. Made with Svelte.
MIT License
750 stars 34 forks source link

Offer UI feedback when config.yml incorrect, and other issue...? #17

Open privatemaker opened 1 year ago

privatemaker commented 1 year ago

I ran into another bug. After successfully doing the oauth dance, logging in, seeing request return 200

https://api.github.com/repos/user/my-repo/git/trees/a92c534exxx.......

Sveltia UI updates and says Loading Site Data... but errors with following:

Uncaught (in promise) TypeError: re(...).findLast is not a function
    ry https://example.org/admin/sveltia-cms.js:387
    ry https://example.org/admin/sveltia-cms.js:387
    xO https://example.org/admin/sveltia-cms.js:401
    update https://example.org/admin/sveltia-cms.js:439
    update https://example.org/admin/sveltia-cms.js:439
    hv https://example.org/admin/sveltia-cms.js:1
    He https://example.org/admin/sveltia-cms.js:1
    promise callback*db https://example.org/admin/sveltia-cms.js:1
    pv https://example.org/admin/sveltia-cms.js:1
    ctx https://example.org/admin/sveltia-cms.js:1
    fU https://example.org/admin/sveltia-cms.js:452
    s https://example.org/admin/sveltia-cms.js:1
    De https://example.org/admin/sveltia-cms.js:1
    h https://example.org/admin/sveltia-cms.js:439
    EA https://example.org/admin/sveltia-cms.js:439
    EA https://example.org/admin/sveltia-cms.js:439
    ab https://example.org/admin/sveltia-cms.js:1
    $/< https://example.org/admin/sveltia-cms.js:1
    He https://example.org/admin/sveltia-cms.js:1
    promise callback*db https://example.org/admin/sveltia-cms.js:1
    pv https://example.org/admin/sveltia-cms.js:1
    ctx https://example.org/admin/sveltia-cms.js:1
    jA https://example.org/admin/sveltia-cms.js:439
    s https://example.org/admin/sveltia-cms.js:1
    f4 https://example.org/admin/sveltia-cms.js:217
    jA https://example.org/admin/sveltia-cms.js:439
    ab https://example.org/admin/sveltia-cms.js:1
    $/< https://example.org/admin/sveltia-cms.js:1
    He https://example.org/admin/sveltia-cms.js:1
    W https://example.org/admin/sveltia-cms.js:1
    dU https://example.org/admin/sveltia-cms.js:452
    kU https://example.org/admin/sveltia-cms.js:452
    ev https://example.org/admin/sveltia-cms.js:1
    <anonymous> https://example.org/admin/sveltia-cms.js:452

When switching to decap-cms / netlify-cms.js I see the following error:

Error loading the CMS configuration
Config Errors:

'collections[1].fields[2].fields[0]' must have required property 'search_fields'
...

Check your config.yml file.

After fixing a few bugs in my config and properly loading the content in Decap, I still see above error in Sveltia.

What is also interesting is the config works fine when using localhost version.

kyoshino commented 1 year ago

You’re right, I haven’t implemented comprehensive validation in Sveltia CMS. I think having a config editor is rather a must because hand-written config files are very problematic, but the CMS still needs a validator to catch any issue. In the meantime, please use Decap as a validator 🀣

kyoshino commented 1 year ago

And yeah, I think your error is unrelated to search_fields because the property is unused (not yet supported) in Sveltia CMS. I’ll figure out how it could happen.

kyoshino commented 1 year ago

It’s a mystery at a glance. I thought it might be a browser compatibility issue because findLast is relatively new, but it doesn’t make sense if it works with the local environment. πŸ€”

privatemaker commented 1 year ago

I think having a config editor is rather a must because hand-written config files are very problematic

Agreed πŸ‘πŸ» that's the dream. One things i've wished for with Netlify/Decap (which diverges from a validation + editor) is that configs could be split into multiple files:

admin/
β”œβ”€β”€ index.html
β”œβ”€β”€ sveltia-cms.js
β”œβ”€β”€ config.yml
└── collections/
    β”œβ”€β”€ posts.yml
    β”œβ”€β”€ pages.yml
    └── widgets.yml

This increases number of requests on load, but the collections could be lazy loaded so it's not too bad. This would progressively enhance, while being backwards compatible, yet allow a dev to wrangle the hundreds of lines of YAML a bit better.