Skip to content

Commit

Permalink
feat:add post type memo
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfa committed Nov 13, 2023
1 parent fb93037 commit 392f1ba
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 71 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ echo "theme = 'notability'" >> hugo.toml

## Release Note

### 0.2.0

- 增加状态文章格式

### 0.1.8

- 文章内链短代码
Expand Down
Binary file added assets/images/avatar.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions assets/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -881,3 +881,45 @@ a {
background-color: #fafafa;
}
}

.post--item {
padding: 25px 0px;
//border-bottom: 1px solid #eee;
border-radius: 5px;
&__status {
.avatar {
border-radius: 100%;
margin-right: 10px;
}
header {
display: flex;
align-items: center;
margin-bottom: 10px;
a {
color: var(--text-gray-light);
display: flex;
align-items: center;
font-size: 14px;
&:hover {
color: var(--main-hover-color);
}
}
}
//background-color: #fafafa;
border-radius: 5px;
margin-top: 10px;
margin-bottom: 10px;
.description {
margin-bottom: 0;
}
}
display: flex;
align-items: center;
.description {
font-size: 14px;
line-height: 1.6;
color: var(--text-gray-light);
word-break: break-all;
margin-bottom: 4px;
}
}
25 changes: 1 addition & 24 deletions layouts/_default/taxonomy.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,7 @@ <h1 class="post-title">{{.Title}}</h1>
</header>
<div class="layoutSingleColumn">
{{ range .Data.Pages }}
<article class="articleItem articleItem__withImage">
{{ if .Content }}
{{ $urls := findRE "<img src=\"[^\"|\\\"]*\"" .Content }} {{ if $urls }} {{ $url :=index ($urls) 0 }} {{ $url
:=(strings.TrimPrefix "<img src=\"" $url) }}
{{ $url := strings.TrimRight " \"" $url }} <img src="{{ $url }}" class="cover" /> {{ end }} {{ end }}
<div class="content">
<h2 class="title">
<a href="{{ .Permalink }}">
{{ .Title }}
</a>
</h2>
<div class="summary">{{ .Summary | truncate 60 }}</div>
<div class="time">
<time datetime='{{.Date.Format "2006-01-02 15:04:01" }}' class="humane--time">{{
.Date | time.Format ":date_long" }}</time>
{{ if .Params.categories }}
<span class="dot"></span>
{{ range (.GetTerms "categories") }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
{{ end }}
</div>
</div>
</article>
{{ partial "post.html" . }}
{{ end }}
</div>
{{ end }}
22 changes: 1 addition & 21 deletions layouts/category/term.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,7 @@ <h1 class="post-title">{{.Title}}</h1>
</header>
<div class="layoutSingleColumn">
{{ range .Data.Pages }}
<article class="articleItem articleItem__withImage">
{{ if .Content }}
{{ $urls := findRE "<img src=\"[^\"|\\\"]*\"" .Content }} {{ if $urls }} {{ $url :=index ($urls) 0 }} {{ $url
:=(strings.TrimPrefix "<img src=\"" $url) }}
{{ $url := strings.TrimRight " \"" $url }} <img src="{{ $url }}" class="cover" /> {{ end }} {{ end }}
<div class="content">
<h2 class="title">
<a href="{{ .Permalink }}">
{{ .Title }}
</a>
</h2>
<div class="summary">{{ .Summary | truncate 60 }}</div>
<div class="time">
<time datetime='{{.Date.Format "2006-01-02 15:04:01" }}' class="humane--time">
{{ .Date |
time.Format
":date_long" }}
</time>
</div>
</div>
</article>
{{ partial "post.html" . }}
{{ end }}
</div>
{{ end }}
31 changes: 5 additions & 26 deletions layouts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,11 @@
{{ $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
{{ $paginator := .Paginate ($pages) }}
{{ range $paginator.Pages }}
<article class="articleItem articleItem__withImage">
{{ if .Content }}
{{ $urls := findRE "<img src=\"[^\"|\\\"]*\"" .Content }} {{ if $urls }} {{ $url :=index ($urls) 0 }} {{
$url :=(strings.TrimPrefix "<img src=\"" $url) }}
{{ $url := strings.TrimRight " \"" $url }} <img src="{{ $url }}" class="cover" /> {{ end }} {{ end }}
<div class="content">
<h2 class="title">
<a href="{{ .Permalink }}">
{{ .Title }}
</a>
</h2>
<div class="summary">{{ .Summary | truncate 60 }}</div>
<div class="time"><time datetime='{{.Date.Format "2006-01-02 15:04:01" }}' class="humane--time">{{ .Date
| time.Format
":date_long"
}}</time>
{{ if .Params.categories }}
<span class="dot"></span>
{{ range (.GetTerms "categories") }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
{{ end }}
</div>
</div>
</article>
{{ end }}
{{ if eq .Type "memo" }}
{{ partial "memo.html" . }}
{{ else }}
{{ partial "post.html" . }}
{{ end }} {{ end }}
</div>
{{ if or ($paginator.HasPrev) ($paginator.HasNext) }}
<div class="pagination">
Expand Down
16 changes: 16 additions & 0 deletions layouts/partials/memo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<article class="post--item post--item__status" itemtype="http://schema.org/Article" itemscope="itemscope">
<div class="content">
<header>
{{ $logo := resources.Get "images/avatar.jpeg" }}
<img src="{{ $logo.RelPermalink }}" class="avatar" width="48" height="48" />
<a datetime='{{.Date.Format "2006-01-02 15:04:01" }}' class="humane--time" href="{{ .Permalink }}"
itemprop="datePublished">{{
.Date |
time.Format ":date_long"
}}</a>
</header>
<div class="description" itemprop="about">
<p>{{ .Summary | truncate 60 }}</p>
</div>
</div>
</article>
25 changes: 25 additions & 0 deletions layouts/partials/post.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<article class="articleItem articleItem__withImage">
{{ if .Content }}
{{ $urls := findRE "<img src=\"[^\"|\\\"]*\"" .Content }} {{ if $urls }} {{ $url :=index ($urls) 0 }} {{ $url
:=(strings.TrimPrefix "<img src=\"" $url) }}
{{ $url := strings.TrimRight " \"" $url }} <img src="{{ $url }}" class="cover" /> {{ end }} {{ end }}
<div class="content">
<h2 class="title">
<a href="{{ .Permalink }}">
{{ .Title }}
</a>
</h2>
<div class="summary">{{ .Summary | truncate 60 }}</div>
<div class="time"><time datetime='{{.Date.Format "2006-01-02 15:04:01" }}' class="humane--time">{{ .Date
| time.Format
":date_long"
}}</time>
{{ if .Params.categories }}
<span class="dot"></span>
{{ range (.GetTerms "categories") }}
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ end }}
{{ end }}
</div>
</div>
</article>

0 comments on commit 392f1ba

Please sign in to comment.