Skip to content

Commit

Permalink
Inject doctype (#91).
Browse files Browse the repository at this point in the history
  • Loading branch information
jimafisk committed Jan 26, 2022
1 parent 59b53ab commit b5780a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions cmd/build/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ func createHTML(currentContent content) error {
renderedHTMLStr := renderedHTML.String()
// Convert the string to byte array that can be written to file system.
htmlBytes := []byte(renderedHTMLStr)
// Inject <!DOCTYPE html>
htmlBytes = bytes.Replace(htmlBytes, []byte("<html"), []byte("<!DOCTYPE html><html"), 1)
if Doreload {
// Inject live-reload script (stored in ejected core).
htmlBytes = bytes.Replace(htmlBytes, []byte("</body>"), []byte("<script type='text/javascript' src='/spa/ejected/live-reload.js'></script></body>"), 1)
Expand Down
18 changes: 12 additions & 6 deletions cmd/defaults/ejected/router.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,24 @@
let user;
onMount(async () => {
user = storage.get('gitlab_tokens');
user = storage.get('gitlab_tokens');
});
if (params
&& params.get('state') !== null
&& params.get('state') === session.get('gitlab_state')
) {
requestAccessToken(params.get('code'));
&& params.get('state') !== null
&& params.get('state') === session.get('gitlab_state')
) {
requestAccessToken(params.get('code'));
}
if (user && Date.now() > (user.created_at + user.expires_in) * 1000) {
requestRefreshToken();
requestRefreshToken();
}
// Inject <!DOCTYPE html>
onMount(async () => {
let doctype = document.implementation.createDocumentType('html', '', '');
document.doctype ? document.replaceChild(doctype, document.doctype) : document.insertBefore(doctype, document.childNodes[0]);
});
</script>

0 comments on commit b5780a2

Please sign in to comment.