-
Notifications
You must be signed in to change notification settings - Fork 0
Initial data when remixing the app #2
base: master
Are you sure you want to change the base?
Conversation
vogre
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Since we have the initial_template_data.json, I'm not quite sure why we need to duplicate it in constants.js? (This would only affect apps that remove the db entry, but I think in that case the defaults are better as blank?)
| export async function getHtmlFields() { | ||
| try { | ||
| const { html, css, js } = await get(editorPrefix); | ||
| const { html, css, js } = (await get(editorPrefix)) || initialData; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the code is repeating between backend/backend.js and backend/_handler.js - can it be extracted into a single location (e.g. so we don't define editorPrefix twice).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exported the editorPrefix and importing in handler - hope this is what you meant :)
| @@ -0,0 +1,7 @@ | |||
| export const initialData = { | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to repeat the initial data in constants.js? How about if someone deletes the entry what is returned an object that looks like { html: '', css: '', js: '' }?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe I'm doing something wrong, but the initial data template did not work for me. both of the files are in the project - any ideas?
|
@vogre Thank you for your comments 👍 Thanks. |
Set initial HTML & CSS when remixing the app