🗃️ Set File property for Page in page repository
This commit is contained in:
parent
49824ed100
commit
408ac2e8a3
|
@ -4,7 +4,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"strings"
|
||||
|
||||
"github.com/adrg/frontmatter"
|
||||
"golang.org/x/text/language"
|
||||
|
@ -45,11 +44,11 @@ func (repo *fileSystemPageRepository) Get(ctx context.Context, lang language.Tag
|
|||
ext = "." + base.String() + ext
|
||||
}
|
||||
|
||||
index := p + ext
|
||||
target := p + ext
|
||||
|
||||
f, err := repo.dir.Open(index)
|
||||
f, err := repo.dir.Open(target)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cannot open '%s' page file: %w", index, err)
|
||||
return nil, fmt.Errorf("cannot open '%s' page file: %w", target, err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
|
@ -61,12 +60,12 @@ func (repo *fileSystemPageRepository) Get(ctx context.Context, lang language.Tag
|
|||
}
|
||||
|
||||
return &domain.Page{
|
||||
File: domain.NewFile(target),
|
||||
Language: lang,
|
||||
Title: data.Title,
|
||||
Content: data.Content,
|
||||
Description: data.Description,
|
||||
Params: data.Params,
|
||||
Resources: make([]*domain.Resource, 0),
|
||||
IsHome: strings.HasPrefix(index, "index.") && strings.HasSuffix(index, ".md"),
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue