resources/page: Expand parmalinks tokens in url

This change allows to use permalink tokens in url front matter fields. This should be useful to target more specific pages instead of using a global permalink configuration. It's expected to be used with cascade.

Fixes #9714
This commit is contained in:
n1xx1
2024-08-01 12:14:29 +02:00
committed by GitHub
parent 92573012e8
commit 566fe7ba12
7 changed files with 101 additions and 21 deletions

View File

@@ -40,22 +40,25 @@ func (c *Cache[K, T]) Get(key K) (T, bool) {
}
// GetOrCreate gets the value for the given key if it exists, or creates it if not.
func (c *Cache[K, T]) GetOrCreate(key K, create func() T) T {
func (c *Cache[K, T]) GetOrCreate(key K, create func() (T, error)) (T, error) {
c.RLock()
v, found := c.m[key]
c.RUnlock()
if found {
return v
return v, nil
}
c.Lock()
defer c.Unlock()
v, found = c.m[key]
if found {
return v
return v, nil
}
v, err := create()
if err != nil {
return v, err
}
v = create()
c.m[key] = v
return v
return v, nil
}
// Set sets the given key to the given value.