Commit graph

300 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
08fdca9d93 Add Markdown diagrams and render hooks for code blocks
You can now create custom hook templates for code blocks, either one for all (`render-codeblock.html`) or for a given code language (e.g. `render-codeblock-go.html`).

We also used this new hook to add support for diagrams in Hugo:

* Goat (Go ASCII Tool) is built-in and enabled by default; just create a fenced code block with the language `goat` and start draw your Ascii diagrams.
* Another popular alternative for diagrams in Markdown, Mermaid (supported by GitHub), can also be implemented with a simple template. See the Hugo documentation for more information.

Updates #7765
Closes #9538
Fixes #9553
Fixes #8520
Fixes #6702
Fixes #9558
2022-02-24 18:59:50 +01:00
hugoreleaser
9433cc2562 releaser: Prepare repository for 0.93.0-DEV
[ci skip]
2022-02-11 14:54:18 +00:00
hugoreleaser
cdf6a0d622 releaser: Bump versions for release of 0.92.2
[ci skip]
2022-02-11 14:17:39 +00:00
Joe Mooring
4f4cec73be Add HUGO_ENV to the os/exec environment
Closes #9490
2022-02-11 08:30:26 +01:00
Joe Mooring
c05c99f0c5 Fix typo in panicOnWarning message 2022-01-27 17:50:34 +01:00
hugoreleaser
ff7689ce02 releaser: Prepare repository for 0.93.0-DEV
[ci skip]
2022-01-27 12:22:31 +00:00
hugoreleaser
85e2e86266 releaser: Bump versions for release of 0.92.1
[ci skip]
2022-01-27 11:44:40 +00:00
Bjørn Erik Pedersen
348d300a71 common: Remove unused code 2022-01-16 17:12:56 +01:00
Bjørn Erik Pedersen
6f07bdb152 common/paths: Remove unused code 2022-01-16 17:12:56 +01:00
hugoreleaser
ed04ed5745 releaser: Prepare repository for 0.93.0-DEV
[ci skip]
2022-01-12 08:58:07 +00:00
hugoreleaser
b354940369 releaser: Bump versions for release of 0.92.0
[ci skip]
2022-01-12 08:23:17 +00:00
Bjørn Erik Pedersen
7396aa945a Add hugo.Deps
Fixes #8949
2022-01-11 18:06:23 +01:00
Bjørn Erik Pedersen
c8b5ab75b7 Add --panicOnWarning flag
Fixes #9357
Fixes #9359
2022-01-06 12:27:04 +01:00
hugoreleaser
1dbfc0f930 releaser: Prepare repository for 0.92.0-DEV
[ci skip]
2021-12-23 16:10:18 +00:00
hugoreleaser
1798bd3fd1 releaser: Bump versions for release of 0.91.2
[ci skip]
2021-12-23 15:33:33 +00:00
hugoreleaser
759cdf3fc8 releaser: Prepare repository for 0.92.0-DEV
[ci skip]
2021-12-22 16:07:34 +00:00
hugoreleaser
f423505746 releaser: Bump versions for release of 0.91.1
[ci skip]
2021-12-22 15:31:05 +00:00
hugoreleaser
728feaecf0 releaser: Prepare repository for 0.92.0-DEV
[ci skip]
2021-12-17 10:31:22 +00:00
hugoreleaser
d1dc0e9a54 releaser: Bump versions for release of 0.91.0
[ci skip]
2021-12-17 09:50:19 +00:00
Bjørn Erik Pedersen
f4389e48ce
Add some basic security policies with sensible defaults
This ommmit contains some security hardening measures for the Hugo build runtime.

There are some rarely used features in Hugo that would be good to have disabled by default. One example would be the "external helpers".

For `asciidoctor` and some others we use Go's `os/exec` package to start a new process.

These are a predefined set of binary names, all loaded from `PATH` and with a predefined set of arguments. Still, if you don't use `asciidoctor` in your project, you might as well have it turned off.

You can configure your own in the new `security` configuration section, but the defaults are configured to create a minimal amount of site breakage. And if that do happen, you will get clear instructions in the loa about what to do.

The default configuration is listed below. Note that almost all of these options are regular expression _whitelists_ (a string or a slice); the value `none` will block all.

```toml
[security]
  enableInlineShortcodes = false
  [security.exec]
    allow = ['^dart-sass-embedded$', '^go$', '^npx$', '^postcss$']
    osEnv = ['(?i)^(PATH|PATHEXT|APPDATA|TMP|TEMP|TERM)$']

  [security.funcs]
    getenv = ['^HUGO_']

  [security.http]
    methods = ['(?i)GET|POST']
    urls = ['.*']
```
2021-12-16 09:40:22 +01:00
hugoreleaser
3f0d49e502 releaser: Prepare repository for 0.91.0-DEV
[ci skip]
2021-12-10 11:42:18 +00:00
hugoreleaser
4890788974 releaser: Bump versions for release of 0.90.1
[ci skip]
2021-12-10 10:56:40 +00:00
hugoreleaser
34a96290fa releaser: Prepare repository for 0.91.0-DEV
[ci skip]
2021-12-08 10:11:31 +00:00
hugoreleaser
dd0d3fdbbe releaser: Bump versions for release of 0.90.0
[ci skip]
2021-12-08 09:33:46 +00:00
Bjørn Erik Pedersen
e71d715b9b Add custom font support to images.Text
Fixes #9253
2021-12-07 16:53:02 +01:00
hugoreleaser
0b70b46aad releaser: Prepare repository for 0.90.0-DEV
[ci skip]
2021-11-17 09:05:38 +00:00
hugoreleaser
cc08c09592 releaser: Bump versions for release of 0.89.4
[ci skip]
2021-11-17 08:24:08 +00:00
hugoreleaser
1ed8069a3a releaser: Prepare repository for 0.90.0-DEV
[ci skip]
2021-11-15 12:56:41 +00:00
hugoreleaser
e1064d2195 releaser: Bump versions for release of 0.89.3
[ci skip]
2021-11-15 12:17:45 +00:00
hugoreleaser
805c24c32c releaser: Prepare repository for 0.90.0-DEV
[ci skip]
2021-11-08 15:56:14 +00:00
hugoreleaser
eaa6c96a79 releaser: Bump versions for release of 0.89.2
[ci skip]
2021-11-08 15:22:23 +00:00
hugoreleaser
9232e28446 releaser: Prepare repository for 0.90.0-DEV
[ci skip]
2021-11-05 16:24:06 +00:00
hugoreleaser
84de0c3255 releaser: Bump versions for release of 0.89.1
[ci skip]
2021-11-05 15:44:32 +00:00
hugoreleaser
41e9e9fe14 releaser: Prepare repository for 0.90.0-DEV
[ci skip]
2021-11-02 10:40:00 +00:00
hugoreleaser
a93d4ba64e releaser: Bump versions for release of 0.89.0
[ci skip]
2021-11-02 10:00:17 +00:00
Bjørn Erik Pedersen
ed6fd26ce8 common/htime: Fix time.Format with Go layouts
Fixes #9107
2021-11-01 15:45:59 +01:00
satotake
b959ecbc81
htime: Set zone of datetime from from go-toml
`go-toml/v2`'s unmarshaler does not specify zone name even if value has
offset explicitly.
To make time-formatting behaviour consistent, convert them into string
in hugo.

Close #8895
2021-10-25 19:49:44 +02:00
hugoreleaser
3efc2e2af8 releaser: Prepare repository for 0.89.0-DEV
[ci skip]
2021-09-04 10:33:09 +00:00
hugoreleaser
bb3254385a releaser: Bump versions for release of 0.88.1
[ci skip]
2021-09-04 09:39:19 +00:00
hugoreleaser
5b59b9c171 releaser: Prepare repository for 0.89.0-DEV
[ci skip]
2021-09-02 09:57:36 +00:00
hugoreleaser
6cacfa329c releaser: Bump versions for release of 0.88.0
[ci skip]
2021-09-02 09:27:27 +00:00
Bjørn Erik Pedersen
f4ffeea71d Fix it so disableKinds etc. does not get merged in from theme
Unless the merge strategy is set up to do so.

For `disableKinds` the current workaround is to make sure the project config has an entry, even if is empty:

```
disableKinds = []
```

Note that this issue only touches root, non-map config-values that either is not set in project config or in Hugo's defaults.

Fixes #8866
2021-08-22 13:25:20 +02:00
hugoreleaser
dfe54d3216 releaser: Prepare repository for 0.88.0-DEV
[ci skip]
2021-08-03 12:11:56 +00:00
hugoreleaser
2ed7be295c releaser: Bump versions for release of 0.87.0
[ci skip]
2021-08-03 10:57:26 +00:00
Bjørn Erik Pedersen
d70c485707
Make sure module config loading errors have file positioning info
Fixes #8845
2021-08-03 09:57:14 +02:00
Bjørn Erik Pedersen
3a96655592 Reduce binary size vs locale, update to CLDR v36.1
Test building with `go build -ldflags="-s -w"`

Hugo 0.86.2: 46MB
Before this commit: 77MB
After this commit: 54MB

Fixes #8839
Fixes #8841
2021-08-02 19:40:32 +02:00
Bjørn Erik Pedersen
e3dc5240f0 Improve handling of <nil> Params
Fixes #8825
2021-07-30 21:07:52 +02:00
Bjørn Erik Pedersen
7907d24ba1
tpl/lang: Add new localized versions of lang.FormatNumber etc.
Fixes #8820
2021-07-29 16:40:06 +02:00
Bjørn Erik Pedersen
b5de37ee79
Handle toml.LocalDate and toml.LocalDateTime in front matter
See #8801
2021-07-28 18:02:42 +02:00
Bjørn Erik Pedersen
a3701e0931 Switch to go-toml v2
We have been using `go-toml` for language files only. This commit makes it the only TOML library.

It's spec compliant and very fast.

A benchark building a site with 200 pages with TOML front matter:

```bash
name                                  old time/op    new time/op    delta
SiteNew/Regular_TOML_front_matter-16    48.5ms ± 1%    47.1ms ± 1%  -2.85%  (p=0.029 n=4+4)

name                                  old alloc/op   new alloc/op   delta
SiteNew/Regular_TOML_front_matter-16    16.9MB ± 0%    16.7MB ± 0%  -1.56%  (p=0.029 n=4+4)

name                                  old allocs/op  new allocs/op  delta
SiteNew/Regular_TOML_front_matter-16      302k ± 0%      296k ± 0%  -2.20%  (p=0.029 n=4+4)
```

Note that the front matter unmarshaling is only a small part of building a site, so the above is very good.

Fixes #8801
2021-07-28 11:51:13 +02:00