destack icon indicating copy to clipboard operation
destack copied to clipboard

Single Page Limitation

Open KnoDoctor opened this issue 4 years ago • 3 comments

I've been playing around with destack and was hoping it would be possible to add support for multiple pages. Currently it appears that all instances of the editor relate back to the same content limiting the use cases to a single landing page per nextjs project.

Great work so far and thanks in advance :)

Ps Happy to help out with any testing once this has been implemented 👍

KnoDoctor avatar Aug 22 '21 19:08 KnoDoctor

It should be possible to implement multiple pages, I might make a PR some time for it. We just have to make an array with all the elements, separated by pages in ./data/index.ts.

iojcde avatar Aug 22 '21 23:08 iojcde

@JcdeA I've been thinking about multiple pages and came to two possible implementations. Here are my thoughts on the two possibilities and a possible way to get it done!

Possible Solutions

  1. Have multiple json files in the data folder.

Structure:

  • data/default.json
  • data/contact.json
  • data/blog/first-post.json OR data/blog-first-post.json

👍 Backwards compatible 👍 Possibly easier to implement (not have to rewrite the JSON file each time a different page is changed) 👍 More close to what we have atm

  1. Have a single json file as we do now but instead of having an object to have an array. In that case each element in the array would represent a page.

Structure:

  • data/default.json

👍 Less files to commit in git

Implementation (Solution 1)

  1. We can get the pathname from the router and send it with handleEvents to handle function (so it knows where to save each page).
  2. At that point we can parse the pathname and save the page to that path eg. pathname = blog/first-post will save to a first-blog.json in folder name blog (or to a blog-first-blog.json file)
  3. We will have to change loadTemplate a little to account for multiple files.
  4. Lastly, we will need to support multiple files in getStaticProps so we have the props available when the site is statically built for production!

Note: An open question is what to do with dynamic-routes.

LiveDuo avatar Aug 23 '21 19:08 LiveDuo

Note: An open question is what to do with dynamic-routes.

At that point we could just create a custom server. It'll make a lot of things easier, without trying to cater around next.js's implementation. We could also provide some kind of simple cli to handle installing & configuration automatically.

However, this probably isn't the best, since next's image optimization won't properly work. We could backport it, though.

iojcde avatar Aug 27 '21 10:08 iojcde