-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a struct with all of Hugo's config options
Primary motivation is documentation, but it will also hopefully simplify the code.
- Loading branch information
Showing
3 changed files
with
174 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
// Copyright 2023 The Hugo Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package allconfig | ||
|
||
import ( | ||
"github.com/gohugoio/hugo/cache/filecache" | ||
"github.com/gohugoio/hugo/common/maps" | ||
"github.com/gohugoio/hugo/config" | ||
"github.com/gohugoio/hugo/config/privacy" | ||
"github.com/gohugoio/hugo/config/security" | ||
"github.com/gohugoio/hugo/config/services" | ||
"github.com/gohugoio/hugo/markup/markup_config" | ||
"github.com/gohugoio/hugo/minifiers" | ||
"github.com/gohugoio/hugo/modules" | ||
"github.com/gohugoio/hugo/related" | ||
"github.com/gohugoio/hugo/resources/images" | ||
) | ||
|
||
/* | ||
ConfigRootKeysSet = map[string]bool{ | ||
"build": true, | ||
"caches": true, | ||
"cascade": true, | ||
"frontmatter": true, | ||
"languages": true, | ||
"imaging": true, | ||
"markup": true, | ||
"mediatypes": true, | ||
"menus": true, | ||
"minify": true, | ||
"module": true, | ||
"outputformats": true, | ||
"params": true, | ||
"permalinks": true, | ||
"related": true, | ||
"sitemap": true, | ||
"privacy": true, | ||
"security": true, | ||
"taxonomies": true, | ||
} | ||
*/ | ||
|
||
// Config holds all configuration options in Hugo. | ||
// TODO(bep) make sure that the keys gets the sensible casing in JSON etc. | ||
type Config struct { | ||
// The build configuration section contains global build-related configuration options. | ||
Build config.Build | ||
|
||
// The caches configuration section contains global cache-related configuration options. | ||
Caches map[string]filecache.Config | ||
|
||
// The cascade configuration section contains global the top level front matter cascade configuration options. | ||
Cascade []CascadeEntryConfig | ||
|
||
// Front matter configuration. | ||
Frontmatter FrontmatterConfig | ||
|
||
// Image processing configuration. | ||
Imaging images.ImagingConfig | ||
|
||
// Language configuration. | ||
Languages map[string]LanguageConfig | ||
|
||
// Markup configuration. | ||
Markup markup_config.Config | ||
|
||
// Media type configuration. | ||
MediaTypes map[string]MediaTypeConfig | ||
|
||
// Menu configuration. | ||
Menus []MenuConfig | ||
|
||
// Minification configuration. | ||
Minify minifiers.MinifyConfig | ||
|
||
// Module configuration. | ||
Module modules.Config | ||
|
||
// Output format configuration. | ||
Outputformats map[string]OutputFormatConfig | ||
|
||
// Params configuration. | ||
Params maps.Params | ||
|
||
// Permalink configuration. | ||
Permalinks map[string]string | ||
|
||
// Privacy configuration. | ||
Privacy privacy.Config | ||
|
||
// Related content configuration. | ||
Related related.Config | ||
|
||
// Security configuration. | ||
Security security.Config | ||
|
||
// Services configuration. | ||
Services services.Config | ||
|
||
// Sitemap configuration. | ||
Sitemap config.Sitemap | ||
|
||
// Taxonomy configuration. | ||
Taxonomies map[string]string | ||
} | ||
|
||
// TODO(bep) move these. | ||
type CascadeEntryConfig struct { | ||
// A Glob pattern matching the content path below /content. | ||
// Expects Unix-styled slashes. Note that this is the virtual path, so it starts at the mount root. | ||
// The matching supports double-asterisks so you can match for patterns like /blog/*/** to match anything from the third level and | ||
Path string | ||
|
||
// A Glob pattern matching the Page’s Kind(s), e.g. “{home,section}”. | ||
Kind string | ||
|
||
// A Glob pattern matching the Page’s language, e.g. “{en,sv}”. | ||
Lang string | ||
|
||
// A Glob pattern matching the build environment, e.g. “{production,development}” | ||
Environment string | ||
} | ||
|
||
type OutputFormatConfig struct { | ||
BaseName string | ||
IsPlainText bool | ||
MediaType string | ||
Protocol string | ||
} | ||
|
||
type FrontmatterConfig struct { | ||
Date []string | ||
ExpiryDate []string | ||
LastMod []string | ||
PublishDate []string | ||
} | ||
|
||
type LanguageConfig struct { | ||
LanguageDirection string | ||
Title string | ||
Weight int | ||
Params maps.Params | ||
} | ||
|
||
type MediaTypeConfig struct { | ||
Suffixes []string | ||
} | ||
|
||
type MenuConfig struct { | ||
Identifier string | ||
Name string | ||
Pre string | ||
URL string | ||
Weight int | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters