summaryrefslogtreecommitdiffstats
path: root/templates/admin/list.html
diff options
context:
space:
mode:
Diffstat (limited to 'templates/admin/list.html')
-rw-r--r--templates/admin/list.html50
1 files changed, 50 insertions, 0 deletions
diff --git a/templates/admin/list.html b/templates/admin/list.html
new file mode 100644
index 0000000..8e488b6
--- /dev/null
+++ b/templates/admin/list.html
@@ -0,0 +1,50 @@
+{{define "list-content"}}
+{{if .Posts}}
+<table>
+ <thead>
+ <tr>
+ <th>Tittel</th>
+ <th>Dato</th>
+ <th>Emne</th>
+ <th>Status</th>
+ <th></th>
+ </tr>
+ </thead>
+ <tbody>
+ {{range .Posts}}
+ <tr>
+ <td>{{.Title}}</td>
+ <td>{{.Date}}</td>
+ <td>
+ {{if .Tags}}
+ <div>
+ {{range .Tags}}<span class="tag">{{.}} </span>{{end}}
+ </div>
+ {{end}}
+ </td>
+ <td>
+ {{if .Draft}}<span>Ikke publisert</span>{{else}}<span>Publisert</span>{{end}}
+ </td>
+ <td>
+ <div>
+ <a href="/admin/{{.Slug}}">Rediger</a>
+ <button onclick=" deletePost('{{.Slug}}', '{{.Title}}' )">Slett</button>
+ </div>
+ </td>
+ </tr>
+ {{end}}
+ </tbody>
+</table>
+{{else}}
+<div>Ingen innlegg</div>
+{{end}}
+
+<script>
+ function deletePost(slug, title) {
+ if (!confirm('Slett "' + title + '"?')) return;
+ fetch('/admin/' + slug, { method: 'DELETE' })
+ .then(() => window.location.href = '/admin/')
+ .catch(err => alert('Kunne ikke slette: ' + err));
+ }
+</script>
+{{end}} \ No newline at end of file