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 {
background-color: var(--background-0);
color: var(--text-0);
margin: 20px;
max-width: 720px;
overflow-wrap: break-word;
margin: 0;
}
@media (min-width: 760px) {
body {
margin: 20px auto;
}
.main-container {
margin: 20px auto;
padding: 0 20px;
max-width: 760px; /* 720px + 20px for left & right padding */
}
footer {
margin-top: 20px;
margin: 20px 0;
text-align: center;
font-size: smaller;
}
@ -308,12 +307,7 @@ h1 svg.icon {
/* }}} */
/* Heading formatting (website title and article section headers) {{{ */
.header {
margin: 16px 0;
font-size: 1.5em;
}
/* Heading formatting (article section titles) {{{ */
/* this is also used i.e. in page-title */
.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 {
display: flex;
flex-grow: 1;
overflow: auto;
background-color: var(--background-1);
border-radius: 8px;
margin-top: 5px;
padding: 4px;
flex-wrap: wrap;
}
.navbar-item {
padding: 8px 12px;
border-radius: 12px;
padding: 12px 16px;
white-space: nowrap;
}
.navbar-item:hover {
background-color: var(--background-3);
background-color: var(--background-2);
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 {
@ -884,47 +904,26 @@ aside.quote {
margin: 25px 0;
}
.full-width-page-list > hr,
.full-width-page-list > h1 {
.related-posts > hr,
.related-posts > h1 {
margin-left: 20px;
margin-right: 20px;
}
.full-width-page-list .page {
.related-posts .page {
min-width: 300px;
max-width: 300px;
}
.full-width-page-list .page:first-child {
.related-posts .page:first-child {
margin-left: 20px;
}
.full-width-page-list .page:last-child {
.related-posts .page:last-child {
margin-right: 20px;
}
@media (max-width: 720px) {
/* 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 {
.related-posts .page-list {
display: flex;
flex-direction: row;
gap: 20px;
@ -946,13 +945,12 @@ aside.quote {
/* Print compatibility {{{ */
@media print {
.top,
.top > .navbar,
.section-header-link,
.post-meta-edit-history,
.prevnext,
.share-buttons,
.related-posts,
.latest-posts {
.related-posts {
display: none;
}
@ -961,8 +959,21 @@ aside.quote {
color-adjust: exact !important;
}
body {
.top {
background-color: unset;
}
.top > .header {
margin-left: 0;
margin-right: 0;
}
.main-container {
max-width: 100%;
margin: 8px 0;
padding: 0;
}
.breadcrumb {
margin: 8px 0;
}
table,
@ -971,12 +982,17 @@ aside.quote {
break-inside: avoid;
}
.table-of-contents {
.table-of-contents:not(.print) {
display: none;
}
.table-of-contents.print {
display: block;
background-color: unset;
padding: 0;
}
.table-of-contents.print ul {
margin: 0;
}
#back-to-top {

View File

@ -32,9 +32,6 @@ params:
# gitFileIcon: github-circle
# 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
# shareButtons:
# twitter: true

View File

@ -5,18 +5,36 @@
<body>
<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" . }}
{{ if not .IsHome }}
{{ partial "breadcrumb.html" . }}
{{ end }}
<main>
{{ block "main" . }}
THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it)
<div class="main-container">
{{ if not .IsHome }}
{{ partial "breadcrumb.html" . }}
{{ 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 }}
<footer>
@ -29,17 +47,6 @@
{{ end }}
</footer>
{{ 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>
</html>

View File

@ -73,17 +73,16 @@
{{ partial "comments.html" . }}
</div>
{{ end }}
{{ end }}
{{ define "post-body" }}
{{ $related := .Site.RegularPages.Related . | first 10 }}
{{ with $related }}
<div class="related-posts full-width-page-list">
<div class="related-posts">
<hr>
<h1>{{ i18n "related_posts" }}</h1>
{{ partial "page-list.html" . }}
</div>
{{ end }}
{{ if .Site.Params.latestPostsOnContent }}
{{ partialCached "latest-posts.html" . }}
{{ 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">
<a class="heading-link" href="{{ .Site.Home.Permalink | absLangURL }}">
{{ .Site.Title | markdownify }}
</a>
</header>
<div class="top">
<header class="header">
<a class="heading-link" href="{{ .Site.Home.Permalink | absLangURL }}">
{{ .Site.Title | markdownify }}
</a>
</header>
<nav class="navbar" aria-label="{{ i18n "aria_navbar" }}">
{{ with .Site.Home }}
<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 }}
<nav class="navbar" aria-label="{{ i18n "aria_navbar" }}">
{{ with .Site.Home }}
<a class="navbar-item{{ if $.IsHome }} active{{ end }}" href="{{ .Permalink | absLangURL }}">{{ .Title | markdownify }}</a>
{{ 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>
{{ range .Site.Menus.main }}
{{ $isActive := false }}
{{/* https://discourse.gohugo.io/t/ismenucurrent-not-working-with-using-sectionpagesmenu/46687/2?u=bbaovanc */}}
{{ 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 }}
{{ end }}
{{ if $markdown }}
{{ $path | readFile | .Page.RenderString (dict "display" "block") }}
{{ with ($path | readFile) }}
{{ if $markdown }}
{{ $path | readFile | $.Page.RenderString (dict "display" "block") }}
{{ else }}
{{ $path | readFile }}
{{ end }}
{{ else }}
{{ $path | readFile }}
{{ errorf "file not found: %s" $path }}
{{ end }}