Commit graph

1059 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
4d8bfa7f1c
tpl: Use xxHash instead of MD5 to hash the deferred templates
Motivation is performance. These templates are typically very small, so the win is minor, I guess.
2024-07-17 12:51:49 +02:00
Bjørn Erik Pedersen
f0ed91caba Throw error if resources.PostProcess is used in a deferred template
That just doesn't work.

See #12655
2024-07-17 12:47:25 +02:00
Bjørn Erik Pedersen
644d55475d Add hash.XxHash
Also move the non crypto hash funcs into this new package.

This is much faster than e.g. MD5, especially for larger inputs:

```
BenchmarkXxHash/xxHash_43-10         	 9917955	       112.2 ns/op	      56 B/op	       4 allocs/op
BenchmarkXxHash/mdb5_43-10           	 6017239	       204.1 ns/op	      96 B/op	       3 allocs/op
BenchmarkXxHash/fnv32a_43-10         	14407333	        82.30 ns/op	      16 B/op	       1 allocs/op
BenchmarkXxHash/xxHash_4300-10       	 2916892	       409.7 ns/op	      56 B/op	       4 allocs/op
BenchmarkXxHash/mdb5_4300-10         	  159748	      7491 ns/op	    4912 B/op	       3 allocs/op
BenchmarkXxHash/fnv32a_4300-10       	  218210	      5510 ns/op	      16 B/op	       1 allocs/op
```

Fixes #12635
2024-07-06 14:08:15 +02:00
Bjørn Erik Pedersen
e1317dd322 Add css.TailwindCSS
Closes #12618
Closes #12620
2024-06-25 15:48:02 +02:00
Bjørn Erik Pedersen
eddcd2bac6 Clean up the css related template funcs package structure
Deprecate and move:

* resources.ToCSS => css.SASS
* resources.PostProcess => css.PostProcess
* resources.Babel => js.Babel

Updates #12618
2024-06-25 15:48:02 +02:00
Bjørn Erik Pedersen
c880faa998
tpl/debug: Fix reset of debug timers when running the server
Fixes #12621
2024-06-24 12:49:35 +02:00
Bjørn Erik Pedersen
6cd0784e44 Implement defer
Closes #8086
Closes #12589
2024-06-23 11:25:47 +02:00
Bjørn Erik Pedersen
8731d88222
Fix Erroridf/Warnidf mixed case issue
Fixes #12617
2024-06-22 19:01:56 +02:00
Bjørn Erik Pedersen
447108fed2
Add a HTTP cache for remote resources.
Fixes #12502
Closes #11891
2024-06-04 16:07:39 +02:00
Joe Mooring
b893a09aa6 tpl/tplimpl: Resolve render hook destinations with leading ./
Closes #12514
2024-05-21 09:38:25 +02:00
Joe Mooring
74ab839ccb tpl/tplimpl: Plainify title and description in twitter_cards.html
Closes #12433
Improves #10900
2024-05-14 14:45:04 +02:00
Joe Mooring
92290aa892 tpl/tplimpl: Plainify title and description in schema.html
Closes #12432
2024-05-14 14:18:49 +02:00
Bjørn Erik Pedersen
e2d66e3218
Create pages from _content.gotmpl
Closes #12427
Closes #12485
Closes #6310
Closes #5074
2024-05-14 13:12:08 +02:00
Joe Mooring
87ab7f7ffc tpl/tplimpl: Improve locale value in opengraph.html
Closes #12480
2024-05-14 10:24:17 +02:00
Joe Mooring
6dfeb9f038 tpl/tplimpl: Retain query string and fragment in render-image.html
Closes #12468
2024-05-10 22:32:48 +02:00
Bjørn Erik Pedersen
503d20954f
Make the cache eviction logic for stale entities more robust
Fixes #12458
2024-05-04 19:45:43 +02:00
Bjørn Erik Pedersen
7203a95a60 Fix rebuilds when running hugo -w
This was partly broken in Hugo 0.123.0.

We have two internal config options that gets set from the CLI:

* Running; a web server is running
* Watching; either set via `hugo -w`  or `hugo server --watch=false`

Part of the change detection code wrongly used the `Running` as a flag when `Watching` would be the correct.

Fixes #12296
2024-04-25 14:35:49 +02:00
Joe Mooring
fb51b698b3 tpl/tplimpl: Fix double-escaping in opengraph template
Closes #12418
2024-04-25 10:03:17 +02:00
Bjørn Erik Pedersen
15a4b9b337 tpl: Escape .Title in built-in image and link render hooks
Co-authored-by: Joe Mooring <joe@mooring.com>
2024-04-22 16:54:24 +02:00
Joe Mooring
10a8448eee tpl/tplimpl: Improve embedded templates
- Do not call the YouTube oEmbed API
- Do not include the Hugo version in RSS feeds

Closes #12396
2024-04-22 15:57:37 +02:00
Bjørn Erik Pedersen
0c188fda24 tpl: Use erroridf for remote YouTube errors
So they can be silenced.

Fixes #12383
2024-04-18 10:02:36 +02:00
Bjørn Erik Pedersen
df11327ba9 Pass .RenderShortcodes' Page to render hooks as .PageInner
The main use case for this is to resolve links and resources (e.g. images) relative to the included `Page`.

A typical `include` would similar to this:

```handlebars
{{ with site.GetPage (.Get 0) }}
  {{ .RenderShortcodes }}
{{ end }}
```

And when used in a Markdown file:

```markdown
{{% include "/posts/p1" %}}
```

Any render hook triggered while rendering `/posts/p1` will get `/posts/p1` when calling `.PageInner`.

Note that

* This is only relevant for shortcodes included with `{{%` that calls `.RenderShortcodes`.
* `.PageInner` is available in all render hooks that, before this commit, received `.Page`.
* `.PageInner` will fall back to the value of `.Page` if not relevant and will always have a value.

Fixes #12356
2024-04-15 09:49:57 +02:00
Joe Mooring
6049ba99f0 helpers: Fix TrimShortHTML when used with AsciiDoc content
Fixes #12369
2024-04-14 17:53:05 +02:00
Eitan Adler
bf0b140364
all: Fix duplicate words in comments 2024-04-11 09:31:33 +02:00
Joe Mooring
7bf1abfc55 tpl/strings: Improve type checking 2024-04-04 18:34:55 +02:00
Joe Mooring
8a0ea12d8a tpl/tplimpl: Improve youtube shortcode
Changes:

- Add query string params for controls, loop, mute, start, and end
- Add iframe loading attribute
- Obtain default iframe title from YouTube oEmbed API
- Fix autoplay feature
- Improve readability

Closes #3694
Closes #9213
Closes #10520
Closes #10575
Closes #10576

Co-authored-by: sgharms <sgharms@stevengharms.com>
2024-04-04 11:08:30 +02:00
seiya
6f07e5976d errors: Return error from cast.ToStringE() consistently 2024-04-04 11:00:14 +02:00
Joe Mooring
2da4ec5738 tpl/tplimpl: Improve embedded opengraph template
Changes:

- Add tags per documentation
- Prefer site.Title over site.Params.title
- Plainify titles, tags, and descriptions
- Add fallback values for locale
- Fix pages related by series
- Improve readability

Closes #8296
Closes #8698
Closes #8991
Closes #9818
Closes #9866
Closes #10647

Co-authored-by: tomy0000000 <git@tomy.me>
Co-authored-by: sean-au <sean@powerfulwebdesign.com.au>
2024-04-02 18:35:43 +02:00
Joe Mooring
6624979e1b tpl/strings: Create strings.Diff template function
Closes #12330
2024-04-02 18:25:44 +02:00
Joe Mooring
6738a3e79d tpl/tplimpl: Optionally exclude content from sitemap
Define global inclusion/exclusion in site configuration, and override
via front matter. For example, to exclude a page from the sitemap:

    [sitemap]
    disable = true # default is false

Closes #653
Closes #12282

Co-authored-by: kolappannathan <kolappannathan@users.noreply.github.com>
Co-authored-by: felicianotech <FelicianoTech@gmail.com>
2024-04-02 11:21:03 +02:00
Joe Mooring
2f7df4b926
tpl/tplimpl: Remove trailing slash from void elements
Closes #11867
2024-04-01 08:07:02 -07:00
Joe Mooring
f0a26cf58e tpl/tplimpl: Update RSS template
- Use publication date for pubdate
- Include version in generator element

Closes #3918
Closes #11692
2024-03-30 18:32:58 +01:00
Joe Mooring
74ce5dc841 tpl/tplimpl: Update schema template
Changes:

- Remove trailing comma from list of keywords.
- Improve keywords precedence:
  1. Use "keywords" term page titles.
  2. Use "keywords" from front matter if "keywords" is not a taxonomy.
  3. Use "tags" term page titles.
  4. Use term page titles from all taxonomies.
- Enable schema for all page kinds, previously limited to kind = page.
- Remove trailing slashes from void elements.
- Improve readability.

Closes #7570

Co-authored by: 0urobor0s <0urobor0s@users.noreply.github.com>
2024-03-28 14:56:02 +01:00
Bjørn Erik Pedersen
38e05bd3c7 Fix panic with debug.Dump with Page when running the server
This replaces the current implementation with `json.MarshalIndent` which doesn't produce the same output, but at least it doesn't crash.

There's a bug in the upstream `litter` library. This can probably be fixed, but that needs to wait.

I have tested `go-spew` which does not crash, but it is very data racy in this context.

FIxes #12309
2024-03-26 20:41:30 +01:00
Joe Mooring
ebfca61ac4 tpl/tplimpl: Update Google Analytics template and config
Google Analytics 4 (GA4) replaced Google Universal Analytics (UA)
effective 1 July 2023.

See https://support.google.com/analytics/answer/11583528.

Changes:

- Update tpl/tplimpl/embedded/templates/google_analytics.html
- Remove tpl/tplimpl/embedded/templates/google_analytics_async.html
- Remove extraneous config settings

Closes #11802
Closes #10093
2024-03-26 15:40:51 +01:00
Joe Mooring
d4d49e0f0e hugolib: Deprecate site methods Author, Authors, and Social
Closes #12228
2024-03-15 17:26:45 +01:00
Bjørn Erik Pedersen
b40f3c7df6 Fix intersect and similar for term entry page collections
Fixes #12254
2024-03-15 16:45:53 +01:00
Bjørn Erik Pedersen
57206e7274 Upgrade to Go 1.22.1
Closes #12250
2024-03-15 16:40:36 +01:00
Joe Mooring
f038a51b3e tpl/tplimpl: Remove deprecated method from sitemapindex.xml 2024-03-14 21:03:19 +01:00
Joe Mooring
48a0fea87a tpl/tplimpl: Modify figure shortcode to look for page resource
Closes #12244
Closes #12245
2024-03-14 10:21:40 +02:00
Bjørn Erik Pedersen
9e9b1f110c Fix Name for nested resourced fetched in resources.ByName and similar
Fixes #12214
2024-03-13 18:59:50 +02:00
Bjørn Erik Pedersen
a4b17470a8 Fix resource name in resources.ByType
Fixes #12190
2024-03-07 09:50:50 +01:00
Bjørn Erik Pedersen
4d5e173cf8 Fix global resource isn't published when using an uncommon code construct
Fixes #12190
2024-03-07 09:50:50 +01:00
Joe Mooring
632ad74fc5 tpl/tplimpl: Honor markdown attributes in embedded image render hook
Fixes #12203
2024-03-07 08:21:58 +01:00
Bjørn Erik Pedersen
7023cf0f07 Fix resources.GetMatch, resources.Match, and resources.ByType to they don't normalize permalinks
Fixes #12182
2024-03-01 13:34:05 +01:00
Joe Mooring
c9f7ebf004 tpl/tplimpl: Resolve fragments in link render hook
Fixes #12084
2024-02-21 09:11:34 +01:00
Bjørn Erik Pedersen
5dbc29dc6c Handle rebuilds when resources passed to transform.Unmarshal etc. changes
Fixes #12065
2024-02-19 14:50:23 +01:00
Christian Oliff
0672b5c766
all: Fix typos 2024-02-11 13:51:33 +02:00
Joe Mooring
d0788b96ae tpl/tplimpl: Update embedded instagram, twitter, and vimeo shortcodes
- Replace data.GetJSON calls with resources.GetRemote
- Remove usage of Facebook’s oEmbed Read feature

Fixes #11971
2024-02-02 08:01:45 +01:00
Joe Mooring
5dd06b4136 tpl/data: Fix GetCSV deprecation message 2024-02-01 19:21:15 +01:00