Commit graph

505 commits

Author SHA1 Message Date
Bjørn Erik Pedersen ffdbce5787
docs: Regen CLI docs 2023-05-27 17:03:14 +02:00
Bjørn Erik Pedersen a838a27e4c
Merge commit 'd3927310d5b2404c3238f9b899db3329ea516490' 2023-05-27 17:02:23 +02:00
Bjørn Erik Pedersen 10d0fcc01f
docs: Regen CLI docs 2023-05-22 16:48:58 +02:00
Bjørn Erik Pedersen b95e156940
Merge commit 'f96384a3b596f9bc0a3a035970b09b2c601f0ccb' 2023-05-22 16:47:07 +02:00
InLaw 2db7ec622f
tpl/tplimpl: Add img loading attribute to figure shortcode (#10927) 2023-05-21 12:28:45 -07:00
Joe Mooring 150d190ff0 tpl/urls: Return empty string when JoinPath has zero args 2023-05-20 11:14:18 +02:00
Joe Mooring 5b3e165bad tpl/urls: Add JoinPath template function
See https://pkg.go.dev/net/url#JoinPath

Closes #9694
2023-05-19 10:31:17 +02:00
Oleksandr Redko bda082c98c
tpl: Add math.Abs
Fixes #10941.
2023-05-16 18:32:07 +02:00
Joe Mooring bcd7ac7704
Revert "Update syntax-highlighting.md (#10929)" (#10930)
This reverts commit a4fb8dc6bc.
2023-05-06 09:36:29 -07:00
Kirill Bobyrev a4fb8dc6bc
Update syntax-highlighting.md (#10929) 2023-05-06 07:00:37 -07:00
Joe Mooring b6f44aaf1a docs: Improve examples of variadic math functions 2023-03-12 10:32:01 +01:00
septs 84201e8d5d
tpl/math: Allow multi numbers in add, sub, mul, div, min and max 2023-03-11 11:21:08 +01:00
Jonathan Fisher d171d1543d tpl: Add hasSuffix alias
strings.HasPrefix already has an alias of hasPrefix
but strings.HasSuffix has no such alias.
This PR adds a hasSuffix alias to the tpl function with corresponding
function documentation.
It also adds a Minor update to the hasPrefix function documentation
re: keywords and relatedfuncs.

 Completes https://github.com/gohugoio/hugo/issues/10474
2023-03-08 10:18:34 +01:00
davidejones bebb2b8d0a switch transfers to workers 2023-03-07 15:38:26 +01:00
davidejones e6f029bdee customize parallel transfer count 2023-03-07 15:38:26 +01:00
Bjørn Erik Pedersen 97b010f521
Merge commit '336622d5e7afd9334cd2de7150d4f16bdf7c24f9' 2023-03-01 11:56:07 +01:00
Bjørn Erik Pedersen e442a63bb7 related: Add config option cardinalityThreshold
Fixes #10744
2023-02-23 17:06:22 +01:00
Bjørn Erik Pedersen d5601e8391
docs: Another fix related docs example 2023-02-23 11:09:55 +01:00
Bjørn Erik Pedersen cedd04db31
docs: Fix related docs example 2023-02-23 10:54:30 +01:00
Bjørn Erik Pedersen 7e539cb398
Merge commit 'cf591b7c0c598d34896709db6d28598da37e3ff6' 2023-02-23 07:52:04 +01:00
Bjørn Erik Pedersen 90da7664bf Add page fragments support to Related
The main topic of this commit is that you can now index fragments (content heading identifiers) when calling `.Related`.

You can do this by:

* Configure one or more indices with type `fragments`
* The name of those index configurations maps to an (optional) front matter slice with fragment references. This allows you to link
page<->fragment and page<->page.
* This also will index all the fragments (heading identifiers) of the pages.

It's also possible to use type `fragments` indices in shortcode, e.g.:

```
{{ $related := site.RegularPages.Related .Page }}
```

But, and this is important, you need to include the shortcode using the `{{<` delimiter. Not doing so will create infinite loops and timeouts.

This commit also:

* Adds two new methods to Page: Fragments (can also be used to build ToC) and HeadingsFiltered (this is only used in Related Content with
index type `fragments` and `enableFilter` set to true.
* Consolidates all `.Related*` methods into one, which takes either a `Page` or an options map as its only argument.
* Add `context.Context` to all of the content related Page API. Turns out it wasn't strictly needed for this particular feature, but it will
soon become usefil, e.g. in #9339.

Closes #10711
Updates #9339
Updates #10725
2023-02-21 17:56:41 +01:00
Bjørn Erik Pedersen 19e9605629
dos: Regen CLI docs 2023-01-17 12:52:53 +01:00
Bjørn Erik Pedersen b661132e0a
Merge commit 'ef6f101e75256c3bb88a6f1f3b5c1273bf8d7382' 2023-01-17 12:51:46 +01:00
Bjørn Erik Pedersen 6a579ebac3 Add fill HTTP Response info into .Data in resources.GetRemote
See #10604
2023-01-16 14:44:15 +01:00
Septs 3a216186b2 resource/page: Add Page.Ancestors
Fixes #10567
2022-12-23 10:14:53 +01:00
Bjørn Erik Pedersen 59af05cabc Add HUGO_PUBLISHDIR to the Node environment
So you can do  `process.env.HUGO_PUBLISHDIR` in your `postcss.config.js` to figure out where Hugo publishes
its files.

Note that the value will always be an absolute file path and will point to a directory on disk even when running `hugo server` in memory mode.

If you write to this folder from PostCSS when running the server, you could run the server with one of these flags:

```
hugo server --renderToDisk
hugo server --renderStaticToDisk
```

Fixes #10554
2022-12-22 12:43:50 +01:00
Bjørn Erik Pedersen 9a215d6950
Merge commit '41bc6f702aa54200530efbf4267e5c823df3028d' 2022-12-20 11:04:41 +01:00
Bjørn Erik Pedersen 330fa89411 modules: Adjust watch logic vs workspace use definitions 2022-12-19 20:17:33 +01:00
Bjørn Erik Pedersen de9c5542ca
docs: Add basic doc for wrapStandAloneImageWithinParagraph etc.
See #10492
2022-12-05 16:50:47 +01:00
Bjørn Erik Pedersen e93138dfdb dartsass: Add sourceMapIncludeSources option 2022-12-05 16:36:45 +01:00
Bjørn Erik Pedersen ef518485ce
Merge commit 'da16527896d3087585c5e758083ea498dcabc2c3' 2022-12-02 09:19:23 +01:00
Bjørn Erik Pedersen 0a019a1a59
docs: Regen CLI docs 2022-11-17 16:19:22 +01:00
Bjørn Erik Pedersen f04cc581e1
Merge commit '00c4484c7092181729f6f470805bc7d72e8ad17b' 2022-11-17 16:16:19 +01:00
Bjørn Erik Pedersen 09e10110a3 tpl/encoding: Add noHTMLEscape option to jsonify 2022-10-24 17:21:42 +02:00
JB 01ebb6e304
Don't use self-closing generator tag 2022-10-14 12:16:53 +02:00
Bjørn Erik Pedersen 4f9cb4f344
docs: Regenerate CLI docs 2022-09-22 17:57:13 +02:00
Bjørn Erik Pedersen a4028112e3 resources/images: Add $image.Colors
Which returns the most dominant colors of an image using a simple histogram method.

Fixes #10307
2022-09-22 15:57:35 +02:00
Bjørn Erik Pedersen a5cda5ca4d server: Add 404 support 2022-09-14 14:25:33 +02:00
Bjørn Erik Pedersen af23cdca9c
Merge commit '90ad8045056167004d27857a95542936657b8a16' 2022-09-13 20:34:24 +02:00
Bjørn Erik Pedersen 65e52a7f5c
Merge commit 'bdf935d66c1f02dfc942a30e9fc00519bba3aacb' 2022-06-28 20:51:33 +02:00
Bjørn Erik Pedersen 604cfffc5b
Merge commit '475f87f685439de0f907a9ffc29bfd1361eb1c59' 2022-06-16 07:22:11 +02:00
Khayyam Saleem 09ac733381 common: Add hugo.GoVersion
Closes #9849. This enables `hugo.GoVersion` in templates to access the
version of Go that the Hugo binary was built with.
2022-06-14 09:48:45 +02:00
Dawid Potocki 5a9ecb82a3 resources/page: Add :slugorfilename attribute
Fixes #4739, #385
2022-06-13 21:45:03 +02:00
Joe Mooring 953f215f32 tpl/path: Add path.BaseName function
Closes #9973
2022-06-06 09:36:16 +02:00
Bjørn Erik Pedersen 3fcbee261a
docs: Regen CLI docs 2022-05-31 10:24:01 +02:00
Bjørn Erik Pedersen 95baafeac4
Merge commit 'e4bfe59c4e043c92d3992587d8c64d264b262a22' 2022-05-31 10:22:05 +02:00
Bjørn Erik Pedersen 6f7bf3f2d7 Fix indentation in highlight shortcode
This commit adds a new `.InnerDeindent` method to the shortcode context, which is `.Inner` with any
indendation removed. This is then used in the built-in `highlight` shortcode to prevent the extra
whitespace getting hightlighted.

Fixes #4717
2022-05-31 09:05:54 +02:00
Bjørn Erik Pedersen 4b189d8fd9 postcss: Fix import error handling
Note that we will now fail if `inlineImports` is enabled and we cannot resolve an import.

You can work around this by either:

* Use url imports or imports with media queries.
* Set `skipInlineImportsNotFound=true` in the options

Also get the argument order in the different NewFileError* funcs in line.

Fixes #9895
2022-05-15 20:25:25 +02:00
Bjørn Erik Pedersen 855e5869c6
docs: Regen CLI docs 2022-05-08 16:57:29 +02:00
Bjørn Erik Pedersen 1c7759028e
Merge commit '327aaed6d8ca57d8e5e3acb99ff53402ff1c556d' 2022-05-08 16:56:42 +02:00
Bjørn Erik Pedersen 4852a37653
Merge commit '3902f9a4767fe6e62ac5146728d8311b8cd227e0' 2022-04-28 11:52:15 +02:00
Bjørn Erik Pedersen 2dbdf38a54 resources: Add key to reources.GetRemote options map
If set, `key` will be used as the only cache key element for the resource.

The default behaviour is to calculate the key based on the URL and all the options.

This means that you can now do:

```
{{ $cacheKey := print $url (now.Format "2006-01-02") }}
{{ $resource := resource.GetRemote $url (dict "key" $cacheKey) }}
```

Fixes #9755
2022-04-13 09:18:17 +02:00
Bjørn Erik Pedersen 5b5dcb8d5a
Merge commit 'ec920363cdeb687c8bcac9c242767d366fb058cb' 2022-04-08 13:32:01 +02:00
Bjørn Erik Pedersen ffe3eb9195
docs: Regen CLI docs 2022-04-08 13:31:50 +02:00
Cathrine Paulsen da00e7714e
Add environment as a new filter to _cascade.target
Fixes #9612
2022-04-05 09:41:24 +02:00
Bjørn Erik Pedersen 5b18e10841
docs: Regen CLI docs 2022-03-26 11:05:30 +02:00
Bjørn Erik Pedersen d7497b28c1
Merge commit 'd276e901b36d2576ef8350ed96b17f66254eac1b' 2022-03-26 11:04:57 +02:00
Joe Mooring 94e8a90769 tpl/crypto: Add optional encoding arg to hmac function
Closes #9709
2022-03-23 19:42:56 +01:00
Bjørn Erik Pedersen 3bc742bea0
docs: Regenerate CLI docs 2022-03-11 14:47:27 +01:00
Bjørn Erik Pedersen 7182809d96
docs: Regenerate CLI docs 2022-03-08 19:40:50 +01:00
Bjørn Erik Pedersen 9d76b8fa34
Merge commit 'd706529720b3b2ccb99719ccd578062ca25a0cc2' 2022-03-08 19:39:33 +01:00
Bjørn Erik Pedersen 41b5bc9637
Merge commit 'c1398b91a9f4c67876b31feb67516b252e654d3c' 2022-02-28 10:37:27 +01:00
Bjørn Erik Pedersen 14915a0c32
cod: Regen CLI docs 2022-02-28 08:12:35 +01:00
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
John Elliott 7732da9f93 Allow images to be cropped without being resized
Introduces the Crop method for image processing which implements gift.CropToSize. Also allows a smartCrop without resizing, and updates the documentation.

Fixes #9499
2022-02-23 10:01:50 +01:00
Bjørn Erik Pedersen a87be597af modules: Add modules.Workspace config for Go 1.18
Sets `GOWORK` env var for Go 1.18.

Fixes #9525
2022-02-18 15:06:58 +01:00
Bjørn Erik Pedersen f2e7b49acf Add --printUnusedTemplates
Fixes #9502
2022-02-15 20:01:57 +01:00
Bjørn Erik Pedersen 837fdfdf45
commands: Rename --i18n-warnings to printI18nWarnings
To get it in line with the others.
2022-02-15 13:03:36 +01:00
Bjørn Erik Pedersen 6819feab6c
commands: Rename --path-warnings, --print-men to --printPathWarnings, --printMemoryUsage
To get it in line with the others.
2022-02-15 13:00:06 +01:00
Bjørn Erik Pedersen c707b71cdf
Merge commit '230a495941b191af0bdaa7e2fc8c61607cb38207' 2022-02-14 12:58:42 +01:00
Joe Mooring d1109f590a Fix validation of Page Kind in cascade target map
Fixes #8888
2022-02-10 20:42:31 +01:00
Joe Mooring 54f8d8a70a Remove the "check" command
Closes #9454
2022-02-10 16:25:23 +01:00
Joe Mooring 3336762939 Remove hugo gen autocomplete
Closes #8862
2022-02-01 23:23:30 +01:00
Bjørn Erik Pedersen 098254f175
Merge commit 'a8e9fc699a6ff7d578f97a7c553ce844efad8fdb' 2022-01-12 08:16:35 +01:00
Bjørn Erik Pedersen fbb3c181cb
docs: Add dependency table to maintainance page
See #8949
2022-01-11 21:57:37 +01:00
Bjørn Erik Pedersen 7396aa945a Add hugo.Deps
Fixes #8949
2022-01-11 18:06:23 +01:00
Bjørn Erik Pedersen 74f0777c5f
docs. Regen CLI docs
Closes #9363
2022-01-07 12:37:07 +01:00
Bjørn Erik Pedersen 965760835d
docs: Regenerate CLI docs 2022-01-04 17:12:09 +01: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
Bjørn Erik Pedersen 6183184b96
Merge commit '45e6fdb315d113ba13e20a633ed0c67e3f25170d' 2021-12-13 21:05:10 +01:00
Bjørn Erik Pedersen 6c841a691e
Merge commit '8d9511a08f14260cbfb73119e4afae50e5a9966d' 2021-12-08 08:54:25 +01:00
Bjørn Erik Pedersen e71d715b9b Add custom font support to images.Text
Fixes #9253
2021-12-07 16:53:02 +01:00
Paul van Brouwershaven 283394a4fd
images: Text filter that draws text with the given options (#9239)
Fixes #9238
2021-12-07 11:29:55 +01:00
Joe Mooring 5538507e90 tpl/transform: Optional options for highlight func
Closes #9249
Fixes gohugoio/hugoDocs#63
2021-12-07 11:26:56 +01:00
Paul van Brouwershaven 0eaaa8fee3
Implement XML data support
Example:

```
{{ with resources.Get "https://example.com/rss.xml" | transform.Unmarshal }}
    {{ range .channel.item }}
        <strong>{{ .title | plainify | htmlUnescape }}</strong><br />
        <p>{{ .description | plainify | htmlUnescape }}</p>
        {{ $link := .link | plainify | htmlUnescape }}
        <a href="{{ $link }}">{{ $link }}</a><br />
        <hr>
    {{ end }}
{{ end }}
```

Closes #4470
2021-12-02 17:30:36 +01:00
Paul van Brouwershaven 66753416b5
Make resources.Get use a file cache for remote resources
Closes #9228
2021-12-02 12:56:25 +01:00
Paul van Brouwershaven 8aa7257f65
Add remote support to resources.Get
Closes #5255
Supports #9044
2021-11-30 11:49:51 +01:00
hugoreleaser ab01ba6e7e releaser: Add release notes to /docs for release of 0.89.4
[ci skip]
2021-11-17 08:24:08 +00:00
hugoreleaser c88cdb5610 releaser: Add release notes to /docs for release of 0.89.3
[ci skip]
2021-11-15 12:17:45 +00:00
hugoreleaser 63e3a5ebb2 releaser: Add release notes to /docs for release of 0.89.2
[ci skip]
2021-11-08 15:22:23 +00:00
hugoreleaser b6a4ae4ad5 releaser: Add release notes to /docs for release of 0.89.1
[ci skip]
2021-11-05 15:44:32 +00:00
hugoreleaser ade966b84b releaser: Add release notes to /docs for release of 0.89.0
[ci skip]
2021-11-02 10:00:17 +00:00
Bjørn Erik Pedersen f503b63957
docs: Regen CLI docs 2021-11-02 09:01:26 +01:00
Joe Mooring 0cc39af682 Update Twitter shortcode oEmbed endpoint
The existing endpoint will be retired and removed on November 23, 2021.
References:

- https://twittercommunity.com/t/consolidating-the-oembed-functionality/154690
- https://developer.twitter.com/en/docs/twitter-for-websites/oembed-api#Embedded

This is a backward compatible change.

The existing endpoint requires a single parameter: the id of the tweet.

The new endpoint requires two parameters: the id of the tweet, and the
user with whom it is associated. For the moment, if you supply the wrong
user, the request will be redirected (with a small delay) to the correct
user/id pair. This behavior is undocumented, but we will take advantage
of it as Hugo site authors transition to the new syntax.

{{< tweet 1453110110599868418 >}} --> works, throws warning, deprecate at some point

{{< tweet user="SanDiegoZoo" id="1453110110599868418" >}} --> new syntax

Fixes #8130
2021-11-01 15:51:00 +01:00
Bjørn Erik Pedersen 4b36498a85
Merge commit 'aa5ac36a3eb68b86c803caec703869efefc8447e' 2021-10-31 13:53:55 +01:00
Bjørn Erik Pedersen 471ed91c60 hugofs: Add includeFiles and excludeFiles to mount configuration
Fixes #9042
2021-10-20 05:00:17 +02:00
Joe Mooring 64abc83fc4 Allow multiple plugins in the PostCSS options map
Usage:
{{ $options := dict "use" "autoprefixer postcss-color-alpha" }}
{{ $style := resources.Get "main.css" | resources.PostCSS $options }}

Fixes #9015
2021-10-10 11:11:43 +02:00
Joe Mooring f8d132d731
docs: Create path.Clean documentation
Related to #9005
2021-10-09 20:36:57 +02:00
hugoreleaser 5bc547389a releaser: Add release notes to /docs for release of 0.88.1
[ci skip]
2021-09-04 09:39:19 +00:00
hugoreleaser acc5eb5b51 releaser: Add release notes to /docs for release of 0.88.0
[ci skip]
2021-09-02 09:27:27 +00:00