chriskthomas / linkfree-generator

A simple, free, open-source, and self-hosted alternative to linktree
https://linkfree.ckt.im
Apache License 2.0
140 stars 28 forks source link

Allow import of existing index.html files #1

Open chriskthomas opened 1 year ago

chriskthomas commented 1 year ago

Right now, there is no way to import an index.html file to automatically fill the fields. I would like to rectify this. It is fine if the importation is not backwards compatible. I am thinking that the simplest way to do it is to store all of the text fields in json as a comment at the bottom of the document.

This json could then be imported when the index.html file is imported.

chriskthomas commented 1 year ago

Likely depends on #4 as the import option could just set the localStorage keys and refresh.

officialxndr commented 1 year ago

Is this something we'd want to sort through the index and pull all related links to fill the fields? would the index.html be from someone's webpage or specifically built just for the auto import?

chriskthomas commented 1 year ago

Is this something we'd want to sort through the index and pull all related links to fill the fields?

Yes!

would the index.html be from someone's webpage or specifically built just for the auto import?

The later. My thought was that the page builder could insert an html comment after the closing html. We then put a json string inside the comment with the exact JavaScript object that we want for the import.

When the page is imported, this json in the comment is read and we can loop through the entries to fill the form.

chriskthomas commented 1 year ago

So, this consists of two steps:

  1. Add comment json object to api.php
  2. Add import option to index.js / index.php

Step 2 should probably be done in js and html without using php to process any inputs.