Age | Commit message (Collapse) | Author |
|
Before this commit, you would have to use page bundles to do image processing etc. in Hugo.
This commit adds
* A new `/assets` top-level project or theme dir (configurable via `assetDir`)
* A new template func, `resources.Get` which can be used to "get a resource" that can be further processed.
This means that you can now do this in your templates (or shortcodes):
```bash
{{ $sunset := (resources.Get "images/sunset.jpg").Fill "300x200" }}
```
This also adds a new `extended` build tag that enables powerful SCSS/SASS support with source maps. To compile this from source, you will also need a C compiler installed:
```
HUGO_BUILD_TAGS=extended mage install
```
Note that you can use output of the SCSS processing later in a non-SCSSS-enabled Hugo.
The `SCSS` processor is a _Resource transformation step_ and it can be chained with the many others in a pipeline:
```bash
{{ $css := resources.Get "styles.scss" | resources.ToCSS | resources.PostCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```
The transformation funcs above have aliases, so it can be shortened to:
```bash
{{ $css := resources.Get "styles.scss" | toCSS | postCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```
A quick tip would be to avoid the fingerprinting part, and possibly also the not-superfast `postCSS` when you're doing development, as it allows Hugo to be smarter about the rebuilding.
Documentation will follow, but have a look at the demo repo in https://github.com/bep/hugo-sass-test
New functions to create `Resource` objects:
* `resources.Get` (see above)
* `resources.FromString`: Create a Resource from a string.
New `Resource` transformation funcs:
* `resources.ToCSS`: Compile `SCSS` or `SASS` into `CSS`.
* `resources.PostCSS`: Process your CSS with PostCSS. Config file support (project or theme or passed as an option).
* `resources.Minify`: Currently supports `css`, `js`, `json`, `html`, `svg`, `xml`.
* `resources.Fingerprint`: Creates a fingerprinted version of the given Resource with Subresource Integrity..
* `resources.Concat`: Concatenates a list of Resource objects. Think of this as a poor man's bundler.
* `resources.ExecuteAsTemplate`: Parses and executes the given Resource and data context (e.g. .Site) as a Go template.
Fixes #4381
Fixes #4903
Fixes #4858
|
|
Fixes #4638
|
|
```bash
benchmark old ns/op new ns/op delta
BenchmarkStringifyMapKeysStringsOnlyInterfaceMaps-4 3053 2015 -34.00%
BenchmarkStringifyMapKeysStringsOnlyStringMaps-4 5.23 5.18 -0.96%
BenchmarkStringifyMapKeysIntegers-4 2320 5177 +123.15%
benchmark old allocs new allocs delta
BenchmarkStringifyMapKeysStringsOnlyInterfaceMaps-4 6 6 +0.00%
BenchmarkStringifyMapKeysStringsOnlyStringMaps-4 0 0 +0.00%
BenchmarkStringifyMapKeysIntegers-4 6 14 +133.33%
benchmark old bytes new bytes delta
BenchmarkStringifyMapKeysStringsOnlyInterfaceMaps-4 1008 1008 +0.00%
BenchmarkStringifyMapKeysStringsOnlyStringMaps-4 0 0 +0.00%
BenchmarkStringifyMapKeysIntegers-4 1008 1776 +76.19%
```
Closes #4393
|
|
```bash
benchmark old ns/op new ns/op delta
BenchmarkStringifyMapKeysStringsOnlyInterfaceMaps-4 3269 3053 -6.61%
BenchmarkStringifyMapKeysStringsOnlyStringMaps-4 4.79 5.23 +9.19%
BenchmarkStringifyMapKeysIntegers-4 2707 2320 -14.30%
benchmark old allocs new allocs delta
BenchmarkStringifyMapKeysStringsOnlyInterfaceMaps-4 16 6 -62.50%
BenchmarkStringifyMapKeysStringsOnlyStringMaps-4 0 0 +0.00%
BenchmarkStringifyMapKeysIntegers-4 16 6 -62.50%
benchmark old bytes new bytes delta
BenchmarkStringifyMapKeysStringsOnlyInterfaceMaps-4 1080 1008 -6.67%
BenchmarkStringifyMapKeysStringsOnlyStringMaps-4 0 0 +0.00%
BenchmarkStringifyMapKeysIntegers-4 1080 1008 -6.67%
```
|
|
|
|
```bash
BenchmarkStringifyMapKeysStringsOnlyInterfaceMaps-4 500000 3269 ns/op 1080 B/op 16 allocs/op
BenchmarkStringifyMapKeysStringsOnlyStringMaps-4 300000000 4.79 ns/op 0 B/op 0 allocs/op
BenchmarkStringifyMapKeysIntegers-4 500000 2707 ns/op 1080 B/op 16 allocs/op
```
|
|
* Unmarshaled YAML arrays indistinguishable from JSON arrays.
* Fixes #3890
|
|
Recurse through result of yaml package parsing and change all
maps from map[interface{}]interface{} to map[string]interface{}
making them jsonable and sortable.
Fixes #2441, #4083
|
|
This bug was introduced in Hugo 0.35.
Fixes #4361
|
|
* Page without front matter now treated same as a page with empty front matter.
* Test cases added to cover this and repro issue #4320.
* Type safety of front matter code improved.
Fixes #4320
|
|
Fixes #3682
|
|
Fixes #3682
|
|
Fixes #3661
|
|
Also remove a broken JSON test.
Fixes #3511
|
|
This commit removes the fragile front matter decoding, and takes the provided archetype file as-is and processes it as a template.
This also means that we no longer will attempt to fill in default values for `title` and `date`.
The upside is that it is now easy to create these values in a dynamic way:
```toml
+++
title = {{ .BaseFileName | title }}
date = {{ .Date }}
draft = true
+++
```
You can currently use all of Hugo's template funcs, but the data context is currently very shallow:
* `.Type` gives the archetype kind provided
* `.Name` gives the target file name without extension.
* `.Path` gives the target file name
* `.Date` gives the current time as RFC3339 formatted string
The above will probably be extended in #1629.
Fixes #452
Updates #1629
|
|
|
|
We still have go-toml as a transitive dependency, and it is the way to go eventually, but we care about speed, so let us wait that one out.
Note that the issue this fixes is about taxonomies, but I guess this is a general issue for sites with many pages that uses TOML as front matter.
```
benchmark old ns/op new ns/op delta
BenchmarkFrontmatterTags/TOML:1-4 23206 8543 -63.19%
BenchmarkFrontmatterTags/TOML:11-4 80117 18495 -76.92%
BenchmarkFrontmatterTags/TOML:21-4 140676 28727 -79.58%
benchmark old allocs new allocs delta
BenchmarkFrontmatterTags/TOML:1-4 173 60 -65.32%
BenchmarkFrontmatterTags/TOML:11-4 625 138 -77.92%
BenchmarkFrontmatterTags/TOML:21-4 1106 210 -81.01%
benchmark old bytes new bytes delta
BenchmarkFrontmatterTags/TOML:1-4 9231 2912 -68.45%
BenchmarkFrontmatterTags/TOML:11-4 19808 5184 -73.83%
BenchmarkFrontmatterTags/TOML:21-4 31200 7536 -75.85%
```
See #3541
Updates #3464
|
|
The list handling is surprisingly expensive:
```
▶ go test -run="NONE" -bench="BenchmarkFrontmatterTags" -test.benchmem=true ./parser | prettybench
PASS
benchmark iter time/iter bytes alloc allocs
--------- ---- --------- ----------- ------
BenchmarkFrontmatterTags/JSON:1-4 1000000 2039.00 ns/op 912 B/op 20 allocs/op
BenchmarkFrontmatterTags/JSON:11-4 300000 5202.00 ns/op 1640 B/op 44 allocs/op
BenchmarkFrontmatterTags/JSON:21-4 200000 7993.00 ns/op 2392 B/op 65 allocs/op
BenchmarkFrontmatterTags/YAML:1-4 200000 9359.00 ns/op 5928 B/op 66 allocs/op
BenchmarkFrontmatterTags/YAML:11-4 100000 21218.00 ns/op 8408 B/op 140 allocs/op
BenchmarkFrontmatterTags/YAML:21-4 50000 32852.00 ns/op 10920 B/op 211 allocs/op
BenchmarkFrontmatterTags/TOML:1-4 100000 21505.00 ns/op 9231 B/op 173 allocs/op
BenchmarkFrontmatterTags/TOML:11-4 20000 82919.00 ns/op 19808 B/op 625 allocs/op
BenchmarkFrontmatterTags/TOML:21-4 10000 141847.00 ns/op 31200 B/op 1106 allocs/op
ok github.com/spf13/hugo/parser 17.890s
```
See #3464
|
|
Difference between toml.Load(string(datum)) and
toml.LoadReader(bytes.NewReader(datum)):
benchmark old ns/op new ns/op delta
BenchmarkLoad-4 82068 78489 -4.36%
benchmark old allocs new allocs delta
BenchmarkLoad-4 494 493 -0.20%
benchmark old bytes new bytes delta
BenchmarkLoad-4 17009 16913 -0.56%
|
|
Closes #3142
|
|
Accept JSON frontmatter without leading "{\n" so that one line
frontmatters such as `{"param":"paramvalue"}` no longer silently render
empty html.
|
|
Lots of cleanups here:
- Refactor InterfaceToConfig and InterfaceToFrontMatter to use io.Writer.
- Simplify InterfaceToFrontMatter by wrapping InterfaceToConfig.
- Export FrontmatterType since we return it in DetectFrontMatter.
- Refactor removeTOMLIdentifier to avoid blindly replacing "+++".
- Update HandleJSONMetaData to return an empty map on nil input.
- Updates vendored goorgeous package and test for org-mode frontmatter.
- Add tests and godoc comments.
Coverage for parser package increased from 45.2% to 85.2%.
|
|
Fixes #1483
See #936
|
|
|
|
Closes #2400
|
|
|
|
Fixes #2089
|
|
|
|
Closes #2108
|
|
Useful if using or sharing files with users that use editors that
append a unicode byte order marker header (like Windows notepad).
This will still assume files are UTF-8 encoded.
Closes #2075
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
See #1646
|
|
Still need to add some missing headers and an AUTHORS file.
See #1646
|
|
|
|
Fixes #1428
|
|
|
|
When a YAML/TOML's delimiter character sequence is included in a
frontmatter string, parser mistakes it as a delimiter. This fixes it by
checking a character right before the delimiter sequence is '\n' or it
is the beginning of the frontmatter.
Fix #1320
|
|
When someone hits space after typing "---" (or "+++") but before they
hit return, hugo silently failed to parse the file. This corrects that.
|
|
Many minor fixes to make test logs more consistent and correct a
mispelling.
Standardize on "[%i] got X but expected Y" for log messages. Using
a consistent layout makes it easier to read the test results. This
was mostly changing "Got" to "got". Swapped the order of values on
several calls to bring them in line with the convention.
A few log messages had a sequence number added to identify the
exact scenario that failed. Otherwise, there would be no way to
ascertain which failed When there are many scenarios.
Correct spelling of "expected."
Fixes #1028
Merged be2097e1ad789eca5d893805a059d94defbe5c48
[close #1040]
|
|
|
|
First step to use initialisms that golint suggests,
for example:
Line 116: func GetHtmlRenderer should be GetHTMLRenderer
as see on http://goreportcard.com/report/spf13/hugo
Thanks to @bep for the idea!
Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.
First step in fixing #959.
|
|
|
|
|
|
|