Skip to content

Commit 186934f

Browse files
committed
common/hcontext: Replace with external package
1 parent 13b43e6 commit 186934f

File tree

7 files changed

+26
-65
lines changed

7 files changed

+26
-65
lines changed

‎common/hcontext/context.go‎

Lines changed: 0 additions & 46 deletions
This file was deleted.

‎common/hugo/hugo.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ import (
2828
"github.com/bep/logg"
2929

3030
"github.com/bep/godartsass/v2"
31-
"github.com/gohugoio/hugo/common/hcontext"
31+
3232
"github.com/gohugoio/hugo/common/hexec"
3333
"github.com/gohugoio/hugo/common/loggers"
3434
"github.com/gohugoio/hugo/common/maps"
3535
"github.com/gohugoio/hugo/hugofs/files"
3636

37+
"github.com/bep/helpers/contexthelpers"
3738
"github.com/spf13/afero"
3839

3940
iofs "io/fs"
@@ -145,7 +146,7 @@ const (
145146
contextKeyMarkupScope contextKey = iota
146147
)
147148

148-
var markupScope = hcontext.NewContextDispatcher[string](contextKeyMarkupScope)
149+
var markupScope = contexthelpers.NewContextDispatcher[string](contextKeyMarkupScope)
149150

150151
type Context struct{}
151152

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/bep/golibsass v1.2.0
1515
github.com/bep/goportabletext v0.1.0
1616
github.com/bep/gowebp v0.3.0
17-
github.com/bep/helpers v0.5.0
17+
github.com/bep/helpers v0.6.0
1818
github.com/bep/imagemeta v0.12.0
1919
github.com/bep/lazycache v0.8.0
2020
github.com/bep/logg v0.4.0

‎go.sum‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ github.com/bep/gowebp v0.3.0 h1:MhmMrcf88pUY7/PsEhMgEP0T6fDUnRTMpN8OclDrbrY=
157157
github.com/bep/gowebp v0.3.0/go.mod h1:ZhFodwdiFp8ehGJpF4LdPl6unxZm9lLFjxD3z2h2AgI=
158158
github.com/bep/helpers v0.5.0 h1:rneezhnG7GzLFlsEWO/EnleaBRuluBDGFimalO6Y50o=
159159
github.com/bep/helpers v0.5.0/go.mod h1:dSqCzIvHbzsk5YOesp1M7sKAq5xUcvANsRoKdawxH4Q=
160+
github.com/bep/helpers v0.6.0 h1:qtqMCK8XPFNM9hp5Ztu9piPjxNNkk8PIyUVjg6v8Bsw=
161+
github.com/bep/helpers v0.6.0/go.mod h1:IOZlgx5PM/R/2wgyCatfsgg5qQ6rNZJNDpWGXqDR044=
160162
github.com/bep/imagemeta v0.12.0 h1:ARf+igs5B7pf079LrqRnwzQ/wEB8Q9v4NSDRZO1/F5k=
161163
github.com/bep/imagemeta v0.12.0/go.mod h1:23AF6O+4fUi9avjiydpKLStUNtJr5hJB4rarG18JpN8=
162164
github.com/bep/lazycache v0.8.0 h1:lE5frnRjxaOFbkPZ1YL6nijzOPPz6zeXasJq8WpG4L8=

‎hugolib/page__content.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ import (
2626

2727
maps0 "maps"
2828

29+
"github.com/bep/helpers/contexthelpers"
2930
"github.com/bep/logg"
30-
"github.com/gohugoio/hugo/common/hcontext"
31+
3132
"github.com/gohugoio/hugo/common/herrors"
3233
"github.com/gohugoio/hugo/common/hugio"
3334
"github.com/gohugoio/hugo/common/hugo"
@@ -673,7 +674,7 @@ const (
673674
contextKeyContentCallback contextKey = iota
674675
)
675676

676-
var setGetContentCallbackInContext = hcontext.NewContextDispatcher[func(*pageContentOutput, contentTableOfContents)](contextKeyContentCallback)
677+
var setGetContentCallbackInContext = contexthelpers.NewContextDispatcher[func(*pageContentOutput, contentTableOfContents)](contextKeyContentCallback)
677678

678679
func (c *cachedContentScope) contentToC(ctx context.Context) (contentTableOfContents, error) {
679680
cp := c.pco

‎resources/resource_factories/create/create.go‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import (
2323
"strings"
2424
"time"
2525

26+
"github.com/bep/helpers/contexthelpers"
27+
2628
"github.com/bep/logg"
2729
"github.com/gohugoio/httpcache"
2830
hhttpcache "github.com/gohugoio/hugo/cache/httpcache"
@@ -34,7 +36,7 @@ import (
3436
"github.com/gohugoio/hugo/cache/dynacache"
3537
"github.com/gohugoio/hugo/cache/filecache"
3638
"github.com/gohugoio/hugo/common/hashing"
37-
"github.com/gohugoio/hugo/common/hcontext"
39+
3840
"github.com/gohugoio/hugo/common/hugio"
3941
"github.com/gohugoio/hugo/common/tasks"
4042
"github.com/gohugoio/hugo/resources"
@@ -48,7 +50,7 @@ type Client struct {
4850
httpClient *http.Client
4951
httpCacheConfig hhttpcache.ConfigCompiled
5052
cacheGetResource *filecache.Cache
51-
resourceIDDispatcher hcontext.ContextDispatcher[string]
53+
resourceIDDispatcher contexthelpers.ContextDispatcher[string]
5254

5355
// Set when watching.
5456
remoteResourceChecker *tasks.RunEvery
@@ -64,7 +66,7 @@ const (
6466
// New creates a new Client with the given specification.
6567
func New(rs *resources.Spec) *Client {
6668
fileCache := rs.FileCaches.GetResourceCache()
67-
resourceIDDispatcher := hcontext.NewContextDispatcher[string](contextKeyResourceID)
69+
resourceIDDispatcher := contexthelpers.NewContextDispatcher[string](contextKeyResourceID)
6870
httpCacheConfig := rs.Cfg.GetConfigSection("httpCacheCompiled").(hhttpcache.ConfigCompiled)
6971
var remoteResourceChecker *tasks.RunEvery
7072
if rs.Cfg.Watching() && !httpCacheConfig.IsPollingDisabled() {

‎tpl/template.go‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ import (
2121
"sync"
2222
"unicode"
2323

24+
"github.com/bep/helpers/contexthelpers"
2425
bp "github.com/gohugoio/hugo/bufferpool"
25-
"github.com/gohugoio/hugo/common/hcontext"
26+
2627
"github.com/gohugoio/hugo/identity"
2728
"github.com/gohugoio/hugo/langs"
2829

@@ -56,18 +57,18 @@ const (
5657

5758
// Context manages values passed in the context to templates.
5859
var Context = struct {
59-
DependencyManagerScopedProvider hcontext.ContextDispatcher[identity.DependencyManagerScopedProvider]
60+
DependencyManagerScopedProvider contexthelpers.ContextDispatcher[identity.DependencyManagerScopedProvider]
6061
GetDependencyManagerInCurrentScope func(context.Context) identity.Manager
61-
DependencyScope hcontext.ContextDispatcher[int]
62-
Page hcontext.ContextDispatcher[page]
63-
IsInGoldmark hcontext.ContextDispatcher[bool]
64-
CurrentTemplate hcontext.ContextDispatcher[*CurrentTemplateInfo]
62+
DependencyScope contexthelpers.ContextDispatcher[int]
63+
Page contexthelpers.ContextDispatcher[page]
64+
IsInGoldmark contexthelpers.ContextDispatcher[bool]
65+
CurrentTemplate contexthelpers.ContextDispatcher[*CurrentTemplateInfo]
6566
}{
66-
DependencyManagerScopedProvider: hcontext.NewContextDispatcher[identity.DependencyManagerScopedProvider](contextKeyDependencyManagerScopedProvider),
67-
DependencyScope: hcontext.NewContextDispatcher[int](contextKeyDependencyScope),
68-
Page: hcontext.NewContextDispatcher[page](contextKeyPage),
69-
IsInGoldmark: hcontext.NewContextDispatcher[bool](contextKeyIsInGoldmark),
70-
CurrentTemplate: hcontext.NewContextDispatcher[*CurrentTemplateInfo](cntextKeyCurrentTemplateInfo),
67+
DependencyManagerScopedProvider: contexthelpers.NewContextDispatcher[identity.DependencyManagerScopedProvider](contextKeyDependencyManagerScopedProvider),
68+
DependencyScope: contexthelpers.NewContextDispatcher[int](contextKeyDependencyScope),
69+
Page: contexthelpers.NewContextDispatcher[page](contextKeyPage),
70+
IsInGoldmark: contexthelpers.NewContextDispatcher[bool](contextKeyIsInGoldmark),
71+
CurrentTemplate: contexthelpers.NewContextDispatcher[*CurrentTemplateInfo](cntextKeyCurrentTemplateInfo),
7172
}
7273

7374
func init() {

0 commit comments

Comments
 (0)