From dfaa658e27a45b2cf27513db6648492be08c9ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 6 Sep 2022 19:00:15 +0200 Subject: [PATCH] Add expiryDate 2 years after last theme update/version This should be a clear indication that the theme isn't up to date. --- README.md | 6 ++++++ pkg/buildcmd/build.go | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 236dbfa..6c02396 100644 --- a/README.md +++ b/README.md @@ -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 hugo new theme THEME_NAME. In your theme repository: diff --git a/pkg/buildcmd/build.go b/pkg/buildcmd/build.go index a4f6878..e3ba4b2 100644 --- a/pkg/buildcmd/build.go +++ b/pkg/buildcmd/build.go @@ -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},