Skip to content

Commit

Permalink
feat: using officil blog theme, and enbeded extend to blog git
Browse files Browse the repository at this point in the history
  • Loading branch information
alswl committed Apr 30, 2023
1 parent 20fa23a commit a425420
Show file tree
Hide file tree
Showing 11 changed files with 322 additions and 3 deletions.
38 changes: 38 additions & 0 deletions asserts/css/extended/my.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.entry-content .thumbnail img {
margin: var(--gap) auto calc(var(--gap)) auto;
border-radius: var(--radius);
pointer-events: none;
height: auto;
}


.post-content h1 {
margin: 32px auto 24;
font-size: 32px;
}

.post-content h2 {
margin: 24px auto 16px;
font-size: 24px;
}

.post-content h3 {
font-size: 18px;
}

.post-content h4 {
font-size: 16px;
}

.post-content h5 {
font-size: 16px;
}

.post-content h6 {
font-size: 16px;
}

body {
font-size: 16px;
}

11 changes: 11 additions & 0 deletions asserts/css/extended/post-entry.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.entry-content {
margin: 8px 0;
color: var(--secondary);
font-size: 14px;
line-height: 1.6;
overflow: hidden;
/* show full summary in list */
display: inherit;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
4 changes: 4 additions & 0 deletions asserts/css/extended/post-single.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.post-content code {
padding: inherit;
font-size: inherit;
}
9 changes: 9 additions & 0 deletions asserts/css/extended/theme-vars.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* assets/css/core/theme-vars.css */

:root {
--theme: rgb(245, 245, 245);
}

.list {
background: var(--theme);
}
12 changes: 12 additions & 0 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- https://medium.com/@ardianta/writing-using-typora-on-hugo-based-blog-a1be8500774a -->
{{ if in .Destination "/static/" }}
<!-- 12 is count of ../../static carachers -->
{{ $new_file_path := substr .Destination 12 }}
<!-- render the image with new path -->
<img loading="lazy" src="{{ $new_file_path | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}" {{ end }} />
{{ else }}

<img loading="lazy" src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}" {{ end }} />

{{ end }}

121 changes: 121 additions & 0 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
{{/* vimdiff layouts/_default/list.html themes/hugo-PaperMod/layouts/_default/list.html */}}
{{/* feat: using first image as list cover */}}

{{- define "main" }}

{{- if (and site.Params.profileMode.enabled .IsHome) }}
{{- partial "index_profile.html" . }}
{{- else }} {{/* if not profileMode */}}

{{- if not .IsHome | and .Title }}
<header class="page-header">
{{- partial "breadcrumbs.html" . }}
<h1>
{{ .Title }}
{{- if and (or (eq .Kind `term`) (eq .Kind `section`)) (.Param "ShowRssButtonInSectionTermList") }}
<a href="index.xml" title="RSS" aria-label="RSS">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"
stroke-linecap="round" stroke-linejoin="round" height="23">
<path d="M4 11a9 9 0 0 1 9 9" />
<path d="M4 4a16 16 0 0 1 16 16" />
<circle cx="5" cy="19" r="1" />
</svg>
</a>
{{- end }}
</h1>
{{- if .Description }}
<div class="post-description">
{{ .Description | markdownify }}
</div>
{{- end }}
</header>
{{- end }}

{{- if .Content }}
<div class="post-content">
{{- if not (.Param "disableAnchoredHeadings") }}
{{- partial "anchored_headings.html" .Content -}}
{{- else }}{{ .Content }}{{ end }}
</div>
{{- end }}

{{- $pages := union .RegularPages .Sections }}

{{- if .IsHome }}
{{- $pages = where site.RegularPages "Type" "in" site.Params.mainSections }}
{{- $pages = where $pages "Params.hiddenInHomeList" "!=" "true" }}
{{- end }}

{{- $paginator := .Paginate $pages }}

{{- if and .IsHome site.Params.homeInfoParams (eq $paginator.PageNumber 1) }}
{{- partial "home_info.html" . }}
{{- end }}

{{- $term := .Data.Term }}
{{- range $index, $page := $paginator.Pages }}

{{- $class := "post-entry" }}

{{- $user_preferred := or site.Params.disableSpecial1stPost site.Params.homeInfoParams }}
{{- if (and $.IsHome (eq $paginator.PageNumber 1) (eq $index 0) (not $user_preferred)) }}
{{- $class = "first-entry" }}
{{- else if $term }}
{{- $class = "post-entry tag-entry" }}
{{- end }}

<article class="{{ $class }}">
{{- $isHidden := (site.Params.cover.hidden | default site.Params.cover.hiddenInList) }}
{{- partial "cover.html" (dict "cxt" . "IsHome" true "isHidden" $isHidden) }}
<header class="entry-header">
<h2>
{{- .Title }}
{{- if .Draft }}<sup><span class="entry-isdraft">&nbsp;&nbsp;[draft]</span></sup>{{- end }}
</h2>
</header>
{{- if (ne (.Param "hideSummary") true) }}
<div class="entry-content">
{{- if (.Param "ShowFirstPic") }}
{{ $img := findRE "(?i)<img .*?src\\s*=\\s*\"([^\"]*(png|jpg|jpeg|gif|bmp|svg))\".*?>" .Content 1 }}
{{ range $img }}
<div class="thumbnail"><img src="{{ replaceRE "<img .*?src=\"(.*?)\".*?>" "$1" . }}" alt="Thumbnail" /></div>
{{ end }}
{{ end }}
<p>{{ .Summary | plainify | htmlUnescape }}{{ if .Truncated }}...{{ end }}</p>
</div>
{{- end }}
{{- if not (.Param "hideMeta") }}
<footer class="entry-footer">
{{- partial "post_meta.html" . -}}
</footer>
{{- end }}
<a class="entry-link" aria-label="post link to {{ .Title | plainify }}" href="{{ .Permalink }}"></a>
</article>
{{- end }}

{{- if gt $paginator.TotalPages 1 }}
<footer class="page-footer">
<nav class="pagination">
{{- if $paginator.HasPrev }}
<a class="prev" href="{{ $paginator.Prev.URL | absURL }}">
«&nbsp;{{ i18n "prev_page" }}&nbsp;
{{- if (.Param "ShowPageNums") }}
{{- sub $paginator.PageNumber 1 }}/{{ $paginator.TotalPages }}
{{- end }}
</a>
{{- end }}
{{- if $paginator.HasNext }}
<a class="next" href="{{ $paginator.Next.URL | absURL }}">
{{- i18n "next_page" }}&nbsp;
{{- if (.Param "ShowPageNums") }}
{{- add 1 $paginator.PageNumber }}/{{ $paginator.TotalPages }}
{{- end }}&nbsp;»
</a>
{{- end }}
</nav>
</footer>
{{- end }}

{{- end }}{{/* end profileMode */}}

{{- end }}{{- /* end main */ -}}
65 changes: 65 additions & 0 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{/* vimdiff layouts/_default/single.html themes/hugo-PaperMod/layouts/_default/single.html */}}
{{/* feat: enable post_footer */}}

{{- define "main" }}

<article class="post-single">
<header class="post-header">
{{ partial "breadcrumbs.html" . }}
<h1 class="post-title">
{{ .Title }}
{{- if .Draft }}<sup><span class="entry-isdraft">&nbsp;&nbsp;[draft]</span></sup>{{- end }}
</h1>
{{- if .Description }}
<div class="post-description">
{{ .Description }}
</div>
{{- end }}
{{- if not (.Param "hideMeta") }}
<div class="post-meta">
{{- partial "post_meta.html" . -}}
{{- partial "translation_list.html" . -}}
{{- partial "edit_post.html" . -}}
{{- partial "post_canonical.html" . -}}
</div>
{{- end }}
</header>
{{- $isHidden := .Params.cover.hidden | default site.Params.cover.hiddenInSingle | default site.Params.cover.hidden }}
{{- partial "cover.html" (dict "cxt" . "IsHome" false "isHidden" $isHidden) }}
{{- if (.Param "ShowToc") }}
{{- partial "toc.html" . }}
{{- end }}

{{- if .Content }}
<div class="post-content">
{{- if not (.Param "disableAnchoredHeadings") }}
{{- partial "anchored_headings.html" .Content -}}
{{- else }}{{ .Content }}{{ end }}

{{- if eq .Section "posts" }}
{{- partial "post_footer.html" . }}
{{ end }}
</div>
{{- end }}

<footer class="post-footer">
{{- $tags := .Language.Params.Taxonomies.tag | default "tags" }}
<ul class="post-tags">
{{- range ($.GetTerms $tags) }}
<li><a href="{{ .Permalink }}">{{ .LinkTitle }}</a></li>
{{- end }}
</ul>
{{- if (.Param "ShowPostNavLinks") }}
{{- partial "post_nav_links.html" . }}
{{- end }}
{{- if (and site.Params.ShowShareButtons (ne .Params.disableShare true)) }}
{{- partial "share_icons.html" . -}}
{{- end }}
</footer>

{{- if (.Param "comments") }}
{{- partial "comments.html" . }}
{{- end }}
</article>

{{- end }}{{/* end main */}}
40 changes: 40 additions & 0 deletions layouts/index.atom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{/* modified from https://gist.github.com/lpar/7ded35d8f52fef7490a5be92e6cd6937 */}}

{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link href="{{ .Permalink }}index.xml" rel="self"/>
<link href="{{ .Permalink }}"/>{{ if not .Date.IsZero }}
<updated>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>{{ end }}
<id>{{ .Permalink }}</id>{{ with .Site.Author.name }}
<author>
<name>{{.}}</name>{{ with $.Site.Author.email }}
<email>{{.}}</email>{{end}}
</author>{{end}}
<generator>Hugo -- gohugo.io</generator>{{ range $pages }}
<entry>
{{ `<title type="html"><![CDATA[` | safeHTML }}{{ .Title }}]]></title>
<link href="{{ .Permalink }}"/>
<id>{{ .Permalink }}</id>{{ with $.Site.Author.name }}
<author>
<name>{{.}}</name>
</author>{{end}}
<published>{{ .Date.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</published>
<updated>{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" | safeHTML }}</updated>
{{ if .Content }}
{{ `<content type="html"><![CDATA[` | safeHTML }}{{ .Content }}]]></content>
{{ end }}
</entry>{{ end }}
</feed>

19 changes: 19 additions & 0 deletions layouts/partials/home_info.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{/* vimdiff layouts/partials/home_info.html themes/hugo-PaperMod/layouts/partials/home_info.html */}}

{{- with site.Params.homeInfoParams }}
<article class="home-info">
{{ if (gt (len .Title) 0) }}
<header class="entry-header">
<h1>{{ .Title | markdownify }}</h1>
</header>
{{ end }}
{{ if (gt (len .Content) 0) }}
<div class="entry-content">
{{ .Content | markdownify }}
</div>
{{ end }}
<footer class="entry-footer">
{{ partial "social_icons.html" site.Params.socialIcons }}
</footer>
</article>
{{- end -}}
4 changes: 2 additions & 2 deletions layouts/partials/post_footer.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<hr />
<p>origin: <a href="{{ .Permalink }}">{{ .LinkTitle }} | {{ site.Title }}</a></p>
<p>原文链接: <a href="{{ .Permalink }}">{{ .LinkTitle }} | {{ site.Title }}</a></p>
<p>3a1ff193cee606bd1e2ea554a16353ee</p>
<p>My wechat subscription<a
<p>欢迎关注我的微信公众号<a
href="http://mp.weixin.qq.com/mp/getmasssendmsg?__biz=MzIyNTIwMTU3MQ==#wechat_webview_type=1&amp;wechat_redirect">窥豹</a></p>
<figure>
<img
Expand Down
2 changes: 1 addition & 1 deletion themes/hugo-PaperMod

0 comments on commit a425420

Please sign in to comment.