defaultHTMLDoc builds a standard html doc for orbit that also verifies the public directory if override data exits, then it will use that as a base for the HTML document
(override string)
| 101 | // defaultHTMLDoc builds a standard html doc for orbit that also verifies the public directory |
| 102 | // if override data exits, then it will use that as a base for the HTML document |
| 103 | func defaultHTMLDoc(override string) *htmlDoc { |
| 104 | base := &htmlDoc{Head: []string{`<meta charset="utf-8" />`}, Body: []string{}} |
| 105 | // we allow some special operations on the dom for debugging, currently supporting: |
| 106 | // - getting the contents of orbit manifest with the function "getManifest" |
| 107 | if CurrentDevMode == DevBundleMode { |
| 108 | base.Body = append(base.Body, `<script class="debug"> const getManifest = () => JSON.parse(document.getElementById("orbit_manifest").textContent) </script>`) |
| 109 | base.Body = append(base.Body, `<script class="debug" src="/p/hotreload.js"> </script>`) |
| 110 | base.Body = append(base.Body, fmt.Sprintf(`<script class="debug" id="debug_data" type="application/json">{ "hotReloadPort": %d }</script>`, hotReloadPort)) |
| 111 | } |
| 112 | // the html override that will provide a basis for the default html doc |
| 113 | if override != "" { |
| 114 | base.Body = append(base.Body, innerHTML(string(override), "<body>", "</body>")) |
| 115 | base.Head = append(base.Head, innerHTML(string(override), "<head>", "</head>")) |
| 116 | } |
| 117 | return base |
| 118 | } |
| 119 | // parseSlug will parse slugs from the incoming path provided initial slugKeys and return a map of the slugs |
| 120 | // in map[string]string form where the key is the slug name & value is the value as it appears in the path |
| 121 | func parseSlug(slugKeys map[int]string, path string) map[string]string { |