теперь посты сортируются по времени создания, убрал суффикс .md в url постов

design
serr 2025-06-06 18:19:08 +03:00
parent e1e95848fa
commit 21ce6944f8
3 changed files with 4 additions and 5 deletions

View File

@ -57,8 +57,7 @@ func LoadPosts(dir string) (PostsMap, error) {
// Ошибка парсинга timestamp
log.Fatal(`post name parse error`)
}
link := fmt.Sprintf("/%s", name[lowLineIndex+1:])
link := fmt.Sprintf("/%s", strings.TrimSuffix(name[lowLineIndex+1:], ".md"))
posts[PostLink(link)] = createPost(link, html, timestamp)
}
return nil

View File

@ -7,7 +7,7 @@
<div>
{{ .data }}
<p>
<code>mod time: {{ .modTimestamp }}</code>
<code>create time: {{ .modTimestamp }}</code>
</p>
</div>
</main>

View File

@ -6,7 +6,7 @@
<main>
<div>
<p>
<code>posts sorted by last mod time</code>
<code>posts sorted by create time</code>
</p>
</div>
{{ range $ind, $post := .posts }}
@ -18,7 +18,7 @@
<a href="{{ $post.Link }}">read more</a>
</p>
<p>
<code>mod time: {{ $post.Timestamp }}</code>
<code>create time: {{ $post.Timestamp }}</code>
</p>
</div>
{{ end }}