mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
hugolib: Add hugo.Sites and .Site.IsDefault(), modify .Site.Sites
Changes: - Add hugo.Sites to return all sites for all dimensions - Modify .Site.Sites to return all sites for all dimensions - Deprecate .Site.Sites in favor of hugo.Sites - Add .Site.IsDefault() to report whether the current site is the default site across all dimensions - Consolidate tests Closes #14479 Closes #14481 Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
21be4afd49
commit
ab62320d6b
@@ -27,8 +27,16 @@ import (
|
||||
|
||||
func TestPageMatcher(t *testing.T) {
|
||||
c := qt.New(t)
|
||||
developmentTestSite := testSite{h: hugo.NewInfo(testConfig{environment: "development"}, nil)}
|
||||
productionTestSite := testSite{h: hugo.NewInfo(testConfig{environment: "production"}, nil)}
|
||||
|
||||
opts := hugo.HugoInfoOptions{
|
||||
Conf: testConfig{environment: "development"},
|
||||
}
|
||||
developmentTestSite := testSite{h: hugo.NewInfo(opts, nil)}
|
||||
|
||||
opts = hugo.HugoInfoOptions{
|
||||
Conf: testConfig{environment: "production"},
|
||||
}
|
||||
productionTestSite := testSite{h: hugo.NewInfo(opts, nil)}
|
||||
|
||||
dec := cascadeConfigDecoder{}
|
||||
|
||||
|
||||
+18
-3
@@ -77,12 +77,15 @@ type Site interface {
|
||||
// Returns the configured copyright information for this Site.
|
||||
Copyright() string
|
||||
|
||||
// Returns all Sites for all languages.
|
||||
// Returns all sites for all dimensions.
|
||||
Sites() Sites
|
||||
|
||||
// Returns Site currently rendering.
|
||||
Current() Site
|
||||
|
||||
// Reports whether this site is the default across all dimensions.
|
||||
IsDefault() bool
|
||||
|
||||
// Returns a struct with some information about the build.
|
||||
Hugo() hugo.HugoInfo
|
||||
|
||||
@@ -120,8 +123,9 @@ type Site interface {
|
||||
LanguagePrefix() string
|
||||
|
||||
hstore.StoreProvider
|
||||
|
||||
// String returns a string representation of the site.
|
||||
// Note that this represenetation may change in the future.
|
||||
// Note that this representation may change in the future.
|
||||
String() string
|
||||
|
||||
// For internal use only.
|
||||
@@ -239,6 +243,10 @@ func (s *siteWrapper) Current() Site {
|
||||
return s.s.Current()
|
||||
}
|
||||
|
||||
func (s *siteWrapper) IsDefault() bool {
|
||||
return s.s.IsDefault()
|
||||
}
|
||||
|
||||
func (s *siteWrapper) Config() SiteConfig {
|
||||
return s.s.Config()
|
||||
}
|
||||
@@ -350,6 +358,10 @@ func (t testSite) Current() Site {
|
||||
return t
|
||||
}
|
||||
|
||||
func (t testSite) IsDefault() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (s testSite) LanguagePrefix() string {
|
||||
return ""
|
||||
}
|
||||
@@ -439,8 +451,11 @@ func (s testSite) CheckReady() {
|
||||
|
||||
// NewDummyHugoSite creates a new minimal test site.
|
||||
func NewDummyHugoSite(conf config.AllProvider) Site {
|
||||
opts := hugo.HugoInfoOptions{
|
||||
Conf: conf,
|
||||
}
|
||||
return testSite{
|
||||
h: hugo.NewInfo(conf, nil),
|
||||
h: hugo.NewInfo(opts, nil),
|
||||
l: &langs.Language{
|
||||
Lang: "en",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user