place scripts in index as template

This commit is contained in:
Florian Hoss 2022-04-04 08:06:09 +02:00
parent 48813dc129
commit b5f1ccf98d
3 changed files with 21 additions and 12 deletions

View file

@ -8,11 +8,12 @@
<body> <body>
{{template "navbar" .}} {{template "navbar" .}}
<div class="position-absolute top-50 start-50 translate-middle"> <div class="position-absolute top-50 start-50 translate-middle text-center">
<div>Welcome</div> <div>Welcome to the Super Save Store.</div>
<div>Login to continue.</div>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> {{template "scripts" .}}
</body> </body>
</html> </html>
@ -24,14 +25,17 @@
<link rel="mask-icon" href="../static/icons/safari-pinned-tab.svg" color="#5bbad5"> <link rel="mask-icon" href="../static/icons/safari-pinned-tab.svg" color="#5bbad5">
<meta name="msapplication-TileColor" content="#da532c"> <meta name="msapplication-TileColor" content="#da532c">
<meta name="theme-color" content="#ffffff"> <meta name="theme-color" content="#ffffff">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
{{end}} {{end}}
{{define "navbar"}} {{define "navbar"}}
<nav class="navbar navbar-expand-md navbar-light bg-light"> <nav class="navbar navbar-expand-md navbar-light bg-light">
<div class="container-fluid"> <div class="container-fluid">
<a class="navbar-brand" href="/">SuperSave</a> <a class="navbar-brand" href="/">SuperSave</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"> <button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span> <span class="navbar-toggler-icon"></span>
</button> </button>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
@ -46,4 +50,10 @@
</div> </div>
</div> </div>
</nav> </nav>
{{end}} {{end}}
{{define "scripts"}}
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin="anonymous"></script>
{{end}}

View file

@ -24,6 +24,6 @@
</form> </form>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script> {{template "scripts" .}}
</body> </body>
</html> </html>

View file

@ -22,9 +22,8 @@
<button onclick="registerUser()" class="btn btn-primary">Submit</button> <button onclick="registerUser()" class="btn btn-primary">Submit</button>
</div> </div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" {{template "scripts" .}}
crossorigin="anonymous"></script>
<script> <script>
function registerUser() { function registerUser() {
const username = document.getElementById("username").value; const username = document.getElementById("username").value;
@ -42,4 +41,4 @@
} }
</script> </script>
</body> </body>
</html> </html>