diff options
author | jesselau76 <jesselau76@gmail.com> | 2019-12-01 05:56:10 +0300 |
---|---|---|
committer | jesselau76 <jesselau76@gmail.com> | 2019-12-01 05:56:10 +0300 |
commit | f766ec17256d5ad439ba1fb654bfaa420b11acf9 (patch) | |
tree | 8e2698960c1a250de8cfa1bd499a6bd50aaf2c7b | |
parent | dcc5fe8cb4584cf5fe6f0ffe71545995be32776d (diff) |
fix gridlist style bug
-rw-r--r-- | exampleSite/config.toml | 3 | ||||
-rw-r--r-- | layouts/_default/index.html | 157 | ||||
-rw-r--r-- | layouts/_default/list.html | 10 |
3 files changed, 166 insertions, 4 deletions
diff --git a/exampleSite/config.toml b/exampleSite/config.toml index de056fb..f0e9d28 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -7,7 +7,8 @@ disqusShortname = "" # disqus_shortname googleAnalytics = "" # UA-XXXXXXXX-X paginate = 12 #gridstyle use 3 column. so should be 3,6,9,12,15.... hasCJKLanguage = true # has chinese/japanese/korean ? - +[markup.goldmark.renderer] +unsafe= true [languages.en] weight = 0 languageName = "English" diff --git a/layouts/_default/index.html b/layouts/_default/index.html new file mode 100644 index 0000000..795d374 --- /dev/null +++ b/layouts/_default/index.html @@ -0,0 +1,157 @@ +{{ define "main" -}} + <div class="w3-content w3-card-4" > + +{{ $paginator := .Paginate (where .Site.RegularPages "Section" "!=" "") }} + + + +{{ if .Site.Params.allliststyle }} + <script src="{{ "/js/w3.js" | relURL }}"></script> + <p> + <input oninput="w3.filterHTML('#id01', '.item', this.value)" class="w3-input" placeholder="{{ T "postssearch"}}"> + </p> + <div style="overflow-x:auto;"> + <table id="id01" class="w3-table-all w3-hoverable"> + <tr class="w3-green" style="white-space:nowrap;"> + <th onclick="w3.sortHTML('#id01', '.item', 'td:nth-child(1)')" style="cursor:pointer">{{ T "poststitle"}} <i class="fa fa-sort" style="font-size:13px;"></i></th> + <th onclick="w3.sortHTML('#id01', '.item', 'td:nth-child(2)')" style="cursor:pointer">{{ T "postsdate"}} <i class="fa fa-sort" style="font-size:13px;"></i> </th> + <th onclick="w3.sortHTMLbyNumber('#id01', '.item', 'td:nth-child(3)')" style="cursor:pointer">{{ T "postsword"}} <i class="fa fa-sort" style="font-size:13px;"></i> </th> + </tr> + {{ if .IsHome }} + {{range where .Site.RegularPages "Section" "posts"}} + <tr class="item "> + <td><a href="{{.Permalink}}">{{.Title}}</a></td> + <td>{{ .Date.Format "2006/01/02" }}</td> + <td>{{.WordCount}}</td> + </tr> + {{end}} + + {{ else }} + {{range .Pages }} + <tr class="item "> + <td><a href="{{.Permalink}}">{{.Title}}</a></td> + <td>{{ .Date.Format "2006/01/02" }}</td> + <td>{{.WordCount}}</td> + </tr> + {{end}} + {{ end }} + + </table> + </div> + +{{ else }} + + {{ if .Site.Params.gridstyle }} + <!-- grid list style --> + + + {{ range $i, $e:= $paginator.Pages }} + {{ if modBool $i 3 }} + <div class="w3-row w3-section"> + {{ end }} + {{ if .Site.Params.lazyload | and (gt $i 1) }} + {{ $.Scratch.Set "novisual" 1 }} + {{ end }} + <div class="w3-col w3-container w3-section m12 l4 "> + <div class="w3-card-2 w3-hover-shadow " > + + {{ with .Params.thumbnail }} + <div class="w3-hover-opacity thumb"> + {{ if eq ( $.Scratch.Get "novisual") 1 }} + + <img src="{{ "/placeholder.svg" | relURL }}" data-src="{{ relURL . }}" alt="Thumbnail" /> + {{ else }} + + <img src="{{ relURL . }}" alt="Thumbnail" /> + {{ end }} + </div> + {{ else }} + {{ if .Site.Params.firstpic}} + + {{ $img := findRE "(?i)<img .*?src\\s*=\\s*\"([^\"]*(png|jpg|jpeg|gif|bmp|svg))\".*?>" .Content 1 }} + {{ range $img }} + + <div class="w3-hover-opacity thumb "> + {{ if eq ( $.Scratch.Get "novisual") 1 }} + + <img src="{{ "/placeholder.svg" | relURL }}" data-src="{{ replaceRE "<img .*?src=\"(.*?)\".*?>" "$1" . }}" alt="Thumbnail"/></div> + + {{ else }} + <img src="{{ replaceRE "<img .*?src=\"(.*?)\".*?>" "$1" . }}" alt="Thumbnail" /></div> + {{ end }} + + {{ end }} + {{ end }} + {{ end }} + + <header class="w3-container wraptext w3-text-indigo"> + <h4><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h4> + + + </header> + + + <div class="w3-container wraptext w3-white"> + <code> {{ .Date.Format "2006/01/02" }} </code> + + <p> + {{ with .Description }} + {{ $.Scratch.Set "summary" (markdownify .) }} + {{ else }} + {{ $.Scratch.Set "summary" ((delimit (findRE "(<p.*?>(.|\n)*?</p>\\s*)+" .Content) "[…] ") | plainify | truncate (default 200 .Site.Params.summary_length) (default " …" .Site.Params.text.truncated ) | replaceRE "&" "&" | safeHTML) }} + {{ end }} + {{ $.Scratch.Get "summary" }} + </p> + + </div> + + + + <footer > + <a href="{{ .Permalink }}"><button class="w3-button w3-blue w3-block w3-hover-green">{{ T "readMore" }}</button></a> + </footer> + </div> + </div> + {{ if or (modBool (add $i 1) 3) (ge (add $i 1) $paginator.Pages) }} + </div> + {{ end }} + + {{ end }} + + {{ else }} + + <!-- simple list style --> + + <ul class="w3-ul w3-hoverable"> + + + + {{ range $paginator.Pages }} + <li> + <span class="date">{{ .Date.Format "2006/01/02" }}</span> + <a href="{{ .Permalink }}">{{ .Title | markdownify }}</a> + </li> + {{ end }} + {{ end }} + </ul> + + </div> + + <br> + <div class="w3-content" > + <div class="w3-bar w3-section w3-hide-large w3-hide-medium"> + + {{ with $paginator.Prev -}} + <a href="{{ .URL }}" class="w3-btn w3-text-indigo w3-hover-green">❮ Previous</a> + {{- end }} + {{ with $paginator.Next -}} + <a href="{{ .URL }}" class="w3-btn w3-right w3-text-indigo w3-hover-green">Next ❯</a> + {{- end }} + </div> + <nav class="w3-center w3-hide-small">{{ template "_internal/pagination.html" . }}</nav> + + + {{- end }} +</div> +{{ end }} + diff --git a/layouts/_default/list.html b/layouts/_default/list.html index 15d4a0b..08ab009 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,9 +1,13 @@ {{ define "main" -}} <div class="w3-content w3-card-4" > -{{if not .IsHome }} -<h1 class="w3-center">{{ .Title | markdownify }}</h1> +{{ if not .IsHome }} + <h1 class="w3-center">{{ .Title | markdownify }}</h1> + + {{ end }} -{{ $paginator := .Paginate (where .Site.RegularPages "Section" "!=" "") }} +{{ $paginator := .Paginate (where .RegularPages "Section" "!=" "") }} + + {{ if .Site.Params.allliststyle }} <script src="{{ "/js/w3.js" | relURL }}"></script> |