Skip to content

Commit e8ae475

Browse files
committed
Add post mode in home
1 parent c566025 commit e8ae475

File tree

5 files changed

+131
-1
lines changed

5 files changed

+131
-1
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
.post-warp {
2+
.intro {
3+
transform: translateY(0);
4+
margin: 2em 0 5em 0;
5+
6+
.avatar {
7+
img {
8+
width: 96px;
9+
}
10+
}
11+
}
12+
13+
.post {
14+
margin-bottom: 4em;
15+
border-bottom: 1px dashed #ddd;
16+
17+
.post-content {
18+
padding-top: .5em;
19+
}
20+
21+
.post-footer {
22+
display: flex;
23+
justify-content: space-between;
24+
align-items: center;
25+
26+
.post-meta {
27+
a {
28+
color: rgba(85, 85, 85, 0.52941) !important;
29+
.dark-theme & {
30+
color: $dark-font-secondary-color !important;
31+
}
32+
33+
&:hover {
34+
color: $light-font-secondary-color !important;
35+
.dark-theme & {
36+
color: $dark-font-secondary-color !important;
37+
}
38+
}
39+
}
40+
}
41+
.post-tags {
42+
span {
43+
a {
44+
color: rgba(85, 85, 85, 0.52941) !important;
45+
.dark-theme & {
46+
color: $dark-font-secondary-color !important;
47+
}
48+
49+
&:hover {
50+
color: $light-font-secondary-color !important;
51+
.dark-theme & {
52+
color: $dark-font-secondary-color !important;
53+
}
54+
}
55+
}
56+
}
57+
}
58+
}
59+
}
60+
}

assets/css/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
@import "_common/_page/terms.scss";
1010
@import "_common/_page/post.scss";
1111
@import "_common/_page/tags.scss";
12+
@import "_common/_page/home_post.scss";
1213

1314
@import "_common/_section/navbar.scss";
1415
@import "_common/_section/footer.scss";

layouts/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{{ define "content" }}
2-
{{ partial "home.html" . }}
2+
{{ if eq .Site.Params.home_mode "post" }}
3+
{{ partial "home_post.html" . }}
4+
{{ else }}
5+
{{ partial "home_profile.html" . }}
6+
{{ end }}
37
{{ end }}

layouts/partials/home_post.html

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
<div class="post-warp">
3+
<div class="intro">
4+
{{ $cdn_url := .Scratch.Get "cdn_url" }}
5+
{{ with .Site.Params.avatar}}
6+
{{ $avatar := .}}
7+
<div class="avatar">
8+
<a href="/posts/"> <img src="{{ (printf "%s%s" $cdn_url $avatar)}}"> </a>
9+
</div>
10+
{{ end }}
11+
{{ with .Site.Params.subtitle}}
12+
<h2 class="description">
13+
{{ . }}
14+
</h2>
15+
{{ end }}
16+
17+
</div>
18+
{{ range (.Paginate .Pages).Pages }}
19+
<article class="post" itemscope itemscope="" itemtype="http://schema.org/Article">
20+
21+
<header class="post-header">
22+
<h1 class="post-title" itemprop="name headline"><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
23+
</header>
24+
<div class="post-content">
25+
<!--featured_image-->
26+
{{ with .Params.featured_image }}
27+
{{- $img := . -}}
28+
<p><img src="{{ printf "%s%s" $cdn_url $img }}" class="featured_image"></p>
29+
{{ end }}
30+
<!-- end featured_image-->
31+
32+
{{ .Summary }}
33+
</div>
34+
<div class="post-footer">
35+
<div class="post-meta">
36+
<span class="post-time">
37+
<time datetime={{.Date.Format (.Site.Params.dateFormatToUse | default "2006-01-02") }} itemprop="datePublished">{{ .Date.Format (.Site.Params.dateFormatToUse | default "January 2, 2006") }}</time>
38+
</span>
39+
in
40+
{{ with .Params.categories -}}
41+
<i class="iconfont icon-folder"></i>
42+
<span class="post-category">
43+
{{ range . }}
44+
{{- $name := . -}}
45+
{{- with $.Site.GetPage "taxonomy" (printf "categories/%s" $name) | default ($.Site.GetPage "taxonomy" (printf "categories/%s" ($name | urlize))) -}}
46+
<a href="{{ .Permalink }}"> {{ $name }} </a>
47+
{{ end -}}
48+
{{ end }}
49+
</span>
50+
{{- end }}
51+
</div>
52+
{{ with .Params.tags }}
53+
<div class="post-tags">
54+
{{ range . }}
55+
<span class="tag"><a href="{{ "tags/" | absURL }}{{ . | urlize }}/">
56+
#{{.}}</a></span>
57+
{{ end }}
58+
</div>
59+
{{ end }}
60+
</div>
61+
</article>
62+
{{ end }}
63+
64+
{{ partial "paginator.html" . }}
65+
</div>
File renamed without changes.

0 commit comments

Comments
 (0)