-
Notifications
You must be signed in to change notification settings - Fork 0
/
type.go
166 lines (126 loc) · 4.22 KB
/
type.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package hugosites
import (
fsVO "github.com/dddplayer/hugoverse/internal/domain/fs/valueobject"
"github.com/dddplayer/hugoverse/internal/domain/hugosites/valueobject"
"github.com/dddplayer/hugoverse/internal/domain/site"
"io"
)
// Publisher publishes a result file.
type Publisher interface {
Publish(d Descriptor) error
}
// Descriptor describes the needed publishing chain for an item.
type Descriptor struct {
// The content to publish.
Src io.Reader
// The OutputFormat of this content.
OutputFormat valueobject.Format
// Where to publish this content. This is a filesystem-relative path.
TargetPath string
// If set, will replace all relative URLs with this one.
AbsURLPath string
}
const (
KindPage = "page"
// The rest are node types; home page, sections etc.
KindHome = "home"
KindSection = "section"
)
// File represents a source file.
// This is a temporary construct until we resolve page.Page conflicts.
// TODO(bep) remove this construct once we have resolved page deprecations
type File interface {
fileOverlap
FileWithoutOverlap
}
// Temporary to solve duplicate/deprecated names in page.Page
type fileOverlap interface {
// Path gets the relative path including file name and extension.
// The directory is relative to the content root.
Path() string
// Section is first directory below the content root.
// For page bundles in root, the Section will be empty.
Section() string
IsZero() bool
}
type FileWithoutOverlap interface {
// Filename gets the full path and filename to the file.
Filename() string
// Dir gets the name of the directory that contains this file.
// The directory is relative to the content root.
Dir() string
// Extension is an alias to Ext().
// Deprecated: Use Ext instead.
Extension() string
// Ext gets the file extension, i.e "myblogpost.md" will return "md".
Ext() string
// LogicalName is filename and extension of the file.
LogicalName() string
// BaseFileName is a filename without extension.
BaseFileName() string
// TranslationBaseName is a filename with no extension,
// not even the optional language extension part.
TranslationBaseName() string
// ContentBaseName is a either TranslationBaseName or name of containing folder
// if file is a leaf bundle.
ContentBaseName() string
// UniqueID is the MD5 hash of the file's path and is for most practical applications,
// Hugo content files being one of them, considered to be unique.
UniqueID() string
FileInfo() fsVO.FileMetaInfo
}
// Page is the core interface in Hugo.
type Page interface {
ContentProvider
PageWithoutContent
}
// ContentProvider provides the content related values for a Page.
type ContentProvider interface {
Content() (any, error)
}
// PageWithoutContent is the Page without any of the content methods.
type PageWithoutContent interface {
// FileProvider For pages backed by a file.
FileProvider
PageMetaProvider
}
// FileProvider provides the source file.
type FileProvider interface {
File() File
}
// PageMetaProvider provides page metadata, typically provided via front matter.
type PageMetaProvider interface {
// Kind The Page Kind. One of page, home, section, taxonomy, term.
Kind() string
// SectionsEntries Returns a slice of sections (directories if it's a file) to this
// Page.
SectionsEntries() []string
// Layout The configured layout to use to render this page. Typically set in front matter.
Layout() string
// Type is a discriminator used to select layouts etc. It is typically set
// in front matter, but will fall back to the root section.
Type() string
}
// PagePerOutputProviders will be shifted out when rendering a given output format.
type PagePerOutputProviders interface {
TargetPather
ResourceLinksProvider
}
type TargetPather interface {
TargetPaths() valueobject.TargetPaths
}
type ResourceLinksProvider interface {
// Permalink represents the absolute link to this resource.
Permalink() string
// RelPermalink represents the host relative link to this resource.
RelPermalink() string
}
// OutputFormatsProvider provides the OutputFormats of a Page.
type OutputFormatsProvider interface {
OutputFormats() valueobject.OutputFormats
}
// SitesProvider provide accessors to get sites.
type SitesProvider interface {
Site() site.Site
Sites() site.Sites
}