9 Commits

Author SHA1 Message Date
bbab41e90f WIP table of contents 2023-10-21 21:49:04 -05:00
0b3b160e87 Rename config.yaml to hugo.yaml in exampleSite 2023-10-21 21:45:22 -05:00
12c6efc0fe Add "Skip to main content" tab-focusable button
- https://webaim.org/techniques/skipnav/
- https://css-tricks.com/how-to-create-a-skip-to-content-link/
2023-10-21 20:21:26 -05:00
0e930f7ae1 Clean up dom layout of full-width page lists
They shouldn't be a child of the centered, max-width'd body because they
need to be full width. So put them outside of the main container div.
2023-10-21 19:44:02 -05:00
289f55dc19 Throw error in include shortcode if file not found 2023-10-16 20:35:05 -05:00
0ddf0bdf42 Improve print compatiblity with navbar redesign 2023-10-15 20:54:11 -05:00
03d826f1c4 Fix wrong highlight color on navbar 2023-10-15 19:40:45 -05:00
f94307cdbf Redesign navbar to be full width 2023-10-15 19:33:10 -05:00
fde24f7438 Fix navbar highlighting on section page itself 2023-10-15 17:49:56 -05:00
7 changed files with 130 additions and 116 deletions

View File

@ -173,19 +173,18 @@ html {
body { body {
background-color: var(--background-0); background-color: var(--background-0);
color: var(--text-0); color: var(--text-0);
margin: 20px;
max-width: 720px;
overflow-wrap: break-word; overflow-wrap: break-word;
margin: 0;
} }
@media (min-width: 760px) { .main-container {
body { margin: 20px auto;
margin: 20px auto; padding: 0 20px;
} max-width: 760px; /* 720px + 20px for left & right padding */
} }
footer { footer {
margin-top: 20px; margin: 20px 0;
text-align: center; text-align: center;
font-size: smaller; font-size: smaller;
} }
@ -308,12 +307,7 @@ h1 svg.icon {
/* }}} */ /* }}} */
/* Heading formatting (website title and article section headers) {{{ */ /* Heading formatting (article section titles) {{{ */
.header {
margin: 16px 0;
font-size: 1.5em;
}
/* this is also used i.e. in page-title */ /* this is also used i.e. in page-title */
.heading-link { .heading-link {
@ -328,26 +322,36 @@ h1 svg.icon {
/* }}} */ /* }}} */
/* Navbar formatting {{{ */ /* Top bar formatting {{{ */
.top {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-between;
background-color: var(--background-1);
}
.header {
flex-grow: 1;
margin: 8px 16px;
font-size: 1.25em;
display: flex;
align-items: center;
}
.navbar { .navbar {
display: flex; display: flex;
flex-grow: 1; flex-wrap: wrap;
overflow: auto;
background-color: var(--background-1);
border-radius: 8px;
margin-top: 5px;
padding: 4px;
} }
.navbar-item { .navbar-item {
padding: 8px 12px; padding: 12px 16px;
border-radius: 12px;
white-space: nowrap; white-space: nowrap;
} }
.navbar-item:hover { .navbar-item:hover {
background-color: var(--background-3); background-color: var(--background-2);
text-decoration: none; text-decoration: none;
} }
@ -374,6 +378,22 @@ h1 svg.icon {
} }
/* }}} */ /* }}} */
/* Skip to main content {{{ */
#skip-to-main {
position: absolute;
padding: 8px;
background-color: var(--text-0);
color: var(--background-0);
transform: translateY(-100%);
}
#skip-to-main:focus {
transform: translateY(0%);
}
#main-content:target {
animation: none; /* prevent it from turning yellow */
}
/* }}} */
/* Breadcrumb navigation {{{ */ /* Breadcrumb navigation {{{ */
.breadcrumb { .breadcrumb {
@ -884,47 +904,26 @@ aside.quote {
margin: 25px 0; margin: 25px 0;
} }
.full-width-page-list > hr, .related-posts > hr,
.full-width-page-list > h1 { .related-posts > h1 {
margin-left: 20px; margin-left: 20px;
margin-right: 20px; margin-right: 20px;
} }
.full-width-page-list .page { .related-posts .page {
min-width: 300px; min-width: 300px;
max-width: 300px; max-width: 300px;
} }
.full-width-page-list .page:first-child { .related-posts .page:first-child {
margin-left: 20px; margin-left: 20px;
} }
.full-width-page-list .page:last-child { .related-posts .page:last-child {
margin-right: 20px; margin-right: 20px;
} }
@media (max-width: 720px) { .related-posts .page-list {
/* when the screen is smaller than max size, make sure that the .related div
* still reaches the screen edge. then if the posts overflow and require
* scrolling, you can see it cut off on the side of your phone screen
*/
.full-width-page-list {
margin-left: -20px;
margin-right: -20px;
}
}
@media (min-width: 720px) {
.full-width-page-list {
/* this makes it full width -- 720px max-width on body it is exactly 720px
* so .related takes up full width
*/
margin-left: calc(-100vw / 2 + 720px / 2);
margin-right: calc(-100vw / 2 + 720px / 2);
}
}
.full-width-page-list .page-list {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 20px; gap: 20px;
@ -946,13 +945,12 @@ aside.quote {
/* Print compatibility {{{ */ /* Print compatibility {{{ */
@media print { @media print {
.top, .top > .navbar,
.section-header-link, .section-header-link,
.post-meta-edit-history, .post-meta-edit-history,
.prevnext, .prevnext,
.share-buttons, .share-buttons,
.related-posts, .related-posts {
.latest-posts {
display: none; display: none;
} }
@ -961,8 +959,21 @@ aside.quote {
color-adjust: exact !important; color-adjust: exact !important;
} }
body { .top {
background-color: unset;
}
.top > .header {
margin-left: 0;
margin-right: 0;
}
.main-container {
max-width: 100%; max-width: 100%;
margin: 8px 0;
padding: 0;
}
.breadcrumb {
margin: 8px 0;
} }
table, table,
@ -971,12 +982,17 @@ aside.quote {
break-inside: avoid; break-inside: avoid;
} }
.table-of-contents { .table-of-contents:not(.print) {
display: none; display: none;
} }
.table-of-contents.print { .table-of-contents.print {
display: block; display: block;
background-color: unset;
padding: 0;
}
.table-of-contents.print ul {
margin: 0;
} }
#back-to-top { #back-to-top {

View File

@ -32,9 +32,6 @@ params:
# gitFileIcon: github-circle # gitFileIcon: github-circle
# gitHistoryURL: https://github.com/BBaoVanC/bobatheme/commits/master # gitHistoryURL: https://github.com/BBaoVanC/bobatheme/commits/master
# display a "Latest Posts" section on the homepage below its content
homepageLatestPosts: true
# social media share icons # social media share icons
# shareButtons: # shareButtons:
# twitter: true # twitter: true

View File

@ -5,18 +5,36 @@
<body> <body>
<a id="top" aria-hidden="true"></a> <a id="top" aria-hidden="true"></a>
<a id="skip-to-main" href="#main-content">Skip to main content</a>
<a id="back-to-top" href="#top" aria-label="{{ i18n "aria_back_to_top_button" }}">
{{ partial "icon.html" "chevron-up" }}
</a>
<noscript>
<style>
#back-to-top {
display: block;
}
</style>
</noscript>
{{ partial "top.html" . }} {{ partial "top.html" . }}
{{ if not .IsHome }} <div class="main-container">
{{ partial "breadcrumb.html" . }} {{ if not .IsHome }}
{{ end }} {{ partial "breadcrumb.html" . }}
<main>
{{ block "main" . }}
THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it)
{{ end }} {{ end }}
</main>
<main id="main-content">
{{ block "main" . }}
THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it)
{{ end }}
</main>
</div>
{{ block "post-body" . }}
{{/* currently this is only used for related posts */}}
{{ end }}
{{ if or .Site.Copyright .Site.Params.footer }} {{ if or .Site.Copyright .Site.Params.footer }}
<footer> <footer>
@ -29,17 +47,6 @@
{{ end }} {{ end }}
</footer> </footer>
{{ end }} {{ end }}
<a id="back-to-top" href="#top" aria-label="{{ i18n "aria_back_to_top_button" }}">
{{ partial "icon.html" "chevron-up" }}
</a>
<noscript>
<style>
#back-to-top {
display: block;
}
</style>
</noscript>
</body> </body>
</html> </html>

View File

@ -73,17 +73,16 @@
{{ partial "comments.html" . }} {{ partial "comments.html" . }}
</div> </div>
{{ end }} {{ end }}
{{ end }}
{{ define "post-body" }}
{{ $related := .Site.RegularPages.Related . | first 10 }} {{ $related := .Site.RegularPages.Related . | first 10 }}
{{ with $related }} {{ with $related }}
<div class="related-posts full-width-page-list"> <div class="related-posts">
<hr> <hr>
<h1>{{ i18n "related_posts" }}</h1> <h1>{{ i18n "related_posts" }}</h1>
{{ partial "page-list.html" . }} {{ partial "page-list.html" . }}
</div> </div>
{{ end }} {{ end }}
{{ if .Site.Params.latestPostsOnContent }}
{{ partialCached "latest-posts.html" . }}
{{ end }}
{{ end }} {{ end }}

View File

@ -1,11 +0,0 @@
<div class="latest-posts full-width-page-list">
<hr>
<h1>
{{ i18n "latest_posts" }}
{{ partial "rss-link.html" .Site.Home }}
</h1>
{{ with .Site.RegularPages | first 5 }}
{{ partial "page-list.html" . }}
{{ end }}
</div>

View File

@ -1,21 +1,24 @@
<header class="header"> <div class="top">
<a class="heading-link" href="{{ .Site.Home.Permalink | absLangURL }}"> <header class="header">
{{ .Site.Title | markdownify }} <a class="heading-link" href="{{ .Site.Home.Permalink | absLangURL }}">
</a> {{ .Site.Title | markdownify }}
</header> </a>
</header>
<nav class="navbar" aria-label="{{ i18n "aria_navbar" }}"> <nav class="navbar" aria-label="{{ i18n "aria_navbar" }}">
{{ with .Site.Home }} {{ with .Site.Home }}
<a class="navbar-item{{ if $.IsHome }} active{{ end }}" href="{{ .Permalink | absLangURL }}">{{ .Title | markdownify }}</a> <a class="navbar-item{{ if $.IsHome }} active{{ end }}" href="{{ .Permalink | absLangURL }}">{{ .Title | markdownify }}</a>
{{ end }}
{{ range .Site.Menus.main }}
{{ $isActive := false }}
{{ if or ($.HasMenuCurrent .Menu .) ($.IsMenuCurrent .Menu .) }}
{{ $isActive = true }}
{{ end }} {{ end }}
<a class="navbar-item{{ if $isActive }} active{{ end }}"
{{ if strings.HasPrefix .URL "http" }}target="_blank" rel="noopener"{{ end }} {{ range .Site.Menus.main }}
href="{{ .URL }}">{{ .Name }}</a> {{ $isActive := false }}
{{ end }} {{/* https://discourse.gohugo.io/t/ismenucurrent-not-working-with-using-sectionpagesmenu/46687/2?u=bbaovanc */}}
</nav> {{ if or ($.HasMenuCurrent .Menu .) (eq .Page $) }}
{{ $isActive = true }}
{{ end }}
<a class="navbar-item{{ if $isActive }} active{{ end }}"
{{ if strings.HasPrefix .URL "http" }}target="_blank" rel="noopener"{{ end }}
href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
</nav>
</div>

View File

@ -9,9 +9,12 @@
{{ $path = .Get 0 }} {{ $path = .Get 0 }}
{{ end }} {{ end }}
{{ with ($path | readFile) }}
{{ if $markdown }} {{ if $markdown }}
{{ $path | readFile | .Page.RenderString (dict "display" "block") }} {{ $path | readFile | $.Page.RenderString (dict "display" "block") }}
{{ else }}
{{ $path | readFile }}
{{ end }}
{{ else }} {{ else }}
{{ $path | readFile }} {{ errorf "file not found: %s" $path }}
{{ end }} {{ end }}