1 Commits

Author SHA1 Message Date
7780ccb376 WIP: use template to generate the individual share buttons 2025-07-30 01:59:40 -05:00
21 changed files with 141 additions and 177 deletions

View File

@@ -158,38 +158,61 @@ pre > code {
/* }}} */ /* }}} */
/* Common distances/sizes {{{ */ /* Basic elements {{{ */
:root { html {
--page-margin: 16px; scroll-behavior: smooth;
} }
/* }}} */ @media screen and (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
body {
background-color: var(--background-0);
color: var(--text-0);
overflow-wrap: break-word;
margin: 0;
}
/* Common elements {{{ */ .main-container {
margin: 20px auto;
padding: 0 20px;
max-width: 760px; /* 720px + 20px for left & right padding */
}
footer {
margin: 20px 0;
text-align: center;
font-size: smaller;
}
footer p {
margin: 0;
}
img, img,
video { video {
max-width: 100%; max-width: 100%;
} }
figure > .figure-media { .post-media > figure img,
.post-media > figure video {
padding: 5px; padding: 5px;
}
figure > .figure-media.border {
border: 2px solid var(--figure-border);
}
.post-media > figure > .figure-media {
border: 7px solid var(--figure-border); border: 7px solid var(--figure-border);
} }
figure img,
figure video {
padding: 5px;
border: 2px solid var(--figure-border);
}
figure { figure {
display: block; margin: auto;
text-align: center; display: inline-block;
margin: 0;
} }
figcaption { figcaption {
@@ -217,6 +240,14 @@ hr {
border: 1px solid var(--background-3); border: 1px solid var(--background-3);
} }
@media (min-width: 720px) {
.full-width-hr {
/* see also: the related-posts section too */
margin-left: calc(-100vw / 2 + 760px / 2);
margin-right: calc(-100vw / 2 + 760px / 2);
}
}
table.simple { table.simple {
border-collapse: collapse; border-collapse: collapse;
border: 2px solid var(--text-1); border: 2px solid var(--text-1);
@@ -276,40 +307,12 @@ table.simple tbody tr:nth-child(even) {
/* }}} */ /* }}} */
/* Baseof formatting {{{ */ /* Heading formatting (article section titles) {{{ */
html { /* this is also used i.e. in page-title */
scroll-behavior: smooth; .heading-link {
} color: inherit;
font-weight: bold;
@media screen and (prefers-reduced-motion: reduce) {
html {
scroll-behavior: auto;
}
}
body {
background-color: var(--background-0);
color: var(--text-0);
overflow-wrap: break-word;
margin: 0;
}
.main-container {
margin: var(--page-margin) auto;
/* use padding because otherwise there's no way to have margin be both auto, and a minimum value */
padding: 0 var(--page-margin);
max-width: calc(720px + 2 * var(--page-margin)); /* padding is included in the element's width */
}
footer {
margin: var(--page-margin) 0;
text-align: center;
font-size: smaller;
}
footer p {
margin: 0;
} }
/* }}} */ /* }}} */
@@ -322,30 +325,23 @@ footer p {
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
background-color: var(--background-1); background-color: var(--background-1);
/* padding can't be here because then the first navbar element will be shifted too far over,
* or it will need its hover background to be chopped off on the left */
} }
.header { .header {
flex-grow: 1; flex-grow: 1;
margin: 8px var(--page-margin); margin: 8px 16px;
font-size: 1.25em; font-size: 1.25em;
display: flex; display: flex;
align-items: center; align-items: center;
} }
.header a {
color: inherit;
font-weight: bold;
}
.navbar { .navbar {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
} }
.navbar-item { .navbar-item {
padding: 12px var(--page-margin); padding: 12px 16px;
white-space: nowrap; white-space: nowrap;
} }
@@ -379,7 +375,7 @@ footer p {
/* Breadcrumb navigation {{{ */ /* Breadcrumb navigation {{{ */
.breadcrumb { .breadcrumb {
margin: var(--page-margin) 0; margin: 20px 0;
} }
.breadcrumb ul { .breadcrumb ul {
@@ -487,10 +483,6 @@ footer p {
margin-bottom: 10px; margin-bottom: 10px;
} }
.page-title a {
color: inherit;
}
.page-title h1 { .page-title h1 {
margin: 0; margin: 0;
} }
@@ -641,7 +633,7 @@ footer p {
/* }}} */ /* }}} */
/* Components exclusive to content/single pages {{{ */ /* Content (single) formatting {{{ */
.series-box { .series-box {
background-color: var(--background-1); background-color: var(--background-1);
@@ -784,13 +776,10 @@ footer p {
padding: 4px 8px; padding: 4px 8px;
border-top-left-radius: 8px; border-top-left-radius: 8px;
border-top-right-radius: 8px; border-top-right-radius: 8px;
height: 2em;
}
.code-block > .code-header > * {
margin: auto 0;
} }
.code-block > .code-header > .code-type { .code-block > .code-header > .code-type {
border-top-left-radius: 8px; border-top-left-radius: 8px;
margin: auto 0;
} }
/* TODO: make the code copy button prettier */ /* TODO: make the code copy button prettier */
.code-block > .code-header > .code-copy-button { .code-block > .code-header > .code-copy-button {
@@ -884,16 +873,19 @@ aside.quote {
/* }}} */ /* }}} */
/* }}} */
/* Related posts section {{{ */ /* Related posts section {{{ */
/* set the margins on the contents instead of the parent .related-posts .full-width-page-list {
* so that the posts in the list clip off the edge of the screen, /* make left/right 0 margin so it takes up full width */
* which makes a more obvious indicator that it's scrollable margin: 25px 0;
*/ }
.related-posts > hr, .related-posts > hr,
.related-posts > h1 { .related-posts > h1 {
margin: var(--page-margin); margin-left: 20px;
margin-right: 20px;
} }
.related-posts .page { .related-posts .page {
@@ -903,24 +895,21 @@ aside.quote {
} }
.related-posts .page:first-child { .related-posts .page:first-child {
margin-left: var(--page-margin); margin-left: 20px;
} }
.related-posts .page:last-child { .related-posts .page:last-child {
margin-right: var(--page-margin); margin-right: 20px;
} }
.related-posts .page-list { .related-posts .page-list {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 20px; gap: 20px;
overflow-x: auto; overflow-x: scroll;
margin-bottom: var(--page-margin);
} }
/* }}} */ /* }}} */
/* }}} */
/* @media specializations {{{ */ /* @media specializations {{{ */

View File

@@ -1,14 +1,3 @@
.comments > h2 {
margin-bottom: 0;
}
.comments .email-address-notice {
margin: 0;
font-size: smaller;
}
.comments .enable-javascript-notice {
font-style: italic;
}
/* Isso styling */ /* Isso styling */
h4.isso-thread-heading { h4.isso-thread-heading {
color: var(--text-0); color: var(--text-0);

View File

@@ -1,3 +0,0 @@
.code-copy-button {
display: none;
}

View File

@@ -1,20 +1,15 @@
{{/* put comments CSS here instead of in <head> so that it doesn't get
* loaded unnecessarily on regular pages
*/}}
{{ with resources.Get "css/comments.css" | fingerprint "sha512" }} {{ with resources.Get "css/comments.css" | fingerprint "sha512" }}
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }} {{ end }}
<h2>Comments</h2> <h2 style="margin-bottom: 0;">Comments</h2>
<p class="email-address-notice"> <p style="margin: 0; font-size: smaller;">
If you provide an email address, you can enable notifications for If you provide an email address, you can enable notifications for
replies to your comment. It will not be shown publicly. replies to your comment. It will not be shown publicly.
</p> </p>
<noscript> <noscript>
<p class="enable-javascript-notice"> <i>Enable JavaScript to see the comment section.</i>
Enable JavaScript to see the comment section.
</p>
</noscript> </noscript>
<section id="isso-thread" data-title="{{ .Title }}"></section> <section id="isso-thread" data-title="{{ .Title }}"></section>

View File

@@ -0,0 +1,7 @@
{{ with .Description }}
<p>{{ . | markdownify }}</p>
{{ else }}
{{ with .Summary }}
{{ . }}
{{ end }}
{{ end }}

View File

@@ -3,9 +3,9 @@
* claims that images won't work with JS disabled since it would * claims that images won't work with JS disabled since it would
* make tracking possible, but my experience says otherwise * make tracking possible, but my experience says otherwise
*/}} */}}
<img class="figure-media" src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} /> <img src="{{ .Permalink }}" {{ with .Params.alt }}alt="{{ . }}"{{ end }} />
{{ else if eq .ResourceType "video" }} {{ else if eq .ResourceType "video" }}
<video class="figure-media" controls preload="metadata"> <video controls preload="metadata">
{{ with .Params.alt }} {{ with .Params.alt }}
{{ warnf "video does not support alt text, '%s'" . }} {{ warnf "video does not support alt text, '%s'" . }}
{{ end }} {{ end }}

View File

@@ -6,12 +6,6 @@
{{ with resources.Get "css/bobastyle.css" | fingerprint "sha512" }} {{ with resources.Get "css/bobastyle.css" | fingerprint "sha512" }}
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"> <link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{ end }} {{ end }}
{{ with resources.Get "css/noscript.css" | fingerprint "sha512" }}
<noscript>
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
</noscript>
{{ end }}
{{ with resources.Get "css/syntax.css" | fingerprint "sha512" }} {{ with resources.Get "css/syntax.css" | fingerprint "sha512" }}
<link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" media="print" onload="this.media='all'"> <link rel="stylesheet" type="text/css" href="{{ .Permalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous" media="print" onload="this.media='all'">
{{ end }} {{ end }}

View File

@@ -1,6 +1,6 @@
{{ if gt .Paginator.TotalPages 1 }} {{ if gt .Paginator.TotalPages 1 }}
<nav class="pagination"> <nav class="pagination">
{{/* https://github.com/gohugoio/hugo/blob/a88b488181279befd50e1d127f9f67604f2f9854/tpl/tplimpl/embedded/templates/_partials/pagination.html */}} {{/* https://github.com/gohugoio/hugo/blob/a88b488181279befd50e1d127f9f67604f2f9854/tpl/tplimpl/embedded/templates/_partials/pagination.html */}}
{{ partial "pagination-hugo.html" . }} {{ partial "_internal/pagination.html" . }}
</nav> </nav>
{{ end }} {{ end }}

View File

@@ -3,6 +3,16 @@
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}"> <meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
<meta property="og:url" content="{{ .Permalink }}"> <meta property="og:url" content="{{ .Permalink }}">
{{ $images := $.Resources.ByType "image" }}
{{ $featured := $images.GetMatch "*feature*" }}
{{ if not $featured }}
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ end }}
{{ with $featured }}
<meta property="og:image" content="{{ $featured.Permalink }}">
{{ end }}
{{ with .Section }} {{ with .Section }}
<meta property="article:section" content="{{ . }}"> <meta property="article:section" content="{{ . }}">
{{ end }} {{ end }}
@@ -27,38 +37,12 @@
<meta property="og:site_name" content="{{ . }}"> <meta property="og:site_name" content="{{ . }}">
{{ end }} {{ end }}
{{ $images := $.Resources.ByType "image" }}
{{ $featured := $images.GetMatch "*feature*" }}
{{ if not $featured }}
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ end }}
{{ with $featured }}
<meta property="og:image" content="{{ $featured.Permalink }}">
{{ with .Params.alt }}
<meta property="og:image:alt" content="{{ . }}">
{{ end }}
{{ with .MediaType }}
<meta property="og:image:type" content="{{ . }}">
{{ end }}
{{ with .Width }}
<meta property="og:image:width" content="{{ . }}">
{{ end }}
{{ with .Height }}
<meta property="og:image:height" content="{{ . }}">
{{ end }}
{{ end }}
{{ $videos := $.Resources.ByType "video" }} {{ $videos := $.Resources.ByType "video" }}
{{ $featured_video := $videos.GetMatch "*feature*" }} {{ $featured_video := $videos.GetMatch "*feature*" }}
{{ if not $featured_video }} {{ if not $featured_video }}
{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }} {{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}
{{ end }} {{ end }}
{{ with $featured_video }} {{ with $featured_video }}
<meta property="og:video" content="{{ $featured_video.Permalink | absURL }}"> <meta property="og:video" content="{{ $featured_video.Permalink | absURL }}">
{{ with .MediaType }}
<meta property="og:video:type" content="{{ . }}">
{{ end }}
{{ end }} {{ end }}

View File

@@ -31,8 +31,6 @@
*/}} */}}
{{ with .Site.Params.social.twitter }} {{ with .Site.Params.social.twitter }}
<meta name="twitter:site" content="@{{ . }}"> <meta name="twitter:site" content="@{{ . }}">
{{ else }}
{{ errorf "a twitter username is required for twitter cards to work" }}
{{ end }} {{ end }}
{{ with .GetTerms "authors" }} {{ with .GetTerms "authors" }}
{{ range . }} {{ range . }}

View File

@@ -1,4 +1,22 @@
{{ define "_partials/share-button.html" }}
<a class="{{ .ShortName }}-share"
target="_blank"
rel="noopener"
aria-label="{{ i18n (printf "aria_share_%s" .ShortName) }}"
onclick="share_event('{{ .ProperName }}');"
href="{{ .URL }}">
{{- partial "icon.html" (or .IconName .ShortName) -}}
</a>
{{ end }}
<div class="share-buttons"> <div class="share-buttons">
{{ $services := dict
"twitter" (dict "ProperName" "Twitter" "URL" (printf "https://twitter.com/intent/tweet?url=%s&text=%s&via=bbaovanc" .Permalink .Title))
}}
{{ range $name, $info := $services }}
{{ $data := merge $info (dict "ShortName" $name) }}
{{ partial "share-button.html" $data }}
{{ end }}
{{ if .Site.Params.shareButtons.twitter }} {{ if .Site.Params.shareButtons.twitter }}
<a class="twitter-share" <a class="twitter-share"
target="_blank" target="_blank"

View File

@@ -1,6 +1,6 @@
<div class="top"> <div class="top">
<header class="header"> <header class="header">
<a href="{{ .Site.Home.Permalink | absLangURL }}"> <a class="heading-link" href="{{ .Site.Home.Permalink | absLangURL }}">
{{ .Site.Title | markdownify }} {{ .Site.Title | markdownify }}
</a> </a>
</header> </header>

View File

@@ -0,0 +1 @@
<hr class="full-width-hr">

View File

@@ -1,15 +1,13 @@
<h2 class="page-title"> <h2 class="page-title">
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a> <a class="heading-link" href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
{{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }} {{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }}
</h2> </h2>
{{ partial "page-metadata/author.html" . }} {{ partial "page-metadata/author.html" . }}
{{ with .Summary }}
<div class="page-description"> <div class="page-description">
{{ . }} {{ partial "description-or-summary.html" . }}
</div> </div>
{{ end }}
<div class="readmore"> <div class="readmore">
<a href="{{ .Permalink }}">{{ i18n "read_more" }} &rarr;</a> <a href="{{ .Permalink }}">{{ i18n "read_more" }} &rarr;</a>

View File

@@ -13,11 +13,16 @@
{{ partial "breadcrumb.html" . }} {{ partial "breadcrumb.html" . }}
{{ end }} {{ end }}
<main id="main-content"> <main id="main-content" {{ if .IsPage }}data-pagefind-body{{ end }}>
{{ block "main" . }} {{ block "main" . }}
THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it) THIS TEXT SHOULD NOT SHOW. YUZSIQGHE (that string is so I can grep for it)
{{ end }} {{ end }}
</main> </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>
@@ -30,11 +35,6 @@
{{ end }} {{ end }}
</footer> </footer>
{{ end }} {{ end }}
</div>
{{ block "post-body" . }}
{{/* currently this is only used for related posts */}}
{{ end }}
</body> </body>
</html> </html>

View File

@@ -24,7 +24,7 @@
{{ partial "feature-figure.html" . }} {{ partial "feature-figure.html" . }}
<article class="post-content" data-pagefind-body> <article class="post-content">
{{ .Content }} {{ .Content }}
</article> </article>

View File

@@ -5,10 +5,8 @@
{{ .Title | markdownify }} {{ .Title | markdownify }}
</h2> </h2>
{{ with .Summary }}
<div class="section-description"> <div class="section-description">
{{ . }} {{ partial "description-or-summary.html" . }}
</div> </div>
{{ end }}
</div> </div>
</a> </a>

View File

@@ -1,16 +1,14 @@
<h2 class="page-title"> <h2 class="page-title">
{{ with .Parent.Params.icon }}{{ partial "icon.html" . }}{{ end }} {{ with .Parent.Params.icon }}{{ partial "icon.html" . }}{{ end }}
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a> <a class="heading-link" href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
{{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }} {{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }}
</h2> </h2>
{{ partial "page-metadata/series.html" . }} {{ partial "page-metadata/series.html" . }}
{{ with .Summary }}
<div class="page-description"> <div class="page-description">
{{ . }} {{ partial "description-or-summary.html" . }}
</div> </div>
{{ end }}
<div class="page-list series-inner"> <div class="page-list series-inner">
{{ range .Data.Pages.Reverse }} {{ range .Data.Pages.Reverse }}

View File

@@ -1,6 +1,6 @@
<h2 class="page-title"> <h2 class="page-title">
{{ with .Parent.Params.icon }}{{ partial "icon.html" . }}{{ end }} {{ with .Parent.Params.icon }}{{ partial "icon.html" . }}{{ end }}
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a> <a class="heading-link" href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
{{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }} {{ if .Draft }}{{ partial "icon.html" "write" }}{{ end }}
</h2> </h2>
@@ -8,11 +8,9 @@
{{ partial "feature-figure.html" . }} {{ partial "feature-figure.html" . }}
{{ with .Summary }}
<div class="page-description"> <div class="page-description">
{{ . }} {{ partial "description-or-summary.html" . }}
</div> </div>
{{ end }}
<div class="readmore"> <div class="readmore">
<a href="{{ .Permalink }}">{{ i18n "read_more" }} &rarr;</a> <a href="{{ .Permalink }}">{{ i18n "read_more" }} &rarr;</a>

View File

@@ -28,7 +28,7 @@
</a> </a>
{{ partial "page-metadata/taxonomy.html" . }} {{ partial "page-metadata/taxonomy.html" . }}
</div> </div>
{{ .Summary }} {{ partial "description-or-summary.html" . }}
</article> </article>
{{ end }} {{ end }}
{{ end }} {{ end }}