👔 Fixed resources filters in Page and Site use cases

This commit is contained in:
Maxim Lebedev 2023-11-09 07:51:45 +06:00
parent dd9cc5b2d1
commit db68a8d768
Signed by: toby3d
GPG Key ID: 1F14E25B7C119FC5
2 changed files with 16 additions and 3 deletions

View File

@ -54,12 +54,14 @@ func (ucase *pageUseCase) Do(ctx context.Context, lang language.Tag, p string) (
return out, nil
}
for j := range out.Files {
if ext := out.Files[j].Ext(); ext != ".html" && ext != ".md" {
for j := 0; j < len(out.Files); j++ {
if ext := out.Files[j].Ext(); ext != "html" && ext != "md" {
continue
}
out.Files = slices.Delete(out.Files, j, j+1)
j--
}
return out, nil

View File

@ -3,6 +3,7 @@ package usecase
import (
"context"
"fmt"
"slices"
"golang.org/x/text/language"
@ -29,7 +30,17 @@ func (ucase *siteUseCase) Do(ctx context.Context, lang language.Tag) (*domain.Si
return nil, fmt.Errorf("cannot find base site data: %w", err)
}
out.Files, _, _ = ucase.statics.Fetch(ctx, ".")
if out.Files, _, err = ucase.statics.Fetch(ctx, "."); err == nil {
for i := 0; i < len(out.Files); i++ {
if ext := out.Files[i].Ext(); ext != "html" && ext != "md" {
continue
}
out.Files = slices.Delete(out.Files, i, i+1)
i--
}
}
sub, err := ucase.sites.Get(ctx, lang)
if err != nil {