mirror of
https://github.com/gohugoio/hugo.git
synced 2024-05-11 05:54:58 +00:00
resource: Add front matter metadata to Resource
This commit expands the Resource interface with 3 new methods: * Name * Title * Params All of these can be set in the Page front matter. `Name` will get its default value from the base filename, and is the value used in the ByPrefix and GetByPrefix lookup methods. Fixes #4244
This commit is contained in:
@@ -147,3 +147,25 @@ func TestDecodeImaging(t *testing.T) {
|
||||
assert.Equal(42, imaging.Quality)
|
||||
assert.Equal("nearestneighbor", imaging.ResampleFilter)
|
||||
}
|
||||
|
||||
func TestImageWithMetadata(t *testing.T) {
|
||||
assert := require.New(t)
|
||||
|
||||
image := fetchSunset(assert)
|
||||
|
||||
var meta = []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
"title": "My Sunset",
|
||||
"name": "Sunset #:counter",
|
||||
"src": "*.jpg",
|
||||
},
|
||||
}
|
||||
|
||||
assert.NoError(AssignMetadata(meta, image))
|
||||
assert.Equal("Sunset #1", image.Name())
|
||||
|
||||
resized, err := image.Resize("200x")
|
||||
assert.NoError(err)
|
||||
assert.Equal("Sunset #1", resized.Name())
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user