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
809 stars 36 forks source link

Local repository not recognizing posts from remote #35

Closed refact0r closed 9 months ago

refact0r commented 1 year ago

I have a Sveltekit static site with Sveltia in a Github repo deployed on Netlify. The deployed version of Sveltia correctly recognizes all posts. However when I run the site in development mode locally and select "Work with local repository", Sveltia only displays the posts that were created using the local version. The posts that were pulled from the Github repo are not shown.

kyoshino commented 1 year ago

Thanks for flagging the issue! Listing files will be done differently when using the local workflow.

Is this your site in question? https://github.com/refact0r/forgotten-europe-website

refact0r commented 1 year ago

Yes that is the site I am working on.

kyoshino commented 1 year ago

Okay, will check it out later!

kyoshino commented 1 year ago

I’m running your SvelteKit project locally. I see all the content — 2 blog posts, 5 interviews and 7 images — on Svelta CMS. Not sure what’s going on 🤔 Did you reload /admin in your browser after fetching the content from remote?

refact0r commented 1 year ago

Yes, I have tried reloading the page, clearing site data, restarting dev server. It seems that all images from remote load correctly, but blog posts, news articles, and the 1 interview not created locally do not show up.

kyoshino commented 1 year ago

Hmm, will check again.

zanhk commented 9 months ago

Got same problem in my repo https://github.com/zankhq/astro-starter/tree/chore/sveltia

kyoshino commented 9 months ago

@zanhk Are you on Windows? To be honest, I’ve tested the local repo editing only on macOS, so there may be permission issues or something.

To clarify, changes made to local files are not automatically reflected in the CMS interface; you’ll need to reload the app to see any new external changes. Automatic updates will be possible in the (near) future when the new FileSystemObserver API is implemented in browsers.

zanhk commented 9 months ago

@kyoshino yes I m on windows, it asked for folder permissions and I gave it the whole repo folder access.

I've opened the admin ui with existing file (from the repo that was previously using decap cms) and I did not see them, I've created a new entry and it created the file succesffully, after restarting I could only see the created file and not the previous one.

As you mentioned could probably be a permission issue, I ll take a look when I ll have sometime but if it's only a local problem doesn't seem a big deal as it's always possibile to change those files directly, just mentioned as I was testing out the repo.

kyoshino commented 9 months ago

Let me check with my Windows virtual machine later today.

kyoshino commented 9 months ago

Testing on Windows 10 but cannot reproduce the issue. 🤔 🤔 🤔 Fetch the origin, reload the CMS, and then remote changes show up in the admin. I suspected it might be related to file paths because Windows uses a backslash as the separator, but not sure.

Has anyone noticed any difference between a file created locally and a file created remotely?

kyoshino commented 9 months ago

Or perhaps line breaks, because Windows uses CR+LF while macOS/Linux/web uses LF.

kyoshino commented 9 months ago

Now I could reproduce the issue. Figuring out why!

kyoshino commented 9 months ago

So line breaks are the culprit. 🤖 This kind of issue can be avoided by configuring the .gitattributes and .editorconfig files on a repository, but anyway, the problem could be easily solved in the CMS.

kyoshino commented 9 months ago

The fix is in! Sorry to take this long 🙇🏼

zanhk commented 9 months ago

@kyoshino Awesome

zanhk commented 9 months ago

@kyoshino This works as well!