Remove items deprecated <= v0.136.0 (note)

Template functions:
- data.GetCSV / getCSV (use resources.GetRemote)
- data.GetJSON / getJSON (use resources.GetRemote)
- crypto.FNV32a (use hash.FNV32a)
- resources.Babel (use js.Babel)
- resources.PostCSS (use css.PostCSS)
- resources.ToCSS (use css.Sass)

Page methods:
- .Page.NextPage (use .Page.Next)
- .Page.PrevPage (use .Page.Prev)

Paginator:
- .Paginator.PageSize (use .Paginator.PagerSize)

Site methods:
- .Site.LastChange (use .Site.Lastmod)
- .Site.Author (use .Site.Params.Author)
- .Site.Authors (use .Site.Params.Authors)
- .Site.Social (use .Site.Params.Social)
- .Site.IsMultiLingual (use hugo.IsMultilingual)
- .Sites.First (use .Sites.Default)

Site config:
- paginate (use pagination.pagerSize)
- paginatePath (use pagination.path)

File caches:
- getjson cache
- getcsv cache
This commit is contained in:
Bjørn Erik Pedersen
2026-02-12 19:33:58 +01:00
committed by GitHub
parent b358a65c8b
commit af5051e759
23 changed files with 22 additions and 1230 deletions
-14
View File
@@ -41,8 +41,6 @@ var defaultCacheConfig = FileCacheConfig{
}
const (
CacheKeyGetJSON = "getjson"
CacheKeyGetCSV = "getcsv"
CacheKeyImages = "images"
CacheKeyAssets = "assets"
CacheKeyModules = "modules"
@@ -74,8 +72,6 @@ var defaultCacheConfigs = Configs{
MaxAge: 24 * time.Hour,
Dir: ":cacheDir/modules",
},
CacheKeyGetJSON: defaultCacheConfig,
CacheKeyGetCSV: defaultCacheConfig,
CacheKeyImages: {
MaxAge: -1,
Dir: resourcesGenDir,
@@ -130,16 +126,6 @@ func (c FileCacheConfig) MarshalJSON() ([]byte, error) {
})
}
// GetJSONCache gets the file cache for getJSON.
func (f Caches) GetJSONCache() *Cache {
return f[CacheKeyGetJSON]
}
// GetCSVCache gets the file cache for getCSV.
func (f Caches) GetCSVCache() *Cache {
return f[CacheKeyGetCSV]
}
// ImageCache gets the file cache for processed images.
func (f Caches) ImageCache() *Cache {
return f[CacheKeyImages]
+11 -17
View File
@@ -44,12 +44,9 @@ assetDir = "assets"
archetypeDir = "archetypes"
[caches]
[caches.getJSON]
[caches.misc]
maxAge = "10m"
dir = "/path/to/c1"
[caches.getCSV]
maxAge = "11h"
dir = "/path/to/c2"
[caches.images]
dir = "/path/to/c3"
[caches.getResource]
@@ -60,11 +57,11 @@ dir = "/path/to/c4"
c.Assert(err, qt.IsNil)
fs := afero.NewMemMapFs()
decoded := testconfig.GetTestConfigs(fs, cfg).Base.Caches
c.Assert(len(decoded), qt.Equals, 8)
c.Assert(len(decoded), qt.Equals, 6)
c2 := decoded["getcsv"]
c.Assert(c2.MaxAge.String(), qt.Equals, "11h0m0s")
c.Assert(c2.DirCompiled, qt.Equals, filepath.FromSlash("/path/to/c2/filecache/getcsv"))
c2 := decoded["misc"]
c.Assert(c2.MaxAge.String(), qt.Equals, "10m0s")
c.Assert(c2.DirCompiled, qt.Equals, filepath.FromSlash("/path/to/c1/filecache/misc"))
c3 := decoded["images"]
c.Assert(c3.MaxAge, qt.Equals, time.Duration(-1))
@@ -91,12 +88,9 @@ archeTypedir = "archetypes"
ignoreCache = true
[caches]
[caches.getJSON]
[caches.misc]
maxAge = 1234
dir = "/path/to/c1"
[caches.getCSV]
maxAge = 3456
dir = "/path/to/c2"
[caches.images]
dir = "/path/to/c3"
[caches.getResource]
@@ -107,7 +101,7 @@ dir = "/path/to/c4"
c.Assert(err, qt.IsNil)
fs := afero.NewMemMapFs()
decoded := testconfig.GetTestConfigs(fs, cfg).Base.Caches
c.Assert(len(decoded), qt.Equals, 8)
c.Assert(len(decoded), qt.Equals, 6)
for _, v := range decoded {
c.Assert(v.MaxAge, qt.Equals, time.Duration(0))
@@ -130,20 +124,20 @@ func TestDecodeConfigDefault(t *testing.T) {
fs := afero.NewMemMapFs()
decoded := testconfig.GetTestConfigs(fs, cfg).Base.Caches
c.Assert(len(decoded), qt.Equals, 8)
c.Assert(len(decoded), qt.Equals, 6)
imgConfig := decoded[filecache.CacheKeyImages]
jsonConfig := decoded[filecache.CacheKeyGetJSON]
miscConfig := decoded[filecache.CacheKeyMisc]
if runtime.GOOS == "windows" {
c.Assert(imgConfig.DirCompiled, qt.Equals, filepath.FromSlash("_gen/images"))
} else {
c.Assert(imgConfig.DirCompiled, qt.Equals, "_gen/images")
c.Assert(jsonConfig.DirCompiled, qt.Equals, "/cache/thecache/hugoproject/filecache/getjson")
c.Assert(miscConfig.DirCompiled, qt.Equals, "/cache/thecache/hugoproject/filecache/misc")
}
c.Assert(imgConfig.IsResourceDir, qt.Equals, true)
c.Assert(jsonConfig.IsResourceDir, qt.Equals, false)
c.Assert(miscConfig.IsResourceDir, qt.Equals, false)
}
func TestFileCacheConfigMarshalJSON(t *testing.T) {
+2 -5
View File
@@ -39,12 +39,9 @@ assetDir = "assets"
archeTypedir = "archetypes"
[caches]
[caches.getjson]
[caches.misc]
maxAge = "200ms"
dir = "/cache/c"
[caches.getcsv]
maxAge = "200ms"
dir = "/cache/d"
[caches.assets]
maxAge = "200ms"
dir = ":resourceDir/_gen"
@@ -53,7 +50,7 @@ maxAge = "200ms"
dir = ":resourceDir/_gen"
`
for _, name := range []string{filecache.CacheKeyGetCSV, filecache.CacheKeyGetJSON, filecache.CacheKeyAssets, filecache.CacheKeyImages} {
for _, name := range []string{filecache.CacheKeyAssets, filecache.CacheKeyImages} {
msg := qt.Commentf("cache: %s", name)
fs := afero.NewMemMapFs()
p := newPathsSpec(t, fs, configStr)
+7 -9
View File
@@ -18,12 +18,12 @@ import (
"fmt"
"io"
"strings"
"github.com/gohugoio/hugo/htesting"
"sync"
"testing"
"time"
"github.com/gohugoio/hugo/htesting"
"github.com/gohugoio/hugo/cache/filecache"
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/config"
@@ -66,7 +66,7 @@ assetDir = "assets"
archeTypedir = "archetypes"
[caches]
[caches.getJSON]
[caches.misc]
maxAge = "10h"
dir = ":cacheDir/c"
@@ -86,7 +86,7 @@ dir = ":cacheDir/c"
c.Assert(err, qt.IsNil)
caches.SetResourceFs(p.SourceFs)
cache := caches.Get("GetJSON")
cache := caches.Get("Misc")
c.Assert(cache, qt.Not(qt.IsNil))
cache = caches.Get("Images")
@@ -108,7 +108,7 @@ dir = ":cacheDir/c"
return []byte("bcd"), nil
}
for _, ca := range []*filecache.Cache{caches.ImageCache(), caches.AssetsCache(), caches.GetJSONCache(), caches.GetCSVCache()} {
for _, ca := range []*filecache.Cache{caches.ImageCache(), caches.AssetsCache()} {
for range 2 {
info, r, err := ca.GetOrCreate("a", rf("abc"))
c.Assert(err, qt.IsNil)
@@ -136,8 +136,6 @@ dir = ":cacheDir/c"
}
}
c.Assert(caches.Get("getJSON"), qt.Not(qt.IsNil))
info, w, err := caches.ImageCache().WriteCloser("mykey")
c.Assert(err, qt.IsNil)
c.Assert(info.Name, qt.Equals, "mykey")
@@ -177,7 +175,7 @@ assetDir = "assets"
archeTypedir = "archetypes"
[caches]
[caches.getjson]
[caches.misc]
maxAge = "1s"
dir = "/cache/c"
@@ -189,7 +187,7 @@ dir = "/cache/c"
c.Assert(err, qt.IsNil)
caches.SetResourceFs(p.Fs.Source)
const cacheName = "getjson"
const cacheName = "misc"
filenameData := func(i int) (string, string) {
data := fmt.Sprintf("data: %d", i)