Skip to content

Commit

Permalink
fix: duplicate date indicators when navigating back
Browse files Browse the repository at this point in the history
  • Loading branch information
believer committed Sep 5, 2024
1 parent e6344ce commit 0eaa926
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
49 changes: 30 additions & 19 deletions views/feed.templ
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,37 @@ templ Feed(isAdmin bool, movies types.Movies, nextPage int, query string) {
data-movie={ strconv.Itoa(movie.ID) }
data-year={ movie.WatchedAt.Format("2006") }
data-month={ movie.WatchedAt.Format("January") }
_="init if my @data-year is not equal to @data-year of previous <li/>
then
make an <li.year-indicator/>
put it before me
then
make an <div.year/>
put the @data-year into its textContent
put it into the previous <li/>
end
_="
init if my @data-year is not really equal to @data-year of previous <li/> then
set dataYear to my @data-year
init if my @data-month is not equal to @data-month of previous <li/>
then
make an <li.month-indicator/>
put it before me
then
make an <div.month/>
put the @data-month into its textContent
put it at the end of the previous <li/>
end
"
if #{dataYear} does not exist then
make an <li.year-indicator/>
put my @data-year into its @id
put it before me
then
make an <div.year/>
put the @data-year into its textContent
put it into the previous <li/>
end
end
init if my @data-month is not really equal to @data-month of previous <li/> then
set y to my @data-year
set m to my @data-month
set ym to `${y}-${m}`
if #{ym} does not exist then
make an <li.month-indicator/>
put `${ym}` into its @id
put it before me
then
make an <div.month/>
put the @data-month into its textContent
put it at the end of the previous <li/>
end
end
"
>
<a
href={ templ.URL(fmt.Sprintf("/movies/%d", movie.ID)) }
Expand Down
14 changes: 7 additions & 7 deletions views/feed_templ.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0eaa926

Please sign in to comment.