Add expiryDate 2 years after last theme update/version

This should be a clear indication that the theme isn't up to date.
This commit is contained in:
Bjørn Erik Pedersen committed 2022-09-06 19:21:19 +02:00
1 parent be3a8d9916
commit dfaa658e27
2 files changed
+21 -4

No files matched your search

+6
View File
@@ -7,6 +7,12 @@ A collection of themes created by the Hugo community. Builds to [themes.gohugo.i
[![Netlify Status](https://api.netlify.com/api/v1/badges/58968044-3238-424c-b9b6-e0d00733890c/deploy-status)](https://app.netlify.com/sites/hugothemes/deploys)
# Themes are removed if not up to date
The current policy is to expire a theme if not updated (version date) for the last years. Even if your theme is feature complete, it's appreciated that you check on from time to time and verify that it works with never Hugo versions.
# Adding a theme to the list
Create your theme using <code>hugo new theme <em>THEME_NAME</em></code>. In your theme repository:
+15 -4
View File
@@ -169,8 +169,8 @@ func (c *buildClient) writeThemesContent() error {
}
func (c *buildClient) writeThemeContent(k string, m client.Module) error {
re := regexp.MustCompile(`\/v\d+$`)
themeName := strings.ToLower(path.Base(re.ReplaceAllString(k, "")))
re := regexp.MustCompile(`\/v\d+$`)
themeName := strings.ToLower(path.Base(re.ReplaceAllString(k, "")))
themeDir := filepath.Join(c.contentDir, "themes", themeName)
client.CheckErr(os.MkdirAll(themeDir, 0777))
@@ -311,9 +311,10 @@ func (t *theme) warn(s string) {
t.themeWarnings = append(t.themeWarnings, s)
}
// 30 days.
var d30 = 30 * 24 * time.Hour
func (t *theme) calculateWeight(maxStars int) {
// 30 days.
d30 := 30 * 24 * time.Hour
// Higher is better.
t.weight = maxStars + 500
@@ -368,8 +369,18 @@ func (t *theme) toFrontMatter() map[string]interface{} {
htmlURL = fmt.Sprintf("https://%s", t.m.Path)
}
var expiryDate time.Time
if !t.m.Time.IsZero() {
// 2 years since last version.
expiryDate = t.m.Time.Add(24 * d30)
} else {
// In practice, this will never expire.
expiryDate = time.Now().Add(22 * d30)
}
return map[string]interface{}{
"draft": t.draft,
"expiryDate": expiryDate,
"title": title,
"slug": t.name,
"aliases": []string{"/" + t.name},