Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
jesselau76 committed Nov 26, 2018
1 parent 3d298f9 commit 57f5b3c
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 16 deletions.
3 changes: 3 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@




# Hugo W3 SIMPLE


Expand All @@ -29,6 +30,8 @@
- 社交按钮.
- 支持多语言.
- 辉光式LOGO,可选
- Lazy Load图片 - 异步加载网站上的图像 - 也就是说先用一个极小的图像文件占住位置,只有当用户滑动屏幕到该图片出现的位置时,才调用真实的图片。 如果页面有很多图片,启用此功能可以使页面加载速度非常快。 [实例演示](https://jesselau.com/21-wordpress-plugins-activated-in-my-website/). 这个网页含有21个图片。不用lazy load前文件大小为854kb,加载时间3.5s.![Before lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/beforelazyload.png)使用lazy load后文件大小为524kb,加载时间就只有2.8s
![After lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/afterlazyload.png)

## 屏幕截图
### 网格化风格
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
- Multilingual.
- Glowing style logo
- Scroll indicator
- Lazy Load images - loading images on websites asynchronously — that is, after the above-the-fold content is fully loaded, or even conditionally, only when they appear in the browser's viewport. This means that if users don't scroll all the way down, images placed at the bottom of the page won't even be loaded. Enable this function to make the page load very fast if it has lots of images. [Live Demo Here](https://jesselau.com/21-wordpress-plugins-activated-in-my-website/). This page includes 21 images. Before lazy load the page size is 854kb and load time is 3.5s.![Before lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/beforelazyload.png)After lazy load the page size is 524kb and load time is 2.8s
![After lazy load](https://raw.githubusercontent.com/jesselau76/hugo-w3-simple/master/images/afterlazyload.png)

## Screenshot
### Grid style
Expand Down Expand Up @@ -93,3 +95,4 @@ Released under the [MIT](https://github.com/jesselau76/hugo-w3-simple/blob/maste




Binary file added images/afterlazyload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/beforelazyload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 14 additions & 14 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ <h1 class="w3-center">{{ .Title | markdownify }}</h1>
<div class="w3-card-2 w3-hover-shadow " >

{{ with .Params.thumbnail }}

<div class="w3-hover-opacity thumb">
{{ if eq ( $.Scratch.Get "novisual") 1 }}
<div class="w3-hover-opacity ">
<img src="placeholder.svg" data-src="{{ relURL . }}" alt="Thumbnail" />

<img src="{{ "/placeholder.svg" | relURL }}" data-src="{{ relURL . }}" alt="Thumbnail" />
{{ else }}
<div class="w3-hover-opacity ">

<img src="{{ relURL . }}" alt="Thumbnail" />
{{ end }}
</div>
{{ else }}
{{ if .Site.Params.firstpic}}
{{ if .Site.Params.lazyload | and (eq ( .Scratch.Get "novisual") 1) }}

{{ $img := findRE "<img .*?src=\"(.*?)\".*?>" .Content 1 }}
{{ range $img }}

<div class="w3-hover-opacity "><img src="placeholder.svg" data-src="{{ replaceRE "<img .*?src=\"(.*?)\".*?>" "$1" . }}" alt="Thumbnail"/></div>
{{ end }}
{{ else }}
{{ $img := findRE "<img .*?src=\"(.*?)\".*?>" .Content 1 }}
{{ range $img }}

<div class="w3-hover-opacity "><img src="{{ replaceRE "<img .*?src=\"(.*?)\".*?>" "$1" . }}" alt="Thumbnail" /></div>
{{ end }}
<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 }}
{{ end }}

<header class="w3-container wraptext w3-text-indigo">
<h4><a href="{{ .URL }}">{{ .Title | markdownify }}</a></h4>
Expand Down
14 changes: 13 additions & 1 deletion layouts/post/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,19 @@ <h1>{{ .Title }}</h1>

<!-- Content -->
<div class="w3-container">
{{ .Content }}
{{ if .Site.Params.lazyload }}
{{ $img := findRE "src=\"(.+?png|jpg|jpeg|gif|bmp)\"" .Content }}
{{ if gt (len $img) 1 }}

{{ (.Content | replaceRE "src=\"(.+?png|jpg|jpeg|gif|bmp)\"" "src=\"/placeholder.svg\" data-src=\"$1\"") | safeHTML }}
{{ else }}
{{ .Content }}
{{ end }}


{{ else }}
{{ .Content }}
{{ end }}
</div>


Expand Down
2 changes: 1 addition & 1 deletion static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ position: fixed;
.thumb {
position: relative;
width: 100%;
padding-top: 75%; /* 4:3 Aspect Ratio */
padding-top: 66.66%; /* 3:2 Aspect Ratio */
height: 0;
overflow: hidden;

Expand Down

0 comments on commit 57f5b3c

Please sign in to comment.