diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-09-06 20:00:15 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2022-09-06 20:16:33 +0300 |
commit | b6ee7b8674ef4d6931443b5da44b07b3922caf4c (patch) | |
tree | c2711402ae078296edc2d4b5088606a580f21393 | |
parent | be3a8d991653424b3c0a27f8f28b76eb72c489e8 (diff) |
Add expiryDate 2 years after last theme update/versionfeat/expiry-date
This should be a clear indication that the theme isn't up to date.
-rw-r--r-- | README.md | 6 | ||||
-rw-r--r-- | pkg/buildcmd/build.go | 19 |
2 files changed, 21 insertions, 4 deletions
@@ -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: 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}, |