From 4d47f5192a78772118a00ad5371e4f2b153f9d08 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas <foo.dogsquared@gmail.com> Date: Tue, 22 Nov 2022 19:59:24 +0800 Subject: [PATCH] Limit external link styling --- assets/scss/base.scss | 24 -------------------- assets/templates/site.scss | 46 +++++++++++++++++++++++++++++--------- layouts/_default/list.html | 6 ++--- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/assets/scss/base.scss b/assets/scss/base.scss index 2df7426..1758a8b 100644 --- a/assets/scss/base.scss +++ b/assets/scss/base.scss @@ -36,30 +36,6 @@ article { } } -/* -Select all links that are external. - -In this case, we'll just exclude all links that are... - -- All internal anchors. -- All links that points to a relative path. -- All origin-relative URLs. - -Also, all links that are explicitly marked as external are obviously -considered. -*/ -a[href]:not(:where( - a[href^="#"], - a[href^="./"], - a[href^="../"], - a[href^="/"]:not(a[href^="//"]), -))::after, a[rel~="external"]::after { - color: var(--base05); - font-size: 0.50em; - content: " [🡕]"; - vertical-align: super; -} - /* Text formatting */ h1, h2, h3, h4, h5, h6 { diff --git a/assets/templates/site.scss b/assets/templates/site.scss index 365ae70..1d3ff9c 100644 --- a/assets/templates/site.scss +++ b/assets/templates/site.scss @@ -2,14 +2,40 @@ This is a site-specific styling that have to be generated. */}} -/* Internal links are not to be styled. */ -{{- $baseURL := urls.Parse $.Site.BaseURL }} -a[href]:where( - a[href^="http://{{- $baseURL.Host -}}"], - a[href^="https://{{- $baseURL.Host -}}"], - a[href$="{{- $baseURL.Host -}}"], - a[href$="{{- $baseURL.Host -}}/"], - a[href^="{{- $.Site.BaseURL -}}"], -)::after { - content: unset; +article > main { + /* + Select all links that are external. + + In this case, we'll just exclude all links that are... + + - All internal anchors. + - All links that points to a relative path. + - All origin-relative URLs. + + Also, all links that are explicitly marked as external are obviously + considered. + */ + a[href]:not(:where( + a[href^="#"], + a[href^="./"], + a[href^="../"], + a[href^="/"]:not(a[href^="//"]), + ))::after, a[rel~="external"]::after { + color: var(--base05); + font-size: 0.50em; + content: " [🡕]"; + vertical-align: super; + } + + /* Internal links are not to be styled. */ + {{- $baseURL := urls.Parse $.Site.BaseURL }} + a[href]:where( + a[href^="http://{{- $baseURL.Host -}}"], + a[href^="https://{{- $baseURL.Host -}}"], + a[href$="{{- $baseURL.Host -}}"], + a[href$="{{- $baseURL.Host -}}/"], + a[href^="{{- $.Site.BaseURL -}}"], + )::after { + content: unset; + } } diff --git a/layouts/_default/list.html b/layouts/_default/list.html index ef48b6d..ee8a78b 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,7 +1,6 @@ {{ define "main" }} -<section> -{{ .Content }} -</section> +<article> + <main>{{- .Content }}</main> {{- /* The homepage should show only pages from the given sections (with `$.Site.Params.mainSections`). Otherwise, we take the pages of a section. */ -}} @@ -18,4 +17,5 @@ Otherwise, we take the pages of a section. */ -}} {{- end }} {{- partial "pagination.html" (dict "Paginator" .Paginator "activeNumberOfPages" 2) }} +</article> {{- end }}