mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-19 07:42:48 +00:00
Compare commits
5 commits
7e773bd01d
...
b69ed130a9
Author | SHA1 | Date | |
---|---|---|---|
b69ed130a9 | |||
5b40662160 | |||
c46d603a02 | |||
69ede10edc | |||
bb59a7ed97 |
|
@ -1065,6 +1065,15 @@ config:
|
|||
enable: false
|
||||
escapedSpace: false
|
||||
definitionList: true
|
||||
extras:
|
||||
insert:
|
||||
enable: false
|
||||
mark:
|
||||
enable: false
|
||||
subscript:
|
||||
enable: false
|
||||
superscript:
|
||||
enable: false
|
||||
footnote: true
|
||||
linkify: true
|
||||
linkifyProtocol: https
|
||||
|
|
1
go.mod
1
go.mod
|
@ -35,6 +35,7 @@ require (
|
|||
github.com/gobuffalo/flect v1.0.2
|
||||
github.com/gobwas/glob v0.2.3
|
||||
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e
|
||||
github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0
|
||||
github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.2.0
|
||||
github.com/gohugoio/locales v0.14.0
|
||||
github.com/gohugoio/localescompressed v1.0.1
|
||||
|
|
2
go.sum
2
go.sum
|
@ -211,6 +211,8 @@ github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
|||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e h1:QArsSubW7eDh8APMXkByjQWvuljwPGAGQpJEFn0F0wY=
|
||||
github.com/gohugoio/go-i18n/v2 v2.1.3-0.20230805085216-e63c13218d0e/go.mod h1:3Ltoo9Banwq0gOtcOwxuHG6omk+AwsQPADyw2vQYOJQ=
|
||||
github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0 h1:YhxZNU8y2vxV6Ibr7QJzzUlpr8oHHWX/l+Q1R/a5Zao=
|
||||
github.com/gohugoio/hugo-goldmark-extensions/extras v0.1.0/go.mod h1:0cuvOnGKW7WeXA3i7qK6IS07FH1bgJ2XzOjQ7BMJYH4=
|
||||
github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.2.0 h1:PCtO5l++psZf48yen2LxQ3JiOXxaRC6v0594NeHvGZg=
|
||||
github.com/gohugoio/hugo-goldmark-extensions/passthrough v0.2.0/go.mod h1:g9CCh+Ci2IMbPUrVJuXbBTrA+rIIx5+hDQ4EXYaQDoM=
|
||||
github.com/gohugoio/locales v0.14.0 h1:Q0gpsZwfv7ATHMbcTNepFd59H7GoykzWJIxi113XGDc=
|
||||
|
|
|
@ -23,11 +23,9 @@ import (
|
|||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/bep/logg"
|
||||
"github.com/gohugoio/hugo/cache/dynacache"
|
||||
"github.com/gohugoio/hugo/deps"
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
"github.com/gohugoio/hugo/hugofs/files"
|
||||
|
@ -47,7 +45,6 @@ import (
|
|||
"github.com/gohugoio/hugo/resources/page"
|
||||
"github.com/gohugoio/hugo/resources/page/siteidentities"
|
||||
"github.com/gohugoio/hugo/resources/postpub"
|
||||
"github.com/gohugoio/hugo/resources/resource"
|
||||
|
||||
"github.com/spf13/afero"
|
||||
|
||||
|
@ -764,48 +761,8 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf
|
|||
}
|
||||
}
|
||||
case files.ComponentFolderAssets:
|
||||
p := pathInfo.Path()
|
||||
logger.Println("Asset changed", p)
|
||||
|
||||
var matches []any
|
||||
var mu sync.Mutex
|
||||
|
||||
h.MemCache.ClearMatching(
|
||||
func(k string, pm dynacache.PartitionManager) bool {
|
||||
// Avoid going through everything.
|
||||
return strings.HasPrefix(k, "/res")
|
||||
},
|
||||
func(k, v any) bool {
|
||||
if strings.Contains(k.(string), p) {
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
switch vv := v.(type) {
|
||||
case resource.Resources:
|
||||
// GetMatch/Match.
|
||||
for _, r := range vv {
|
||||
matches = append(matches, r)
|
||||
}
|
||||
return true
|
||||
default:
|
||||
matches = append(matches, vv)
|
||||
return true
|
||||
|
||||
}
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
var hasID bool
|
||||
for _, r := range matches {
|
||||
identity.WalkIdentitiesShallow(r, func(level int, rid identity.Identity) bool {
|
||||
hasID = true
|
||||
changes = append(changes, rid)
|
||||
return false
|
||||
})
|
||||
}
|
||||
if !hasID {
|
||||
changes = append(changes, pathInfo)
|
||||
}
|
||||
logger.Println("Asset changed", pathInfo.Path())
|
||||
changes = append(changes, pathInfo)
|
||||
case files.ComponentFolderData:
|
||||
logger.Println("Data changed", pathInfo.Path())
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
# Release env.
|
||||
# These will be replaced by script before release.
|
||||
HUGORELEASER_TAG=v0.125.5
|
||||
HUGORELEASER_COMMITISH=c8b9f9f81c375f5b391e61bae711ee63fc76c1fd
|
||||
HUGORELEASER_TAG=v0.125.6
|
||||
HUGORELEASER_COMMITISH=69ede10edcd539380914bbee58d4d32953dd8b43
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ package goldmark
|
|||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/gohugoio/hugo-goldmark-extensions/extras"
|
||||
"github.com/gohugoio/hugo-goldmark-extensions/passthrough"
|
||||
"github.com/gohugoio/hugo/markup/goldmark/hugocontext"
|
||||
"github.com/yuin/goldmark/util"
|
||||
|
@ -194,6 +195,38 @@ func newMarkdown(pcfg converter.ProviderConfig) goldmark.Markdown {
|
|||
))
|
||||
}
|
||||
|
||||
if cfg.Extensions.Extras.Insert.Enable {
|
||||
extensions = append(extensions, extras.New(
|
||||
extras.Config{
|
||||
Insert: extras.InsertConfig{Enable: cfg.Extensions.Extras.Insert.Enable},
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
if cfg.Extensions.Extras.Mark.Enable {
|
||||
extensions = append(extensions, extras.New(
|
||||
extras.Config{
|
||||
Mark: extras.MarkConfig{Enable: cfg.Extensions.Extras.Mark.Enable},
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
if cfg.Extensions.Extras.Subscript.Enable {
|
||||
extensions = append(extensions, extras.New(
|
||||
extras.Config{
|
||||
Subscript: extras.SubscriptConfig{Enable: cfg.Extensions.Extras.Subscript.Enable},
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
if cfg.Extensions.Extras.Superscript.Enable {
|
||||
extensions = append(extensions, extras.New(
|
||||
extras.Config{
|
||||
Superscript: extras.SuperscriptConfig{Enable: cfg.Extensions.Extras.Superscript.Enable},
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
if pcfg.Conf.EnableEmoji() {
|
||||
extensions = append(extensions, emoji.Emoji)
|
||||
}
|
||||
|
|
|
@ -49,6 +49,20 @@ var Default = Config{
|
|||
EastAsianLineBreaksStyle: "simple",
|
||||
EscapedSpace: false,
|
||||
},
|
||||
Extras: Extras{
|
||||
Superscript: Superscript{
|
||||
Enable: false,
|
||||
},
|
||||
Subscript: Subscript{
|
||||
Enable: false,
|
||||
},
|
||||
Insert: Insert{
|
||||
Enable: false,
|
||||
},
|
||||
Mark: Mark{
|
||||
Enable: false,
|
||||
},
|
||||
},
|
||||
Passthrough: Passthrough{
|
||||
Enable: false,
|
||||
Delimiters: DelimitersConfig{
|
||||
|
@ -112,6 +126,7 @@ type Extensions struct {
|
|||
Typographer Typographer
|
||||
Footnote bool
|
||||
DefinitionList bool
|
||||
Extras Extras
|
||||
Passthrough Passthrough
|
||||
|
||||
// GitHub flavored markdown
|
||||
|
@ -150,7 +165,32 @@ type Typographer struct {
|
|||
Apostrophe string
|
||||
}
|
||||
|
||||
// Passthrough hold passthrough configuration.
|
||||
// Extras holds extras configuration.
|
||||
// github.com/hugoio/hugo-goldmark-extensions/extras
|
||||
type Extras struct {
|
||||
Insert Insert
|
||||
Mark Mark
|
||||
Subscript Subscript
|
||||
Superscript Superscript
|
||||
}
|
||||
|
||||
type Insert struct {
|
||||
Enable bool
|
||||
}
|
||||
|
||||
type Mark struct {
|
||||
Enable bool
|
||||
}
|
||||
|
||||
type Subscript struct {
|
||||
Enable bool
|
||||
}
|
||||
|
||||
type Superscript struct {
|
||||
Enable bool
|
||||
}
|
||||
|
||||
// Passthrough holds passthrough configuration.
|
||||
// github.com/hugoio/hugo-goldmark-extensions/passthrough
|
||||
type Passthrough struct {
|
||||
// Whether to enable the extension
|
||||
|
|
|
@ -744,3 +744,53 @@ a^*=x-b^*
|
|||
%!%
|
||||
`)
|
||||
}
|
||||
|
||||
func TestExtrasExtension(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ['page','rss','section','sitemap','taxonomy','term']
|
||||
[markup.goldmark.extensions.extras.insert]
|
||||
enable = false
|
||||
[markup.goldmark.extensions.extras.mark]
|
||||
enable = false
|
||||
[markup.goldmark.extensions.extras.subscript]
|
||||
enable = false
|
||||
[markup.goldmark.extensions.extras.superscript]
|
||||
enable = false
|
||||
-- layouts/index.html --
|
||||
{{ .Content }}
|
||||
-- content/_index.md --
|
||||
---
|
||||
title: home
|
||||
---
|
||||
++insert++
|
||||
|
||||
==mark==
|
||||
|
||||
H~2~0
|
||||
|
||||
1^st^
|
||||
`
|
||||
|
||||
b := hugolib.Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.html",
|
||||
"<p>++insert++</p>",
|
||||
"<p>==mark==</p>",
|
||||
"<p>H~2~0</p>",
|
||||
"<p>1^st^</p>",
|
||||
)
|
||||
|
||||
files = strings.ReplaceAll(files, "enable = false", "enable = true")
|
||||
|
||||
b = hugolib.Test(t, files)
|
||||
|
||||
b.AssertFileContent("public/index.html",
|
||||
"<p><ins>insert</ins></p>",
|
||||
"<p><mark>mark</mark></p>",
|
||||
"<p>H<sub>2</sub>0</p>",
|
||||
"<p>1<sup>st</sup></p>",
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2021 The Hugo Authors. All rights reserved.
|
||||
// Copyright 2024 The Hugo Authors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -328,6 +328,7 @@ Styles: {{ $r.RelPermalink }}
|
|||
b.AssertFileContent("public/index.html", "Styles: /scss/main.css")
|
||||
}
|
||||
|
||||
// Issue #1239.
|
||||
func TestRebuildAssetGetMatch(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !scss.Supports() {
|
||||
|
@ -358,3 +359,61 @@ T1: {{ $r.Content }}
|
|||
|
||||
b.AssertFileContent("public/index.html", `color: blue`)
|
||||
}
|
||||
|
||||
func TestRebuildAssetMatchIssue12456(t *testing.T) {
|
||||
t.Parallel()
|
||||
if !scss.Supports() {
|
||||
t.Skip()
|
||||
}
|
||||
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
disableKinds = ["term", "taxonomy", "section", "page"]
|
||||
disableLiveReload = true
|
||||
-- assets/a.scss --
|
||||
h1 {
|
||||
color: red;
|
||||
}
|
||||
-- assets/dir/b.scss --
|
||||
h2 {
|
||||
color: blue;
|
||||
}
|
||||
-- assets/dir/c.scss --
|
||||
h3 {
|
||||
color: green;
|
||||
}
|
||||
-- layouts/index.html --
|
||||
{{ $a := slice (resources.Get "a.scss") }}
|
||||
{{ $b := resources.Match "dir/*.scss" }}
|
||||
|
||||
{{/* Add styles in a specific order. */}}
|
||||
{{ $styles := slice $a $b }}
|
||||
|
||||
{{ $stylesheets := slice }}
|
||||
{{ range $styles }}
|
||||
{{ $stylesheets = $stylesheets | collections.Append . }}
|
||||
{{ end }}
|
||||
|
||||
|
||||
{{ range $stylesheets }}
|
||||
{{ with . | resources.ToCSS | fingerprint }}
|
||||
<link as="style" href="{{ .RelPermalink }}" rel="preload stylesheet">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
`
|
||||
|
||||
b := hugolib.NewIntegrationTestBuilder(
|
||||
hugolib.IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
NeedsOsFS: true,
|
||||
Running: true,
|
||||
// LogLevel: logg.LevelTrace,
|
||||
}).Build()
|
||||
|
||||
b.AssertFileContent("public/index.html", `b.60a9f3bdc189ee8a857afd5b7e1b93ad1644de0873761a7c9bc84f781a821942.css`)
|
||||
|
||||
b.EditFiles("assets/dir/b.scss", `h2 { color: orange; }`).Build()
|
||||
|
||||
b.AssertFileContent("public/index.html", `b.46b2d77c7ffe37ee191678f72df991ecb1319f849957151654362f09b0ef467f.css`)
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ var (
|
|||
_ resource.ReadSeekCloserResource = (*resourceAdapter)(nil)
|
||||
_ resource.Resource = (*resourceAdapter)(nil)
|
||||
_ resource.Staler = (*resourceAdapterInner)(nil)
|
||||
_ identity.IdentityGroupProvider = (*resourceAdapterInner)(nil)
|
||||
_ resource.Source = (*resourceAdapter)(nil)
|
||||
_ resource.Identifier = (*resourceAdapter)(nil)
|
||||
_ resource.ResourceNameTitleProvider = (*resourceAdapter)(nil)
|
||||
|
@ -657,6 +658,10 @@ type resourceAdapterInner struct {
|
|||
*publishOnce
|
||||
}
|
||||
|
||||
func (r *resourceAdapterInner) GetIdentityGroup() identity.Identity {
|
||||
return r.target.GetIdentityGroup()
|
||||
}
|
||||
|
||||
func (r *resourceAdapterInner) StaleVersion() uint32 {
|
||||
// Both of these are incremented on change.
|
||||
return r.Staler.StaleVersion() + r.target.StaleVersion()
|
||||
|
|
Loading…
Reference in a new issue