1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-11-27 11:44:38 +01:00
gojekyll/site_config.go

69 lines
1.6 KiB
Go
Raw Normal View History

package gojekyll
import yaml "gopkg.in/yaml.v2"
// SiteConfig is the Jekyll site configuration, typically read from _config.yml.
// See https://jekyllrb.com/docs/configuration/#default-configuration
type SiteConfig struct {
// Where things are:
Source string
Destination string
LayoutsDir string `yaml:"layouts_dir"`
2017-06-17 05:36:27 +02:00
IncludesDir string `yaml:"includes_dir"`
Collections map[string]VariableMap
// Handling Reading
Include []string
Exclude []string
MarkdownExt string `yaml:"markdown_ext"`
// Outputting
Permalink string
2017-06-17 05:30:10 +02:00
Defaults []struct {
Scope struct {
Path string
Type string
}
Values VariableMap
}
}
func (s *Site) readConfigBytes(bytes []byte) error {
configVariables := VariableMap{}
if err := yaml.Unmarshal(bytes, &s.config); err != nil {
return err
}
if err := yaml.Unmarshal(bytes, &configVariables); err != nil {
return err
}
s.Variables = MergeVariableMaps(s.Variables, configVariables)
return nil
}
// From https://jekyllrb.com/docs/configuration/#default-configuration
const defaultSiteConfig = `
# Where things are
source: .
destination: ./_site
layouts_dir: _layouts
data_dir: _data
includes_dir: _includes
collections:
posts:
output: true
# Handling Reading
include: [".htaccess"]
exclude: ["Gemfile", "Gemfile.lock", "node_modules", "vendor/bundle/", "vendor/cache/", "vendor/gems/", "vendor/ruby/"]
keep_files: [".git", ".svn"]
encoding: "utf-8"
markdown_ext: "markdown,mkdown,mkdn,mkd,md"
strict_front_matter: false
# Outputting
permalink: date
paginate_path: /page:num
timezone: null
`