forked from blevesearch/hugoidx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
model.go
41 lines (37 loc) · 1.01 KB
/
model.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
package main
import (
"time"
"github.com/spf13/hugo/hugolib"
)
type Page struct {
Title string `json:"title"`
Type string `json:"type"`
Section string `json:"section"`
Content string `json:"content"`
WordCount float64 `json:"word_count"`
ReadingTime float64 `json:"reading_time"`
Keywords []string `json:"keywords"`
Date time.Time `json:"date"`
LastModified time.Time `json:"last_modified"`
Author string `json:"author"`
}
func NewPageForIndex(page *hugolib.Page) *Page {
author := ""
if paramsAuthor, ok := page.Params["author"].([]string); ok {
if len(paramsAuthor) > 0 {
author = paramsAuthor[0]
}
}
return &Page{
Title: page.Title,
Type: page.Type(),
Section: page.Section(),
Content: page.Plain(),
WordCount: float64(page.WordCount),
ReadingTime: float64(page.ReadingTime),
Keywords: page.Keywords,
Date: page.Date,
LastModified: page.Lastmod,
Author: author,
}
}