Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds basic sidebar #190

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/scss/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
@import "partials/typography";
@import "partials/nav";
@import "partials/social-icons";
@import "partials/sidebar";

body.nav--active {
overflow: hidden;
Expand All @@ -19,4 +20,4 @@ main {
@media screen and (max-width: $medium - 1) {
padding-top: calc(3rem + #{$burgerContainerHeight});
}
}
}
9 changes: 8 additions & 1 deletion assets/scss/pages/posts.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
@import "../main";
@import "../partials/post-list";

/* Aligns Sidebar content */
.flex-wrapper {
display: flex;
}

.tags__list {
list-style: none;
margin: 0;
Expand Down Expand Up @@ -52,6 +57,8 @@

/* page overrides */
.post-list__container {
flex-grow: 1;
max-width: 34rem;
display: flex;
justify-content: space-between;
}
}
22 changes: 22 additions & 0 deletions assets/scss/partials/_sidebar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
$sidebarBreakpoint: 1024px;

.sidebar-container {
position: sticky;
align-self: start;
top: 3rem;
max-width: 300px;
text-align: center;

@media screen and (max-width: $sidebarBreakpoint) {
display: none;
}
}

.sidebar-title {
font-size: 0.9rem;
}

.sidebar-text {
font-size: 0.8rem;
margin-bottom: 1rem;
}
44 changes: 24 additions & 20 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
{{ define "styles" }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/posts.scss" "dest" "css/posts.css") }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/posts.scss" "dest" "css/posts.css") }}
{{ end }}

{{ define "main" }}

{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="post-list__container">
<ul class="post-list">
{{ range .Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}"
>{{ .Date.Format $dateFormat }}</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
{{ partial "tags.html" .}}
</div>
</li>
{{ end }}
</ul>
{{ partial "browse-by-tag.html" .}}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="flex-wrapper">
<div class="post-list__container">
<ul class="post-list">
{{ range .Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}">{{ .Date.Format $dateFormat }}</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
{{ partial "tags.html" .}}
</div>
</li>
{{ end }}
</ul>
</div>
<div>
{{ partial "sidebar.html" .}}
{{ partial "browse-by-tag.html" .}}
</div>
</div>

{{ end }}
{{ end }}
83 changes: 43 additions & 40 deletions layouts/_default/single.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
{{ define "styles" }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/post.scss" "dest" "css/post.css") }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/post.scss" "dest" "css/post.css") }}
{{ end }}

{{ define "main" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="flex-wrapper">
<div class="post__container">
<div class="post">
<header class="post__header">
<h1 id="post__title">{{.Title}}</h1>
{{ if .Date }}<time datetime="{{ .Date }}" class="post__date">{{ .Date.Format $dateFormat }}</time> {{ end }}
</header>
<article class="post__content">
{{ partial "anchored-headings.html" .Content }}
{{ if or .Params.math .Site.Params.math }}
{{ partial "math.html" . }}
{{ end }}
</article>
{{ partial "tags.html" .}} {{ partial "post-pagination.html" .}}
{{ template "_internal/disqus.html" . }}
<footer class="post__footer">
{{ partial "social-icons.html" .}}
<p>{{ replace .Site.Copyright "{year}" now.Year }}</p>
</footer>
</div>
</div>
{{ if .Params.toc }}
<div class="toc-container">
{{ if .Site.Params.showPageTitleInTOC }} <div class="toc-post-title">{{ .Title }}</div> {{ end }}
{{ .TableOfContents }}
</div>
{{ end }}
<div class="flex-wrapper">
<div class="post__container">
<div class="post">
<header class="post__header">
<h1 id="post__title">{{.Title}}</h1>
{{ if .Date }}<time datetime="{{ .Date }}" class="post__date">{{ .Date.Format $dateFormat }}</time> {{ end }}
</header>
<article class="post__content">
{{ partial "anchored-headings.html" .Content }}
{{ if or .Params.math .Site.Params.math }}
{{ partial "math.html" . }}
{{ end }}
</article>
{{ partial "tags.html" .}} {{ partial "post-pagination.html" .}}
{{ template "_internal/disqus.html" . }}
<footer class="post__footer">
{{ partial "social-icons.html" .}}
<p>{{ replace .Site.Copyright "{year}" now.Year }}</p>
</footer>
</div>

{{ end }}
</div>
<div>
{{ partial "sidebar.html" .}}
{{ if .Params.toc }}
<div class="toc-container">
{{ if .Site.Params.showPageTitleInTOC }} <div class="toc-post-title">{{ .Title }}</div> {{ end }}
{{ .TableOfContents }}
</div>
{{ end }}
</div>
</div>

{{ define "scripts" }}
{{/* Hardcode a specific prismjs version to avoid a redirect on every page load. */}}
<script src="https://unpkg.com/[email protected]/components/prism-core.min.js"></script>
{{ end }}

{{/* Automatically loads the needed languages to highlight the code blocks. */}}
<script src="https://unpkg.com/prismjs@1.20.0/plugins/autoloader/prism-autoloader.min.js"
data-autoloader-path="https://unpkg.com/[email protected]/components/"></script>
{{ define "scripts" }}
{{/* Hardcode a specific prismjs version to avoid a redirect on every page load. */}}
<script src="https://unpkg.com/[email protected]/components/prism-core.min.js"></script>

{{ if .Params.toc }}
<script src="/js/table-of-contents.js"></script>
{{ end }}
{{/* Automatically loads the needed languages to highlight the code blocks. */}}
<script src="https://unpkg.com/[email protected]/plugins/autoloader/prism-autoloader.min.js"
data-autoloader-path="https://unpkg.com/[email protected]/components/"></script>

{{ if .Params.toc }}
<script src="/js/table-of-contents.js"></script>
{{ end }}

{{ end }}
20 changes: 12 additions & 8 deletions layouts/partials/post-pagination.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
{{ if ne .Params.pagination false}}

<div class="pagination">
{{if .PrevInSection}}
<a class="pagination__item" href="{{.PrevInSection.Permalink}}">
<span class="pagination__label">{{ i18n "prev_post" }}</span>
<span class="pagination__title">{{.PrevInSection.Title}}</span>
</a>
<a class="pagination__item" href="{{.PrevInSection.Permalink}}">
<span class="pagination__label">{{ i18n "prev_post" }}</span>
<span class="pagination__title">{{.PrevInSection.Title}}</span>
</a>
{{end}}

{{if .NextInSection}}
<a class="pagination__item" href="{{.NextInSection.Permalink}}">
<span class="pagination__label">{{ i18n "next_post" }}</span>
<span class="pagination__title" >{{.NextInSection.Title}}</span>
</a>
<a class="pagination__item" href="{{.NextInSection.Permalink}}">
<span class="pagination__label">{{ i18n "next_post" }}</span>
<span class="pagination__title">{{.NextInSection.Title}}</span>
</a>
{{end}}
</div>

{{end}}
8 changes: 8 additions & 0 deletions layouts/partials/sidebar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ if eq .Site.Params.sidebar.visible true }}

<div class="sidebar-container">
<b class="sidebar-title"> {{ .Site.Params.sidebar.title }}</b>
<p class="sidebar-text">{{ .Site.Params.sidebar.text }}</p>
</div>

{{ end }}
41 changes: 21 additions & 20 deletions layouts/taxonomy/tag.html
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
{{ define "styles" }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/tags.scss" "dest" "css/tags.css") }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/tags.scss" "dest" "css/tags.css") }}
{{ end }}

{{ define "main" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}
{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="post-list__container">
<div class="tag__header">
<a href="/blog">{{ i18n "all_posts" }}</a><span class="separator">/</span>
<h1 class="tag__term">{{ .Title }}</h1>
</div>
<ul class="post-list">
{{ range .Data.Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}">{{ .Date.Format $dateFormat }}</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
</div>
</li>
{{ end }}
</ul>
<div class="post-list__container">
<div class="tag__header">
<a href="/blog">{{ i18n "all_posts" }}</a><span class="separator">/</span>
<h1 class="tag__term">{{ .Title }}</h1>
</div>
{{ end }}
<ul class="post-list">
{{ range .Data.Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}">{{ .Date.Format $dateFormat }}</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
</div>
</li>
{{ end }}
</ul>
{{partial "sidebar.html" .}}
</div>
{{ end }}