Chore: Avoid showing plugin version if it's %VERSION% (#75974)

This commit is contained in:
Andres Martinez Gotor
2023-10-11 10:49:30 +02:00
committed by GitHub
parent d5691e6dd1
commit 1f8b08202e
3 changed files with 50 additions and 4 deletions
@@ -30,6 +30,7 @@ func DefaultConstructFunc(signatureCalculator plugins.SignatureCalculator, asset
func DefaultDecorateFuncs(cfg *config.Cfg) []DecorateFunc {
return []DecorateFunc{
AppDefaultNavURLDecorateFunc,
TemplateDecorateFunc,
AppChildDecorateFunc(cfg),
}
}
@@ -86,6 +87,22 @@ func AppDefaultNavURLDecorateFunc(_ context.Context, p *plugins.Plugin) (*plugin
return p, nil
}
// TemplateDecorateFunc is a DecorateFunc that removes the placeholder for the version and last_update fields.
func TemplateDecorateFunc(_ context.Context, p *plugins.Plugin) (*plugins.Plugin, error) {
// %VERSION% and %TODAY% are valid values, according to the plugin schema
// but it's meant to be replaced by the build system with the actual version and date.
// If not, it's the same than not having a version or a date.
if p.Info.Version == "%VERSION%" {
p.Info.Version = ""
}
if p.Info.Updated == "%TODAY%" {
p.Info.Updated = ""
}
return p, nil
}
func setDefaultNavURL(p *plugins.Plugin) {
// slugify pages
for _, include := range p.Includes {