Skip to content

Commit

Permalink
feat: sticky navbar with default to false
Browse files Browse the repository at this point in the history
see #6
  • Loading branch information
tomowang committed Dec 15, 2023
1 parent f764d62 commit 9a6e99f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ For advanced usage, please refer to config directory `config/_default` and
Some of the configuration options are:

* `markup`: goldmark and options for markdown rendering
* `params.header`: header settings (logo for now)
* `params.header`: header settings (logo and sticky navbar)
* `params.footer`: footer settings (copyright years, powered by, etc.)
* `contentTypeName`: dir name of your blog content (default is `content/posts`).
* `params.taxonomies.icons`: icons for taxonomies (categories, tags, series, etc.).
Expand Down
8 changes: 8 additions & 0 deletions assets/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -1149,10 +1149,18 @@ video {
top: 0px;
}

.top-10 {
top: 2.5rem;
}

.top-16 {
top: 4rem;
}

.z-10 {
z-index: 10;
}

.z-50 {
z-index: 50;
}
Expand Down
1 change: 1 addition & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ showReadingTime = true

[header]
logo = "https://placehold.co/512/webp"
sticky = false

[footer]
since = 2023
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
{{ partial "head.html" . }}
</head>
<body class="w-full bg-slate-50 dark:bg-gray-800">
<header class="flex flex-none justify-center">
<header class="flex flex-none justify-center z-10 {{- if $.Site.Params.header.sticky }} bg-slate-50 dark:bg-gray-800 sticky top-0{{ end -}}">
{{ partial "header.html" . }}
</header>
<main class="flex flex-auto justify-center">
Expand Down
2 changes: 1 addition & 1 deletion layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ <h2 class="text-4xl font-semibold text-slate-800 dark:text-slate-200">
</article>
{{ end }}
</section>
<aside class="hidden md:flex flex-col md:w-1/3 mx-3 top-0 sticky self-start">
<aside class="hidden md:flex flex-col md:w-1/3 mx-3 {{- if .Site.Params.header.sticky }} top-10 {{ else }} top-0 {{ end -}} sticky self-start">
{{ partial "sidebar.html" . }}
</aside>
</div>
Expand Down

0 comments on commit 9a6e99f

Please sign in to comment.