mirror of
https://github.com/eiblog/eiblog.git
synced 2026-02-11 08:52:27 +08:00
fix: archive & serie
This commit is contained in:
@@ -12,4 +12,4 @@ COPY conf /app/conf
|
|||||||
EXPOSE 9001
|
EXPOSE 9001
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
CMD ["backend"]
|
CMD ["./backend"]
|
||||||
|
|||||||
27
pkg/cache/cache.go
vendored
27
pkg/cache/cache.go
vendored
@@ -322,20 +322,23 @@ func (c *Cache) readdArticle(article *model.Article, needSort bool) {
|
|||||||
}
|
}
|
||||||
// series
|
// series
|
||||||
for i, serie := range c.Series {
|
for i, serie := range c.Series {
|
||||||
if serie.ID == article.SerieID {
|
if serie.ID != article.SerieID {
|
||||||
c.Series[i].Articles = append(c.Series[i].Articles, article)
|
continue
|
||||||
if needSort {
|
}
|
||||||
sort.Sort(c.Series[i].Articles)
|
c.Series[i].Articles = append(c.Series[i].Articles, article)
|
||||||
PagesCh <- PageSeries // 重建专题
|
if needSort {
|
||||||
}
|
sort.Sort(c.Series[i].Articles)
|
||||||
|
PagesCh <- PageSeries // 重建专题
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// archive
|
// archive
|
||||||
y, m, _ := article.CreatedAt.Date()
|
y, m, _ := article.CreatedAt.Date()
|
||||||
for i, archive := range c.Archives {
|
for i, archive := range c.Archives {
|
||||||
if ay, am, _ := archive.Time.Date(); y == ay && m == am {
|
ay, am, _ := archive.Time.Date()
|
||||||
c.Archives[i].Articles = append(c.Archives[i].Articles, article)
|
if y != ay || m != am {
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
c.Archives[i].Articles = append(c.Archives[i].Articles, article)
|
||||||
if needSort {
|
if needSort {
|
||||||
sort.Sort(c.Archives[i].Articles)
|
sort.Sort(c.Archives[i].Articles)
|
||||||
PagesCh <- PageArchive // 重建归档
|
PagesCh <- PageArchive // 重建归档
|
||||||
@@ -509,11 +512,11 @@ func (c *Cache) regeneratePages() {
|
|||||||
buf.WriteString("\n\n")
|
buf.WriteString("\n\n")
|
||||||
for _, article := range series.Articles {
|
for _, article := range series.Articles {
|
||||||
//eg. * [标题一](/post/hello-world.html) <span class="date">(Man 02, 2006)</span>
|
//eg. * [标题一](/post/hello-world.html) <span class="date">(Man 02, 2006)</span>
|
||||||
str := fmt.Sprintf(`* [%s](/post/%s.html) <span class="date">(%s)</span>`,
|
str := fmt.Sprintf("* [%s](/post/%s.html) <span class=\"date\">(%s)</span>\n",
|
||||||
article.Title, article.Slug, article.CreatedAt.Format("Jan 02, 2006"))
|
article.Title, article.Slug, article.CreatedAt.Format("Jan 02, 2006"))
|
||||||
buf.WriteString(str)
|
buf.WriteString(str)
|
||||||
}
|
}
|
||||||
buf.WriteString("\n\n")
|
buf.WriteString("\n")
|
||||||
}
|
}
|
||||||
c.PageSeries = string(render.RenderPage(buf.Bytes()))
|
c.PageSeries = string(render.RenderPage(buf.Bytes()))
|
||||||
case PageArchive:
|
case PageArchive:
|
||||||
@@ -538,11 +541,11 @@ func (c *Cache) regeneratePages() {
|
|||||||
for i, article := range archive.Articles {
|
for i, article := range archive.Articles {
|
||||||
createdAt := article.CreatedAt.In(tools.TimeLocation)
|
createdAt := article.CreatedAt.In(tools.TimeLocation)
|
||||||
if i == 0 && gt12Month {
|
if i == 0 && gt12Month {
|
||||||
str := fmt.Sprintf(`* *[%s](/post/%s.html) <span class="date">(%s)</span>`,
|
str := fmt.Sprintf("* *[%s](/post/%s.html) <span class=\"date\">(%s)</span>\n",
|
||||||
article.Title, article.Slug, createdAt.Format("Jan 02, 2006"))
|
article.Title, article.Slug, createdAt.Format("Jan 02, 2006"))
|
||||||
buf.WriteString(str)
|
buf.WriteString(str)
|
||||||
} else {
|
} else {
|
||||||
str := fmt.Sprintf(`* [%s](/post/%s.html) <span class="date">(%s)</span>`,
|
str := fmt.Sprintf("* [%s](/post/%s.html) <span class=\"date\">(%s)</span>\n",
|
||||||
article.Title, article.Slug, createdAt.Format("Jan 02, 2006"))
|
article.Title, article.Slug, createdAt.Format("Jan 02, 2006"))
|
||||||
buf.WriteString(str)
|
buf.WriteString(str)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user