Skip to content

Commit

Permalink
refactor: restructure partials folder
Browse files Browse the repository at this point in the history
closes #68

BREAKING CHANGE: partials folder structure is changed
  • Loading branch information
reuixiy committed Feb 20, 2020
1 parent abba97f commit 299c218
Show file tree
Hide file tree
Showing 54 changed files with 75 additions and 75 deletions.
6 changes: 3 additions & 3 deletions layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<div class="container">
{{ partial "header.html" . }}
{{ partial "menu.html" . }}
{{ partial "multilingual.html" . }}
{{ partial "dark-mode.html" . }}
{{ partial "components/multilingual.html" . }}
{{ partial "components/dark-mode.html" . }}
{{ block "main" . }}{{ end }}
{{ partial "back-to-top.html" . }}
{{ partial "components/back-to-top.html" . }}
{{ partial "footer.html" . }}
</div>
{{ partial "script.html" . }}
Expand Down
6 changes: 3 additions & 3 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{ define "main" }}
{{ if and (eq .Kind "section") .Content }}
{{ partial "post.html" . }}
{{ partial "pages/post.html" . }}
{{ else }}
<main class="main list" id="main">
<div class="main-inner">
Expand Down Expand Up @@ -83,10 +83,10 @@ <h2 class="list-year">{{ $year }}{{ if $.Site.Params.chineseZodiac }}{{ replace
{{ end }}
{{ $month := $.Scratch.Get "month" }}
<h3 class="list-month">{{ $month }}</h3>
{{ partial "components/list-item.html" . }}
{{ partial "utils/list-item.html" . }}
{{ end }}
{{ else }}
{{ partial "components/list-item.html" . }}
{{ partial "utils/list-item.html" . }}
{{ end }}
</ul>
{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{{ define "main" }}
{{ partial "post.html" . }}
{{ partial "pages/post.html" . }}
{{ end }}
8 changes: 4 additions & 4 deletions layouts/index.html
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{{ define "main" }}
<!-- Layout Poetry -->
{{ if eq .Site.Params.homeLayout "poetry" }}
{{ partial "page/home-poetry.html" . }}
{{ partial "pages/home-poetry.html" . }}
{{ end }}
<!-- Layout Footage -->
{{ if eq .Site.Params.homeLayout "footage" }}
{{ partial "page/home-footage.html" . }}
{{ partial "pages/home-footage.html" . }}
{{ end }}
<!-- Layout Posts -->
{{ if eq .Site.Params.homeLayout "posts" }}
{{ partial "page/home-posts.html" . }}
{{ partial "pages/home-posts.html" . }}
{{ end }}
<!-- Layout Page -->
{{ if eq .Site.Params.homeLayout "page" }}
{{ partial "post.html" . }}
{{ partial "pages/post.html" . }}
{{ end }}
{{ end }}
6 changes: 3 additions & 3 deletions layouts/index.sectionsatom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<generator uri="https://gohugo.io/" version="{{ printf "%s" hugo.Version | safeHTML }}">Hugo</generator>
{{- range (where $pages "Section" "in" .Site.Params.mainSections) }}
{{ $page := . }}
{{- partial "components/author.html" $page -}}
{{- partial "utils/author.html" $page -}}
{{- $author := ($page.Scratch.Get "author") -}}
<entry>
<title type="text">{{ .Title | safeHTML }}</title>
Expand All @@ -55,10 +55,10 @@
{{ with $author.copyright -}}
<rights>{{ . | plainify }}</rights>
{{- end }}
{{- partial "components/summary.html" $page -}}
{{- partial "utils/summary.html" $page -}}
{{- $summary := .Description | default ($page.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) -}}
{{- $raw := $summary -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $page "raw" $raw "isContent" false) -}}
{{- $summary := $page.Scratch.Get "Content" -}}
{{ printf `<summary type="html"><![CDATA[%s]]></summary>` ($summary | htmlUnescape) | safeHTML }}
{{ if $.Site.Params.includeContent }}
Expand Down
6 changes: 3 additions & 3 deletions layouts/index.sectionsrss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
{{ end }}
{{ range (where $pages "Section" "in" .Site.Params.mainSections) }}
{{ $page := . }}
{{- partial "components/author.html" $page -}}
{{- partial "utils/author.html" $page -}}
{{- $author := ($page.Scratch.Get "author") -}}
<item>
<title>{{ .Title | safeHTML }}</title>
Expand All @@ -50,10 +50,10 @@
{{ if $.Site.Params.includeContent }}
{{ printf `<description><![CDATA[%s]]></description>` .Content | safeHTML }}
{{ else }}
{{- partial "components/summary.html" $page -}}
{{- partial "utils/summary.html" $page -}}
{{- $summary := .Description | default ($page.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) -}}
{{- $raw := $summary -}}
{{- partial "components/markdownify.html" (dict "Deliver" $page "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $page "raw" $raw "isContent" false) -}}
{{- $summary := $page.Scratch.Get "Content" -}}
{{ printf `<description><![CDATA[%s]]></description>` ($summary | htmlUnescape) | safeHTML }}
{{ end }}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $Deliver := . -}}
{{ if and .Site.Params.enablePostCopyright (.Params.displayCopyright | default .Site.Params.displayPostCopyright) }}
{{ partial "components/author.html" . }}
{{ partial "utils/author.html" . }}
{{ $author := .Scratch.Get "author" }}
{{ with $author.name }}
<ul class="post-copyright">
Expand All @@ -18,7 +18,7 @@
{{ end }}
{{ with $author.copyright }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<li class="copyright-item license">{{ printf `%s%s` (i18n "copyrightLicense") $Content | safeHTML }}</li>
{{ end }}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{ if and .Site.Params.enablePostShare (.Params.share | default .Site.Params.displayPostShare) }}

{{- partial "components/summary.html" . -}}
{{- partial "utils/summary.html" . -}}
{{- $description := .Description | default (.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) | default .Site.Params.siteDescription | plainify -}}

{{- partial "components/images.html" . -}}
{{- partial "utils/images.html" . -}}
{{- $images := .Scratch.Get "images" -}}
{{- $images := .Scratch.Add "images" (slice (.Site.Params.siteLogo | absURL)) -}}
{{- $images := (index (.Scratch.Get "images") 0) -}}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{{- $title := .Scratch.Get "title" | safeHTML -}}
{{- $date := .Lastmod.Format "2006-01-02" -}}
{{- with $title -}}{{- printf `<div%s style="cursor:help;display:inline-block">` $title | safeHTML -}}{{- end -}}
{{- partial "components/updated-badge.html" (dict "date" $date) -}}
{{- partial "utils/updated-badge.html" (dict "date" $date) -}}
{{- with $title -}}</div>{{- end -}}
</div>
{{ end }}
File renamed without changes.
6 changes: 3 additions & 3 deletions layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@

{{- if .Site.Params.displayPoweredBy }}
{{- $raw := `Powered by [Hugo](https://github.com/gohugoio/hugo) | Theme is [MemE](https://github.com/reuixiy/hugo-theme-meme)` -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := .Scratch.Get "Content" -}}
<div class="powered-by">{{ $Content | safeHTML }}</div>
{{- end }}

{{- if .Site.Params.displaySiteCopyright }}
{{- $raw := .Site.Copyright -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := .Scratch.Get "Content" -}}
<div class="site-copyright">{{ $Content | safeHTML }}</div>
{{- end }}

{{- with .Site.Params.customFooter }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<div class="custom-footer">{{ $Content | safeHTML }}</div>
{{- end }}
Expand Down
16 changes: 8 additions & 8 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
<!-- Avoid Baidu Mobile Search Transcoding -->
<meta http-equiv="Cache-Control" content="no-siteapp" />

{{ partial "components/title.html" . }}
{{ partial "utils/title.html" . }}
{{- $title := .Scratch.Get "title" -}}
<title>{{ $title }}</title>

Expand All @@ -73,10 +73,10 @@
{{- end }}

<meta name="author" content="{{ .Params.author | default .Site.Author.name }}" />
{{ partial "components/summary.html" . }}
{{ partial "utils/summary.html" . }}
{{- $description := .Description | default (.Scratch.Get "summary" | plainify | replaceRE `\n……` ``) | default .Site.Params.siteDescription | plainify -}}
<meta name="description" content="{{ $description }}" />
{{ partial "components/keywords.html" . }}
{{ partial "utils/keywords.html" . }}
{{- $keywordsDefault := (strings.TrimSuffix ", " ($.Scratch.Get "keywordsDefault")) -}}
{{- $keywordsSite := (strings.TrimSuffix ", " ($.Scratch.Get "keywordsSite")) -}}
{{- $keywordsPost := (strings.TrimSuffix ", " ($.Scratch.Get "keywordsPost")) -}}
Expand All @@ -89,11 +89,11 @@
{{- $safariMaskIcon := "icons/safari-pinned-tab.svg" -}}
{{- $safariMaskColor := .Site.Params.safariMaskColor -}}
{{- $appleTouchIcon := "icons/apple-touch-icon.png" -}}
{{- partial "components/relative-url.html" (dict "Deliver" . "filename" "") -}}
{{- partial "utils/relative-url.html" (dict "Deliver" . "filename" "") -}}
{{- $url := .Scratch.Get "url" -}}
{{- $msApplicationStartURL := $url -}}
{{- $msApplicationTileColor := .Site.Params.msApplicationTileColor -}}
{{- partial "components/relative-url.html" (dict "Deliver" . "filename" "icons/mstile-150x150.png") -}}
{{- partial "utils/relative-url.html" (dict "Deliver" . "filename" "icons/mstile-150x150.png") -}}
{{- $url := .Scratch.Get "url" -}}
{{- $msApplicationTileImage := $url -}}
{{- $manifest := "manifest.json" -}}
Expand Down Expand Up @@ -123,16 +123,16 @@
{{- $Deliver := . -}}
<!-- JSON-LD -->
{{- with .Site.Params.jsonLD -}}
{{ partial "components/json-ld.html" (dict "Deliver" $Deliver "description" $description "keywords" $keywords) }}
{{ partial "utils/json-ld.html" (dict "Deliver" $Deliver "description" $description "keywords" $keywords) }}
{{- end }}

<!-- Twitter Cards -->
{{- with .Site.Params.twitterCards -}}
{{ partial "components/twitter-cards.html" (dict "Deliver" $Deliver) }}
{{ partial "utils/twitter-cards.html" (dict "Deliver" $Deliver) }}
{{- end }}
<!-- Open Graph -->
{{- with .Site.Params.openGraph -}}
{{ partial "components/open-graph.html" (dict "Deliver" $Deliver "description" $description "keywords" $keywords) }}
{{ partial "utils/open-graph.html" (dict "Deliver" $Deliver "description" $description "keywords" $keywords) }}
{{- end }}

{{- with .Site.Params.googleSiteVerification }}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="poetry">
{{ range .Site.Params.homePoetry }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<p>{{ $Content | safeHTML }}</p>
{{ end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ <h2 class="post-title">
<a href="{{ .RelPermalink }}" class="summary-title-link">{{ .LinkTitle }}</a>
</h2>
{{ if $.Site.Params.enablePostMetaInHome }}
{{ partial "post-meta.html" (dict "Deliver" . "isHome" true) }}
{{ partial "components/post-meta.html" (dict "Deliver" . "isHome" true) }}
{{ end }}
<summary class="summary">
{{ partial "components/summary.html" . }}
{{ partial "utils/summary.html" . }}
{{ $summary := (.Scratch.Get "summary") | replaceRE `(</p>)……` `$1` }}
{{ $summary | safeHTML }}
</summary>
Expand Down
32 changes: 16 additions & 16 deletions layouts/partials/post.html → layouts/partials/pages/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<main class="main single" id="main">
<div class="main-inner">

{{ partial "components/data-attributes.html" . }}
{{ partial "utils/data-attributes.html" . }}
{{- $smallCaps := .Scratch.Get "smallCaps" -}}
{{- $align := .Scratch.Get "align" -}}
{{- $type := .Scratch.Get "type" -}}
Expand All @@ -15,32 +15,32 @@ <h1 class="post-title">{{ .Title }}</h1>

{{ with .Params.subtitle }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<div class="post-subtitle">{{ $Content | safeHTML }}</div>
{{ end }}

{{ if .Site.Params.displayPostDescription }}
{{ with .Params.description }}
{{- $raw := . -}}
{{- partial "components/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" $Deliver "raw" $raw "isContent" false) -}}
{{- $Content := $Deliver.Scratch.Get "Content" -}}
<div class="post-description">{{ $Content | safeHTML }}</div>
{{ end }}
{{ end }}

{{ if .Params.meta | default .Site.Params.enablePostMeta }}
{{ partial "post-meta.html" (dict "Deliver" . "isHome" false) }}
{{ partial "components/post-meta.html" (dict "Deliver" . "isHome" false) }}
{{ end }}

{{ $enableTOC := .Params.toc | default .Site.Params.enableTOC -}}
{{- if $enableTOC -}}
{{- partial "components/toc.html" . -}}
{{- partial "utils/toc.html" . -}}
{{- $toc := .Scratch.Get "toc" }}
{{ $toc -}}
{{- end -}}

{{- partial "components/content.html" . -}}
{{- partial "utils/content.html" . -}}
{{- $Content := .Scratch.Get "Content" -}}
<div class="post-body">
{{- $Content -}}
Expand All @@ -52,25 +52,25 @@ <h1 class="post-title">{{ .Title }}</h1>
{{ partial "third-party/google-adsense-unit.html" . }}
{{- end }}

{{ partial "post-copyright.html" . }}
{{ partial "components/post-copyright.html" . }}

{{ partial "post-updated-badge.html" . }}
{{ partial "components/post-updated-badge.html" . }}

{{ partial "post-gitinfo.html" . }}
{{ partial "components/post-gitinfo.html" . }}

{{ partial "post-share.html" . }}
{{ partial "components/post-share.html" . }}

{{ partial "related-posts.html" . }}
{{ partial "components/related-posts.html" . }}

{{ partial "post-tags.html" . }}
{{ partial "components/post-tags.html" . }}

{{ partial "minimal-footer.html" . }}
{{ partial "components/minimal-footer.html" . }}

{{ partial "minimal-footer-about.html" . }}
{{ partial "components/minimal-footer-about.html" . }}

{{ partial "post-nav.html" . }}
{{ partial "components/post-nav.html" . }}

{{ partial "comments.html" . }}
{{ partial "components/comments.html" . }}

</div>
</main>
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h2 class="term-title">
<span class="term-count">{{ printf "(%d)" .Count }}</span>
{{ end }}
</h2>
{{ partial "components/list-item.html" . }}
{{ partial "utils/list-item.html" . }}
</ul>
{{ end }}
</div>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<h1 class="list-title">{{ .Title | default (.Type | title) }}</h1>
{{ end }}
<div class="tree">
{{ partial "components/tree-sections.html" . }}
{{ partial "utils/tree-sections.html" . }}
{{ $pages := (.Scratch.Get "pages") }}
{{ range $page, $name := $pages }}
{{ $depth := (len (split (strings.TrimPrefix "/" $page) "/")) }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/third-party/disqus.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- partial "components/title.html" . -}}
{{- partial "utils/title.html" . -}}
{{- $rawTitle := .Scratch.Get "rawTitle" -}}
<script>
function loadComments() {
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/third-party/service-worker.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{ if and .Site.Params.enableServiceWorker (eq hugo.Environment "production") }}
{{- partial "components/relative-url.html" (dict "Deliver" . "filename" "sw.js") -}}
{{- partial "utils/relative-url.html" (dict "Deliver" . "filename" "sw.js") -}}
{{- $url := .Scratch.Get "url" }}

<div class="app-refresh" id="app-refresh">
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $Deliver := . -}}
{{- $raw := .RawContent -}}
{{- partial "components/markdownify.html" (dict "Deliver" . "raw" $raw "isContent" true) -}}
{{- partial "utils/markdownify.html" (dict "Deliver" . "raw" $raw "isContent" true) -}}

<!-- Link Headings to TOC -->
{{- $Content := .Scratch.Get "Content" -}}
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!-- Auto Detect Images -->
{{- if .Site.Params.autoDetectImages -}}
{{- partial "components/auto-detect-images.html" . -}}
{{- partial "utils/auto-detect-images.html" . -}}
{{- end -}}
{{- $imgsURL := .Scratch.Get "imgsURL" -}}

Expand Down

0 comments on commit 299c218

Please sign in to comment.