fix trending header

This commit is contained in:
orangix 2023-08-15 00:42:12 +02:00
parent be88c02d99
commit f099d12b0b
No known key found for this signature in database
GPG Key ID: C31D4A86601C8416
2 changed files with 36 additions and 20 deletions

View File

@ -4,7 +4,6 @@ import (
"fmt"
"io"
"net/http"
"os"
"strings"
"sync"
@ -69,7 +68,6 @@ func (client *Client) FetchTrending(section, sort, page string) ([]Submission, e
return []Submission{}, err
}
os.Stdout.Write(body)
data := gjson.Parse(string(body))
wg := sync.WaitGroup{}
@ -105,7 +103,5 @@ func (client *Client) FetchTrending(section, sort, page string) ([]Submission, e
wg.Wait()
client.Cache.Set(fmt.Sprintf("trending-%s-%s-%s", section, sort, page), posts, cache.DefaultExpiration)
// TODO: Cache trending
// client.Cache.Set(tag+sort+page+"-tag", tagData, cache.DefaultExpiration)
return posts, nil
}

View File

@ -18,23 +18,43 @@
<div class="flex flex-col items-center justify-center text-center">
<h2 class="text-2xl font-extrabold">Trending</h2>
</div>
<div class="flex flex-col sm:flex-row sm:justify-between">
<div class="flex flex-col">
{{#equal section "hot"}}
<a href="?section=hot"><b>Hot</b></a>
<a href="?section=new">New</a>
<a href="?section=top">Top</a>
<a href="?section=hot&sort={{sort}}"><b>Hot</b></a>
<a href="?section=new&sort={{sort}}">New</a>
<a href="?section=top&sort={{sort}}">Top</a>
{{/equal}}
{{#equal section "new"}}
<a href="?section=hot">Hot</a>
<a href="?section=new"><b>New</b></a>
<a href="?section=top">Top</a>
<a href="?section=hot&sort={{sort}}">Hot</a>
<a href="?section=new&sort={{sort}}"><b>New</b></a>
<a href="?section=top&sort={{sort}}">Top</a>
{{/equal}}
{{#equal section "top"}}
<a href="?section=hot">Hot</a>
<a href="?section=new">New</a>
<a href="?section=top"><b>Top</b></a>
<a href="?section=hot&sort={{sort}}">Hot</a>
<a href="?section=new&sort={{sort}}">New</a>
<a href="?section=top&sort={{sort}}"><b>Top</b></a>
{{/equal}}
</div>
<hr class="sm:hidden my-2" />
<div class="flex flex-col sm:items-end">
{{#equal sort "popular"}}
<a href="?section={{section}}&sort=popular"><b>Popular</b></a>
<a href="?section={{section}}&sort=newest">Newest</a>
<a href="?section={{section}}&sort=best">Best</a>
{{/equal}}
{{#equal sort "newest"}}
<a href="?section={{section}}&sort=popular">Popular</a>
<a href="?section={{section}}&sort=newest"><b>Newest</b></a>
<a href="?section={{section}}&sort=best">Best</a>
{{/equal}}
{{#equal sort "best"}}
<a href="?section={{section}}&sort=popular">Popular</a>
<a href="?section={{section}}&sort=newest">Newest</a>
<a href="?section={{section}}&sort=best"><b>Best</b></a>
{{/equal}}
</div>
</div>
</header>
<main>