blob: 8e488b62c4930588c666b1dccc5efc019a198385 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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}}
|