1

fixing bootstrap sample

This commit is contained in:
Alex Yatskov 2019-02-01 18:46:23 -08:00
parent 32d3e56338
commit c004f4f6fc
70 changed files with 30 additions and 91 deletions

View File

@ -15,6 +15,7 @@ type builder struct{}
func (b *builder) Build(contentDir, buildDir, cacheDir string) { func (b *builder) Build(contentDir, buildDir, cacheDir string) {
errs := goldsmith.Begin(contentDir). errs := goldsmith.Begin(contentDir).
Cache(cacheDir).
Chain(frontmatter.New()). Chain(frontmatter.New()).
Chain(markdown.New()). Chain(markdown.New()).
Chain(layout.New()). Chain(layout.New()).

View File

@ -3,6 +3,5 @@ Area = "blog"
CrumbName = "blog" CrumbName = "blog"
Layout = "collection" Layout = "collection"
Title = "Blog" Title = "Blog"
Paginate = true
+++ +++

View File

@ -0,0 +1,16 @@
{{define "collection"}}
{{template "header" .}}
{{template "navbar" .}}
<div class="container">
{{range .Meta.Groups.Blog}}
<div>
<h2><a href="{{.Path}}">{{.Meta.Title}}</a></h2>
<p>
{{.Meta.Summary}}
<a href="{{.Path}}">&hellip;</a>
</p>
</div>
{{end}}
</div>
{{template "footer" .}}
{{end}}

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@ -1,52 +0,0 @@
{{define "collection"}}
{{template "header" .}}
{{template "navbar" .}}
<div class="container">
{{range .Meta.Pager.PageCurr.Items}}
<div>
<h2><a href="{{.Path}}">{{.Meta.Title}}</a></h2>
<p>
{{.Meta.Summary.Summary}}
<a href="{{.Path}}">[&hellip;more]</a>
</p>
</div>
{{end}}
{{if .Meta.Pager.Paged}}
<ul class="pagination justify-content-center">
{{if .Meta.Pager.PageCurr.Prev}}
<li class="page-item">
<a class="page-link" href="{{.Meta.Pager.PageCurr.Prev.File.Path}}" tabindex="-1">Previous</a>
</li>
{{else}}
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">Previous</a>
</li>
{{end}}
{{range .Meta.Pager.PagesAll}}
{{if eq $.Meta.Pager.PageCurr.Index .Index}}
<li class="page-item disabled">
<a class="page-link" href="#">{{.Index}}</a>
</li>
{{else}}
<li class="page-item">
<a class="page-link" href="{{.File.Path}}">{{.Index}}</a>
</li>
{{end}}
{{end}}
{{if .Meta.Pager.PageCurr.Next}}
<li class="page-item">
<a class="page-link" href="{{.Meta.Pager.PageCurr.Next.File.Path}}" tabindex="-1">Next</a>
</li>
{{else}}
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">Next</a>
</li>
{{end}}
</ul>
{{end}}
</div>
{{template "footer" .}}
{{end}}

View File

@ -1,25 +1,3 @@
/*
* Copyright (c) 2015 Alex Yatskov <alex@foosoft.net>
* Author: Alex Yatskov <alex@foosoft.net>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package main package main
import ( import (
@ -29,15 +7,14 @@ import (
"github.com/FooSoft/goldsmith" "github.com/FooSoft/goldsmith"
"github.com/FooSoft/goldsmith-components/devserver" "github.com/FooSoft/goldsmith-components/devserver"
"github.com/FooSoft/goldsmith-components/filters/condition" "github.com/FooSoft/goldsmith-components/filters/condition"
"github.com/FooSoft/goldsmith-components/plugins/abs" "github.com/FooSoft/goldsmith-components/plugins/absolute"
"github.com/FooSoft/goldsmith-components/plugins/breadcrumbs" "github.com/FooSoft/goldsmith-components/plugins/breadcrumbs"
"github.com/FooSoft/goldsmith-components/plugins/collection" "github.com/FooSoft/goldsmith-components/plugins/collection"
"github.com/FooSoft/goldsmith-components/plugins/dom" "github.com/FooSoft/goldsmith-components/plugins/document"
"github.com/FooSoft/goldsmith-components/plugins/frontmatter" "github.com/FooSoft/goldsmith-components/plugins/frontmatter"
"github.com/FooSoft/goldsmith-components/plugins/index" "github.com/FooSoft/goldsmith-components/plugins/index"
"github.com/FooSoft/goldsmith-components/plugins/layout" "github.com/FooSoft/goldsmith-components/plugins/layout"
"github.com/FooSoft/goldsmith-components/plugins/markdown" "github.com/FooSoft/goldsmith-components/plugins/markdown"
"github.com/FooSoft/goldsmith-components/plugins/paginate"
"github.com/FooSoft/goldsmith-components/plugins/summary" "github.com/FooSoft/goldsmith-components/plugins/summary"
"github.com/FooSoft/goldsmith-components/plugins/syntax" "github.com/FooSoft/goldsmith-components/plugins/syntax"
"github.com/FooSoft/goldsmith-components/plugins/tags" "github.com/FooSoft/goldsmith-components/plugins/tags"
@ -63,7 +40,7 @@ type builder struct {
root string root string
} }
func (b *builder) Build(srcDir, dstDir string) { func (b *builder) Build(contentDir, buildDir, cacheDir string) {
tagMeta := map[string]interface{}{ tagMeta := map[string]interface{}{
"Area": "tags", "Area": "tags",
"CrumbParent": "tags", "CrumbParent": "tags",
@ -74,23 +51,23 @@ func (b *builder) Build(srcDir, dstDir string) {
"Layout": "index", "Layout": "index",
} }
errs := goldsmith.Begin(srcDir). errs := goldsmith.Begin(contentDir).
Cache(cacheDir).
Chain(frontmatter.New()). Chain(frontmatter.New()).
Chain(markdown.New()). Chain(markdown.New()).
Chain(summary.New()). Chain(summary.New()).
Chain(collection.New()). Chain(collection.New()).
Chain(paginate.New("Groups.Blog").InheritKeys("Layout").ItemsPerPage(4)).
Chain(index.New(indexMeta)). Chain(index.New(indexMeta)).
Chain(tags.New().IndexMeta(tagMeta)). Chain(tags.New().IndexMeta(tagMeta)).
Chain(breadcrumbs.New()). Chain(breadcrumbs.New()).
Chain(layout.New("layouts/*.html")). Chain(layout.New()).
Chain(syntax.New().Placement(syntax.PlaceInline)). Chain(syntax.New().Placement(syntax.PlaceInline)).
Chain(dom.New(fixup)). Chain(document.New(fixup)).
Chain(thumbnail.New()). Chain(thumbnail.New()).
FilterPush(condition.New(len(b.root) > 0)). FilterPush(condition.New(len(b.root) > 0)).
Chain(abs.New().BaseURL(b.root)). Chain(absolute.New().BaseUrl(b.root)).
FilterPop(). FilterPop().
End(dstDir) End(buildDir)
for _, err := range errs { for _, err := range errs {
log.Print(err) log.Print(err)
@ -98,11 +75,9 @@ func (b *builder) Build(srcDir, dstDir string) {
} }
func main() { func main() {
var ( root := flag.String("root", "", "server root")
dst = flag.String("dst", "dst", "destination directory") port := flag.Int("port", 8080, "server port")
root = flag.String("root", "", "root directory")
port = flag.Int("port", 8080, "server port")
)
flag.Parse() flag.Parse()
devserver.DevServe(&builder{*root}, *port, "src", *dst, "layouts")
devserver.DevServe(&builder{*root}, *port, "content", "build", "cache")
} }