Skip to content

Commit

Permalink
使文章“过时”
Browse files Browse the repository at this point in the history
  • Loading branch information
movsb committed Mar 20, 2024
1 parent c61e560 commit 71c8e3a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
17 changes: 17 additions & 0 deletions theme/blog/styles/content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,20 @@ blockquote {
h5::before { content: "##### ";}
h6::before { content: "###### ";}
}

.content-wrap {
.disclaimer {
display: none;
}
&.outdated {
> .content {
display: none;
}
> .disclaimer {
display: block;
text-align: center;
line-height: 4em;
font-size: 1.3em;
}
}
}
14 changes: 13 additions & 1 deletion theme/blog/templates/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,22 @@ <h1 class="title clearfix"><a href="{{ .Link }}">{{ .Title }}</a></h1>
{{ end }}
<span>阅读次数:<span class="view">{{ .PageView }}</span></span>
</div>
{{ if .Outdated }}
<div class="content-wrap outdated">
{{ else }}
<div class="content-wrap">
{{ end }}
<div class="content">
{{raw `<!--article begins here-->`}}
{{ .Content }}
{{raw `<!--article ends here-->`}}
</div><!-- end entry -->
</div>
<div class="disclaimer">
<p>这篇文章的内容已被作者标记为“过时”/“需要更新”/“不具参考意义”。</p>
<button onclick="document.getElementsByClassName('content-wrap')[0].classList.remove('outdated');">仍然查看</button>
</div>
</div>
</div><!-- end entry -->
{{if .Tags}}
<div class="meta2 clearfix">
<p><b>标签:</b><span class="value">{{.TagsString}}</span></p>
Expand Down
7 changes: 7 additions & 0 deletions theme/data/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,10 @@ func (p *Post) CustomFooter() (footer string) {
}
return
}

func (p *Post) Outdated() bool {
if value, ok := p.Metas[`outdated`]; ok && (value == `true` || value == `1`) {
return true
}
return false
}

0 comments on commit 71c8e3a

Please sign in to comment.