2017-06-17 16:51:32 +02:00
|
|
|
package gojekyll
|
2017-06-17 03:53:14 +02:00
|
|
|
|
|
|
|
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"`
|
2017-06-17 03:53:14 +02:00
|
|
|
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
|
|
|
|
}
|
2017-06-17 03:53:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
`
|