michael / editable-website

A SvelteKit template for building CMS-free editable websites
https://editable.website
MIT License
1.34k stars 103 forks source link

Modifying multiple blog posts from one page #25

Open neeldhara opened 6 months ago

neeldhara commented 6 months ago

I need the testimonial-style editing UI that's available on the front page for blog articles. In particular, I am envisioning a "listing page" that lists all the blog titles in a table or list, and I'd like all of those titles to be editable.

It appears that the testimonials are saved as one JSON dump in the DB, while the articles get their individual entries/rows in the DB. I wasn't able to figure out how to adapt the code to suit my use case: I do want the articles/blog posts to retain their individual identities in the DB, but I'd like to be able to move them around (ideally this is a custom ordering that gets saved on the go, specific to the "listing page") and edit the titles simultaneously as well.

I am afraid I know nothing about how Svelte works, so sorry if this is somehow an obvious adaptation of the existing code.

PS. Off-topic, but many thanks for making this awesome template and workflow!

michael commented 6 months ago

Hey! Sorry for taking me sooo long to respond. The testimonials are "self-contained" within one page (the page just has one JSON data field in the database) while the blog posts (articles) are separate entites in the database, with fields for title, content (html) and some metadata.

See: https://github.com/michael/editable-website/blob/main/sql/schema.sql

You could easily come up with a listings table powered by a custom SQLite query. For simultaneous edits of titles you'd need to come up with some infrastructure, basically a rest endpoint that takes an array of article_id + title pairs and update them accordingly in the datbase (see api.js). You can basically achieve anything that can be done with Svelte and SvelteKit, but the template is only meant as a starting point, so I think if you want to do more advanced things, studying Svelte/SvelteKit is important.

Hope I wasn't too late and this is still helpful for you. All the best!