Skip to content

Commit

Permalink
add CurrentYear in templte vars
Browse files Browse the repository at this point in the history
  • Loading branch information
Streamlet committed Nov 2, 2023
1 parent fc2baa0 commit 2ff2f35
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion template/sample/category.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ <h2>Empty:)</h2>

<hr />
<div class="foot">
Powered By Streamlet Studio.
Copyright (C) {{ .CurrentYear }}. Powered By Streamlet Studio.
</div>

</body>
Expand Down
2 changes: 1 addition & 1 deletion template/sample/content.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ <h1>NoteIsSite Sample - {{ .Name }} </h1>

<hr />
<div class="foot">
Powered By Streamlet Studio.
Copyright (C) {{ .CurrentYear }}. Powered By Streamlet Studio.
</div>

</body>
Expand Down
2 changes: 1 addition & 1 deletion template/sample/index.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ <h2>Empty:)</h2>

<hr />
<div class="foot">
Powered By Streamlet Studio.
Copyright (C) {{ .CurrentYear }}. Powered By Streamlet Studio.
</div>

</body>
Expand Down
9 changes: 9 additions & 0 deletions template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ import (
"os"
"sync"
"text/template"
"time"

"github.com/Streamlet/NoteIsSite/config"
)

type Globals struct {
}

func (Globals) CurrentYear() string {
return time.Now().Format("2006")
}

type BasicItem struct {
Uri string
Name string
Expand All @@ -18,6 +26,7 @@ type BasicItem struct {
}

type PageData struct {
Globals
*BasicItem
Content string
}
Expand Down

0 comments on commit 2ff2f35

Please sign in to comment.