Compare commits

..
9 Commits
Author SHA1 Message Date
Jimmy Cai c6661196ad release: version 1.0.4 2020-09-23 23:54:50 +02:00
Jimmy Cai d55cc303d4 feat(rss): add RSS template
fix: hidden post being shown in RSS output
feat: add config to output full content in RSS
2020-09-23 22:32:20 +02:00
Jimmy Cai 5b7f96e778 chore: update compiled SCSS file 2020-09-23 13:26:29 +02:00
Jimmy Cai a2a49e7537 refactor(scss): remove alert style and script
It is not used in this theme
2020-09-23 13:22:03 +02:00
Jimmy Cai 26acceb37d feat(scss): improve 2 column style 2020-09-23 13:20:18 +02:00
Jimmy Cai b14ca5d15b feat(article): add KaTeX support 2020-09-21 16:22:44 +02:00
Jimmy CaiandGitHub 0cee4930e2 fix(disqus): fix container padding
Rename `--content-padding` to `--card-padding`
2020-09-20 23:45:44 +02:00
Jimmy Cai 02f2badffc refactor(scss): rename --content-padding to --card-padding
closes https://github.com/CaiJimmy/hugo-theme-stack/issues/16
2020-09-20 19:03:41 +02:00
Jimmy Cai 9d76ab371f feat(archive widget): improve "more" link
Link it to the next available year
2020-09-20 13:26:10 +02:00
17 changed files with 209 additions and 168 deletions
+119
View File
@@ -0,0 +1,119 @@
.container {
margin-left: auto;
margin-right: auto;
&.extended {
@media (min-width: $on-phone) {
max-width: 800px;
.left-sidebar {
width: 25%;
}
}
@media (min-width: $on-tablet) {
max-width: 972px;
.right-sidebar {
width: 25%;
}
}
@media (min-width: $on-desktop) {
max-width: 1200px;
.left-sidebar {
width: 20%;
}
.right-sidebar {
width: 25%;
}
}
@media (min-width: $on-desktop-large) {
max-width: 1536px;
.left-sidebar {
width: 15%;
}
}
}
&.compact {
@media (min-width: $on-phone) {
max-width: 800px;
.left-sidebar {
width: 25%;
}
}
@media (min-width: $on-tablet) {
max-width: 972px;
}
@media (min-width: $on-desktop) {
max-width: 1200px;
.left-sidebar {
width: 20%;
}
}
@media (min-width: $on-desktop-large) {
max-width: 1300px;
}
}
}
.flex {
display: flex;
flex-direction: row;
&.column {
flex-direction: column;
}
&.on-phone--column {
@media (max-width: $on-phone) {
flex-direction: column;
}
}
&.align-items--flex-start {
align-items: flex-start;
}
.grow {
flex-grow: 1;
}
.do-not-shrink {
flex-shrink: 0;
}
.do-not-overflow {
min-width: 0;
flex-shrink: 1;
max-width: 100%;
}
.full-width {
width: 100%;
}
}
main.main {
min-width: 0;
padding: 0 15px;
max-width: 100%;
flex-grow: 1;
padding-top: var(--main-top-padding);
}
.main-grid {
@media (max-width: $on-phone) {
flex-direction: column;
}
}
+1 -1
View File
@@ -53,7 +53,7 @@
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
padding: var(--content-padding); padding: var(--card-padding);
} }
.article-category { .article-category {
+1 -1
View File
@@ -2,5 +2,5 @@
background-color: var(--card-background); background-color: var(--card-background);
box-shadow: var(--shadow-l1); box-shadow: var(--shadow-l1);
border-radius: var(--card-border-radius); border-radius: var(--card-border-radius);
padding: var(--content-padding); padding: var(--card-padding);
} }
+11 -11
View File
@@ -64,13 +64,13 @@
} }
.article-details { .article-details {
padding: var(--content-padding); padding: var(--card-padding);
padding-bottom: 0; padding-bottom: 0;
} }
} }
.article-content { .article-content {
margin: var(--content-padding) 0; margin: var(--card-padding) 0;
color: var(--card-text-color-main); color: var(--card-text-color-main);
img { img {
@@ -80,11 +80,11 @@
} }
.article-footer { .article-footer {
padding: var(--content-padding); padding: var(--card-padding);
padding-top: 0; padding-top: 0;
section:not(:first-child) { section:not(:first-child) {
margin-top: var(--content-padding); margin-top: var(--card-padding);
} }
section { section {
@@ -192,7 +192,7 @@
& > p { & > p {
margin: 1.5em 0; margin: 1.5em 0;
padding: 0 var(--content-padding); padding: 0 var(--card-padding);
} }
h1, h1,
@@ -201,7 +201,7 @@
h4, h4,
h5, h5,
h6 { h6 {
padding: 0 calc(var(--content-padding) - var(--heading-border-size)); padding: 0 calc(var(--card-padding) - var(--heading-border-size));
border-left: var(--heading-border-size) solid var(--accent-color); border-left: var(--heading-border-size) solid var(--accent-color);
} }
@@ -219,13 +219,13 @@
position: relative; position: relative;
margin: 10px 0; margin: 10px 0;
border-left: var(--blockquote-border-size) solid var(--card-separator-color); border-left: var(--blockquote-border-size) solid var(--card-separator-color);
padding: 15px calc(var(--content-padding) - var(--blockquote-border-size)); padding: 15px calc(var(--card-padding) - var(--blockquote-border-size));
background-color: var(--blockquote-background-color); background-color: var(--blockquote-background-color);
} }
& > ul, & > ul,
& > ol { & > ol {
margin: 1em var(--content-padding); margin: 1em var(--card-padding);
} }
hr { hr {
@@ -270,7 +270,7 @@
font-family: var(--code-font-family); font-family: var(--code-font-family);
line-height: 1.428571429; line-height: 1.428571429;
word-break: break-all; word-break: break-all;
padding: var(--content-padding); padding: var(--card-padding);
code { code {
color: unset; color: unset;
@@ -281,9 +281,9 @@
} }
table { table {
margin: 0 var(--content-padding); margin: 0 var(--card-padding);
width: 100%; width: 100%;
max-width: calc(100% - var(--content-padding) * 2); max-width: calc(100% - var(--card-padding) * 2);
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0; border-spacing: 0;
margin-bottom: 1.5em; margin-bottom: 1.5em;
-14
View File
@@ -23,19 +23,10 @@
} }
@media (min-width: $on-phone + 1) { @media (min-width: $on-phone + 1) {
width: 25%;
margin-right: 1%; margin-right: 1%;
padding: var(--main-top-padding) 15px; padding: var(--main-top-padding) 15px;
max-height: 100vh; max-height: 100vh;
} }
@media (min-width: $on-desktop) {
width: 20%;
}
@media (min-width: $on-desktop-large) {
width: 15%;
}
} }
.right-sidebar { .right-sidebar {
@@ -50,14 +41,9 @@
} }
@media (min-width: $on-tablet) { @media (min-width: $on-tablet) {
width: 25%;
margin-left: 1%; margin-left: 1%;
padding-top: 50px; padding-top: 50px;
} }
@media (min-width: $on-desktop + 1) {
width: 25%;
}
} }
.site-info { .site-info {
+2 -95
View File
@@ -8,6 +8,7 @@
@import "breakpoints.scss"; @import "breakpoints.scss";
@import "variables.scss"; @import "variables.scss";
@import "grid.scss";
@import "external/normalize.scss"; @import "external/normalize.scss";
@@ -39,98 +40,4 @@ a {
box-shadow: 0px -10px 0px rgba(var(--link-background-color), var(--link-background-opacity-hover)) inset; box-shadow: 0px -10px 0px rgba(var(--link-background-color), var(--link-background-opacity-hover)) inset;
} }
} }
} }
.container {
margin-left: auto;
margin-right: auto;
&.extended {
@media (min-width: $on-phone) {
max-width: 800px;
}
@media (min-width: $on-tablet) {
max-width: 972px;
}
@media (min-width: $on-desktop) {
max-width: 1200px;
}
@media (min-width: $on-desktop-large) {
max-width: 1536px;
}
}
}
main.main {
min-width: 0;
padding: 0 15px;
max-width: 100%;
flex-grow: 1;
padding-top: var(--main-top-padding);
}
.main-grid {
@media (max-width: $on-phone) {
flex-direction: column;
}
}
.flex {
display: flex;
flex-direction: row;
&.column {
flex-direction: column;
}
&.on-phone--column {
@media (max-width: $on-phone) {
flex-direction: column;
}
}
&.align-items--flex-start {
align-items: flex-start;
}
.grow {
flex-grow: 1;
}
.do-not-shrink {
flex-shrink: 0;
}
.do-not-overflow {
min-width: 0;
flex-shrink: 1;
max-width: 100%;
}
.full-width {
width: 100%;
}
}
.alert {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 5;
background: var(--card-background);
max-width: 400px;
padding: 15px 20px;
border-radius: var(--card-border-radius);
line-height: 1.75;
color: var(--card-text-color-secondary);
box-shadow: var(--shadow-l2);
@media (max-width: $on-phone) {
max-width: 100vw;
width: calc(100% - 30px);
left: 15px;
}
}
+3 -3
View File
@@ -54,12 +54,12 @@ $defaultTagColors: #fff, #fff, #fff, #fff, #fff;
--card-border-radius: 10px; --card-border-radius: 10px;
--content-padding: 30px; --card-padding: 30px;
@media (max-width: $on-desktop-large) { @media (max-width: $on-desktop-large) {
--content-padding: 25px; --card-padding: 25px;
} }
@media (max-width: $on-tablet) { @media (max-width: $on-tablet) {
--content-padding: 20px; --card-padding: 20px;
} }
--small-card-padding: 25px; --small-card-padding: 25px;
-23
View File
@@ -65,29 +65,6 @@ let Stack = {
observer.observe(articleTile) observer.observe(articleTile)
} }
},
alert: (content, time = 5000, animationSpeed = 500) => {
const alert = document.createElement('div');
alert.innerHTML = content;
alert.className = 'alert';
alert.style.visibility = 'hidden';
document.body.appendChild(alert);
alert.style.transform = `translateY(${alert.clientHeight + 50}px)`;
alert.style.transition = `transform ${animationSpeed / 1000}s ease`;
setTimeout(() => {
alert.style.removeProperty('visibility');
alert.style.transform = `translateY(0)`;
}, animationSpeed);
setTimeout(() => {
alert.style.transform = `translateY(${alert.clientHeight + 50}px)`;
}, animationSpeed + time);
setTimeout(() => {
alert.remove();
}, 2 * animationSpeed + time);
} }
} }
+2
View File
@@ -13,6 +13,7 @@ DefaultContentLanguage = "en" # Theme i18n support
[params] [params]
mainSections = ["post"] mainSections = ["post"]
featuredImageField = "image" featuredImageField = "image"
rssFullContent = true
[params.dateFormat] [params.dateFormat]
published = "Jan 02, 2006" published = "Jan 02, 2006"
lastUpdated = "Jan 02, 2006 15:04 MST" lastUpdated = "Jan 02, 2006 15:04 MST"
@@ -21,6 +22,7 @@ DefaultContentLanguage = "en" # Theme i18n support
avatar = "img/avatar.png" avatar = "img/avatar.png"
subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." subtitle = "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
[params.article] [params.article]
math = false
[params.article.license] [params.article.license]
enabled = true enabled = true
default = "Licenced under CC BY-NC-SA 4.0" default = "Licenced under CC BY-NC-SA 4.0"
+1 -1
View File
@@ -2,7 +2,7 @@
<html lang="{{ .Site.LanguageCode }}"> <html lang="{{ .Site.LanguageCode }}">
{{- partial "head/head.html" . -}} {{- partial "head/head.html" . -}}
<body class="{{ block `body-class` . }}{{ end }}"> <body class="{{ block `body-class` . }}{{ end }}">
<div class="container extended flex on-phone--column align-items--flex-start {{ block `container-class` . }}{{end}}"> <div class="container flex on-phone--column align-items--flex-start {{ if .Site.Params.widgets.enabled }}extended{{ else }}compact{{ end }} {{ block `container-class` . }}{{end}}">
{{ partial "sidebar/left.html" . }} {{ partial "sidebar/left.html" . }}
<main class="main full-width"> <main class="main full-width">
{{- block "main" . }}{{- end }} {{- block "main" . }}{{- end }}
+4
View File
@@ -4,4 +4,8 @@
{{ partial "article/components/content" . }} {{ partial "article/components/content" . }}
{{ partial "article/components/footer" . }} {{ partial "article/components/footer" . }}
{{ if or .Params.math .Site.Params.article.math }}
{{ partialCached "article/components/math.html" . }}
{{ end }}
</article> </article>
@@ -0,0 +1,8 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css"
integrity="sha384-AfEj0r4/OFrOo5t7NnNe46zW/tFgW6x/bCJG8FqQCEo3+Aro6EYUG4+cU+KJWu/X" crossorigin="anonymous">
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js"
integrity="sha384-g7c+Jr9ZivxKLnZTDUhnkOnsh30B4H0rpLUpJ4jAIKs4fnJI+sEnkvrMWph2EDg4"
crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js"
integrity="sha384-mll67QQFJfxn0IYznZYonOWZ644AWYC+Pt2cHqMaRhXVrursRwvLnLaebdGIlYNa" crossorigin="anonymous"
onload="renderMathInElement(document.querySelector(`.article-content`));"></script>
@@ -7,6 +7,6 @@
background-color: var(--card-background); background-color: var(--card-background);
border-radius: var(--card-border-radius); border-radius: var(--card-border-radius);
box-shadow: var(--shadow-l1); box-shadow: var(--shadow-l1);
padding: var(--content-padding); padding: var(--card-padding);
} }
</style> </style>
+1 -1
View File
@@ -2,7 +2,7 @@
<section class="copyright">&copy; {{ now.Format "2006" }} {{ .Site.Title }}</section> <section class="copyright">&copy; {{ now.Format "2006" }} {{ .Site.Title }}</section>
<section class="powerby"> <section class="powerby">
Built with <a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo</a> <br /> Built with <a href="https://gohugo.io/" target="_blank" rel="noopener">Hugo</a> <br />
Theme <b><a href="https://github.com/CaiJimmy/hugo-theme-stack" target="_blank" rel="noopener">Stack</a></b> designed by Theme <b><a href="https://github.com/CaiJimmy/hugo-theme-stack" target="_blank" rel="noopener" data-version="1.0.4">Stack</a></b> designed by
<a href="https://jimmycai.com" target="_blank" rel="noopener">Jimmy</a> <a href="https://jimmycai.com" target="_blank" rel="noopener">Jimmy</a>
</section> </section>
</footer> </footer>
+8 -12
View File
@@ -9,20 +9,16 @@
{{ $filtered := ($pages | intersect $notHidden) }} {{ $filtered := ($pages | intersect $notHidden) }}
{{ $archives := $filtered.GroupByDate "2006" }} {{ $archives := $filtered.GroupByDate "2006" }}
{{ range first .Site.Params.widgets.archives.limit ($archives) }} {{ range $index, $item := first (add .Site.Params.widgets.archives.limit 1) ($archives) }}
{{ $id := lower (replace .Key " " "-") }} {{- $id := lower (replace $item.Key " " "-") -}}
<div class="archives-year"> <div class="archives-year">
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}"> <a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}#{{ $id }}">
<span class="year">{{ .Key }}</span> {{ if eq $index $.Site.Params.widgets.archives.limit }}
<span class="count">{{ len .Pages }}</span> <span class="year">{{ T "widgetArchivesMore" }}</span>
</a> {{ else }}
</div> <span class="year">{{ .Key }}</span>
{{ end }} <span class="count">{{ len $item.Pages }}</span>
{{ end }}
{{ if gt (len $archives) .Site.Params.widgets.archives.limit }}
<div class="archives-year">
<a href="{{ $.Site.Params.widgets.archives.path | relLangURL }}">
<span class="year">{{ T "widgetArchivesMore" }}</span>
</a> </a>
</div> </div>
{{ end }} {{ end }}
+42
View File
@@ -0,0 +1,42 @@
{{- $pages := where .Site.RegularPages "Type" "in" .Site.Params.mainSections -}}
{{- $notHidden := where .Site.RegularPages "Params.hidden" "!=" true -}}
{{- $filtered := ($pages | intersect $notHidden) -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $filtered = $filtered | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{.}} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo -- gohugo.io</generator>{{ with .Site.LanguageCode }}
<language>{{.}}</language>{{end}}{{ with .Site.Author.email }}
<managingEditor>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</managingEditor>{{end}}{{ with .Site.Author.email }}
<webMaster>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</webMaster>{{end}}{{ with .Site.Copyright }}
<copyright>{{.}}</copyright>{{end}}{{ if not .Date.IsZero }}
<lastBuildDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}}
{{ range $filtered }}
{{- $content := safeHTML (.Summary | html) -}}
{{- if .Site.Params.rssFullContent -}}
{{- $content = safeHTML (.Content | html) -}}
{{- end -}}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}}
<guid>{{ .Permalink }}</guid>
<description>
{{- $image := partial "helper/image" (dict "Context" . "Type" "rss") -}}
{{- if $image.exists -}}
{{ "<" | html }}img src="{{ $image.permalink | absURL }}" width="{{ $image.resource.Width }}" height="{{ $image.resource.Height }}" alt="Featured image of post {{ .Title }}" {{ "/>" | html}}
{{- end -}}{{ $content }}</description>
</item>
{{ end }}
</channel>
</rss>
File diff suppressed because one or more lines are too long