41 lines
818 B
Go
41 lines
818 B
Go
package domain
|
|
|
|
import (
|
|
"path"
|
|
"testing"
|
|
)
|
|
|
|
type Entry struct {
|
|
Language Language
|
|
Params map[string]any
|
|
File Path
|
|
Description string
|
|
Title string
|
|
Content []byte
|
|
Resources Resources
|
|
Translations []*Entry
|
|
}
|
|
|
|
func (e Entry) IsHome() bool {
|
|
return e.File.dir == "./" && e.File.translationBaseName == "index"
|
|
}
|
|
|
|
func (e Entry) IsTranslated() bool {
|
|
return 1 < len(e.Translations)
|
|
}
|
|
|
|
func TestEntry(tb testing.TB) *Entry {
|
|
tb.Helper()
|
|
|
|
return &Entry{
|
|
Language: NewLanguage("en"),
|
|
Params: make(map[string]any),
|
|
File: NewPath(path.Join("sample-page.en.md")),
|
|
Description: "do not use in production",
|
|
Title: "Sample Page",
|
|
Content: []byte("Hello, world!"),
|
|
Resources: make([]*Resource, 0),
|
|
Translations: make([]*Entry, 0),
|
|
}
|
|
}
|