From b5780a2de4332b0388084597c12b3ad4221fabae Mon Sep 17 00:00:00 2001 From: jimafisk Date: Wed, 26 Jan 2022 17:20:07 -0500 Subject: [PATCH] Inject doctype (#91). --- cmd/build/data_source.go | 2 ++ cmd/defaults/ejected/router.svelte | 18 ++++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/cmd/build/data_source.go b/cmd/build/data_source.go index c9e7be99..060b1462 100644 --- a/cmd/build/data_source.go +++ b/cmd/build/data_source.go @@ -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 + htmlBytes = bytes.Replace(htmlBytes, []byte(""), []byte(""), 1) diff --git a/cmd/defaults/ejected/router.svelte b/cmd/defaults/ejected/router.svelte index f7d36b93..bc9156e7 100755 --- a/cmd/defaults/ejected/router.svelte +++ b/cmd/defaults/ejected/router.svelte @@ -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 + onMount(async () => { + let doctype = document.implementation.createDocumentType('html', '', ''); + document.doctype ? document.replaceChild(doctype, document.doctype) : document.insertBefore(doctype, document.childNodes[0]); + }); +