теперь посты сортируются по времени создания, убрал суффикс .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 // Ошибка парсинга timestamp
log.Fatal(`post name parse error`) log.Fatal(`post name parse error`)
} }
link := fmt.Sprintf("/%s", strings.TrimSuffix(name[lowLineIndex+1:], ".md"))
link := fmt.Sprintf("/%s", name[lowLineIndex+1:])
posts[PostLink(link)] = createPost(link, html, timestamp) posts[PostLink(link)] = createPost(link, html, timestamp)
} }
return nil return nil

View File

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

View File

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