diff options
author | Covey <liuzc89@gmail.com> | 2018-09-16 05:05:47 +0300 |
---|---|---|
committer | Covey <liuzc89@gmail.com> | 2018-09-16 05:05:47 +0300 |
commit | e8ae47559195bcc5a25005be6bb03d4ebdfc9128 (patch) | |
tree | da08f9cb0d4a150430fbd33f5e3b6ba5ddd8e321 | |
parent | c566025192c65b36b00d58afa77fcd88d5efc7ac (diff) |
Add `post mode` in home
-rw-r--r-- | assets/css/_common/_page/home_post.scss | 60 | ||||
-rw-r--r-- | assets/css/main.scss | 1 | ||||
-rw-r--r-- | layouts/index.html | 6 | ||||
-rw-r--r-- | layouts/partials/home_post.html | 65 | ||||
-rw-r--r-- | layouts/partials/home_profile.html (renamed from layouts/partials/home.html) | 0 |
5 files changed, 131 insertions, 1 deletions
diff --git a/assets/css/_common/_page/home_post.scss b/assets/css/_common/_page/home_post.scss new file mode 100644 index 0000000..7808b13 --- /dev/null +++ b/assets/css/_common/_page/home_post.scss @@ -0,0 +1,60 @@ +.post-warp { + .intro { + transform: translateY(0); + margin: 2em 0 5em 0; + + .avatar { + img { + width: 96px; + } + } + } + + .post { + margin-bottom: 4em; + border-bottom: 1px dashed #ddd; + + .post-content { + padding-top: .5em; + } + + .post-footer { + display: flex; + justify-content: space-between; + align-items: center; + + .post-meta { + a { + color: rgba(85, 85, 85, 0.52941) !important; + .dark-theme & { + color: $dark-font-secondary-color !important; + } + + &:hover { + color: $light-font-secondary-color !important; + .dark-theme & { + color: $dark-font-secondary-color !important; + } + } + } + } + .post-tags { + span { + a { + color: rgba(85, 85, 85, 0.52941) !important; + .dark-theme & { + color: $dark-font-secondary-color !important; + } + + &:hover { + color: $light-font-secondary-color !important; + .dark-theme & { + color: $dark-font-secondary-color !important; + } + } + } + } + } + } + } +}
\ No newline at end of file diff --git a/assets/css/main.scss b/assets/css/main.scss index 256374e..aaf188f 100644 --- a/assets/css/main.scss +++ b/assets/css/main.scss @@ -9,6 +9,7 @@ @import "_common/_page/terms.scss"; @import "_common/_page/post.scss"; @import "_common/_page/tags.scss"; +@import "_common/_page/home_post.scss"; @import "_common/_section/navbar.scss"; @import "_common/_section/footer.scss"; diff --git a/layouts/index.html b/layouts/index.html index b829b61..b2ffa60 100644 --- a/layouts/index.html +++ b/layouts/index.html @@ -1,3 +1,7 @@ {{ define "content" }} - {{ partial "home.html" . }} + {{ if eq .Site.Params.home_mode "post" }} + {{ partial "home_post.html" . }} + {{ else }} + {{ partial "home_profile.html" . }} + {{ end }} {{ end }} diff --git a/layouts/partials/home_post.html b/layouts/partials/home_post.html new file mode 100644 index 0000000..e3e9364 --- /dev/null +++ b/layouts/partials/home_post.html @@ -0,0 +1,65 @@ + +<div class="post-warp"> + <div class="intro"> + {{ $cdn_url := .Scratch.Get "cdn_url" }} + {{ with .Site.Params.avatar}} + {{ $avatar := .}} + <div class="avatar"> + <a href="/posts/"> <img src="{{ (printf "%s%s" $cdn_url $avatar)}}"> </a> + </div> + {{ end }} + {{ with .Site.Params.subtitle}} + <h2 class="description"> + {{ . }} + </h2> + {{ end }} + +</div> + {{ range (.Paginate .Pages).Pages }} + <article class="post" itemscope itemscope="" itemtype="http://schema.org/Article"> + + <header class="post-header"> + <h1 class="post-title" itemprop="name headline"><a href="{{ .Permalink }}">{{ .Title }}</a></h1> + </header> + <div class="post-content"> + <!--featured_image--> + {{ with .Params.featured_image }} + {{- $img := . -}} + <p><img src="{{ printf "%s%s" $cdn_url $img }}" class="featured_image"></p> + {{ end }} + <!-- end featured_image--> + + {{ .Summary }} + </div> + <div class="post-footer"> + <div class="post-meta"> + <span class="post-time"> + <time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">{{ .Date.Format (.Site.Params.dateFormatToUse | default "January 2, 2006") }}</time> + </span> + in + {{ with .Params.categories -}} + <i class="iconfont icon-folder"></i> + <span class="post-category"> + {{ range . }} + {{- $name := . -}} + {{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}} + <a href="{{ .Permalink }}"> {{ $name }} </a> + {{ end -}} + {{ end }} + </span> + {{- end }} + </div> + {{ with .Params.tags }} + <div class="post-tags"> + {{ range . }} + <span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/"> + #{{.}}</a></span> + {{ end }} + </div> + {{ end }} + </div> + </article> + {{ end }} + + {{ partial "paginator.html" . }} +</div> diff --git a/layouts/partials/home.html b/layouts/partials/home_profile.html index cb81002..cb81002 100644 --- a/layouts/partials/home.html +++ b/layouts/partials/home_profile.html |