From d8f81fa4573ccdf90030cb8f1252ec27f330493f Mon Sep 17 00:00:00 2001 From: Danny Guo Date: Sun, 27 May 2018 15:32:58 -0500 Subject: [PATCH] Replace AnchorJS with static links --- layouts/_default/list.html | 2 +- layouts/_default/single.html | 2 +- layouts/blog/single.html | 2 +- layouts/partials/anchor.html | 3 ++ layouts/partials/js.html | 4 -- static/css/general.css | 19 ++++++++- static/images/icomoon.json | 82 ++++++++++++++++++++++++++++++++++++ static/images/icons.svg | 9 ++++ 8 files changed, 114 insertions(+), 9 deletions(-) create mode 100644 layouts/partials/anchor.html create mode 100755 static/images/icomoon.json create mode 100755 static/images/icons.svg diff --git a/layouts/_default/list.html b/layouts/_default/list.html index cd93c16..a7373cf 100644 --- a/layouts/_default/list.html +++ b/layouts/_default/list.html @@ -1,5 +1,5 @@ {{ define "main" }} - {{ .Content }} + {{ partial "anchor.html" .Content }} {{ range .Data.Pages.ByDate.Reverse }}

diff --git a/layouts/_default/single.html b/layouts/_default/single.html index bf703c8..a786d68 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,3 +1,3 @@ {{ define "main" }} - {{ .Content }} + {{ partial "anchor.html" .Content }} {{ end }} diff --git a/layouts/blog/single.html b/layouts/blog/single.html index 78b6340..f34915c 100644 --- a/layouts/blog/single.html +++ b/layouts/blog/single.html @@ -6,7 +6,7 @@

{{ .Title }}

Published on {{.Date.Format "2006-01-02"}} - {{ .Content }} + {{ partial "anchor.html" .Content }}
diff --git a/layouts/partials/anchor.html b/layouts/partials/anchor.html new file mode 100644 index 0000000..eef2dd9 --- /dev/null +++ b/layouts/partials/anchor.html @@ -0,0 +1,3 @@ +{{/* Adapted from https://discourse.gohugo.io/t/adding-anchor-next-to-headers/1726 */}} + +{{ . | replaceRE "()" `${1}${3}` | safeHTML }} diff --git a/layouts/partials/js.html b/layouts/partials/js.html index cc8d534..3d195ac 100644 --- a/layouts/partials/js.html +++ b/layouts/partials/js.html @@ -1,12 +1,8 @@ - - {{ template "_internal/google_analytics_async.html" . }} diff --git a/static/css/general.css b/static/css/general.css index 0c859aa..ba12cc5 100644 --- a/static/css/general.css +++ b/static/css/general.css @@ -27,7 +27,7 @@ a { /* Animated link underline on hover Adapted from https://codepen.io/shshaw/details/pdyJBW */ -a:not(.anchorjs-link):not(.link-button) { +a:not(.anchor):not(.link-button) { background-image: linear-gradient(currentColor, currentColor); background-position: 0 100%; background-repeat: no-repeat; @@ -35,10 +35,16 @@ a:not(.anchorjs-link):not(.link-button) { transition: background-size .3s; } -a:not(.anchorjs-link):not(.link-button):hover { +a:not(.anchor):not(.link-button):hover { background-size: 100% 2px; } +.icon-link { + font-size: 0.7em; + margin-left: 0.6em; + margin-bottom: 1px; +} + body { color: #333; font-family: 'Open Sans', sans-serif; @@ -170,3 +176,12 @@ img { .email:hover { background-color: #920126; } + +.icon { + display: inline-block; + width: 1em; + height: 1em; + stroke-width: 0; + stroke: currentColor; + fill: currentColor; +} diff --git a/static/images/icomoon.json b/static/images/icomoon.json new file mode 100755 index 0000000..f872ed1 --- /dev/null +++ b/static/images/icomoon.json @@ -0,0 +1,82 @@ +{ + "IcoMoonType": "selection", + "icons": [ + { + "icon": { + "paths": [ + "M440.236 635.766c-13.31 0-26.616-5.076-36.77-15.23-95.134-95.136-95.134-249.934 0-345.070l192-192c46.088-46.086 107.36-71.466 172.534-71.466s126.448 25.38 172.536 71.464c95.132 95.136 95.132 249.934 0 345.070l-87.766 87.766c-20.308 20.308-53.23 20.308-73.54 0-20.306-20.306-20.306-53.232 0-73.54l87.766-87.766c54.584-54.586 54.584-143.404 0-197.99-26.442-26.442-61.6-41.004-98.996-41.004s-72.552 14.562-98.996 41.006l-192 191.998c-54.586 54.586-54.586 143.406 0 197.992 20.308 20.306 20.306 53.232 0 73.54-10.15 10.152-23.462 15.23-36.768 15.23z", + "M256 1012c-65.176 0-126.45-25.38-172.534-71.464-95.134-95.136-95.134-249.934 0-345.070l87.764-87.764c20.308-20.306 53.234-20.306 73.54 0 20.308 20.306 20.308 53.232 0 73.54l-87.764 87.764c-54.586 54.586-54.586 143.406 0 197.992 26.44 26.44 61.598 41.002 98.994 41.002s72.552-14.562 98.998-41.006l192-191.998c54.584-54.586 54.584-143.406 0-197.992-20.308-20.308-20.306-53.232 0-73.54 20.306-20.306 53.232-20.306 73.54 0.002 95.132 95.134 95.132 249.932 0.002 345.068l-192.002 192c-46.090 46.088-107.364 71.466-172.538 71.466z" + ], + "tags": [ + "link", + "chain", + "url", + "uri", + "anchor" + ], + "defaultCode": 59851, + "grid": 16, + "attrs": [] + }, + "attrs": [], + "properties": { + "ligatures": "link, chain", + "name": "link", + "order": 5, + "id": 204, + "prevSize": 32, + "code": 59851 + }, + "setIdx": 0, + "setId": 1, + "iconIdx": 203 + } + ], + "height": 1024, + "preferences": { + "showGlyphs": true, + "showQuickUse": true, + "showQuickUse2": true, + "showSVGs": true, + "fontPref": { + "prefix": "icon-", + "metadata": { + "fontFamily": "dannyguo", + "majorVersion": 1, + "minorVersion": 0 + }, + "metrics": { + "emSize": 1024, + "baseline": 6.25, + "whitespace": 50 + }, + "embed": false, + "autoHost": true, + "showMetrics": true, + "showSelector": true, + "showMetadata": true, + "noie8": true, + "ie7": false, + "selector": "", + "classSelector": ".icon" + }, + "imagePref": { + "prefix": "icon-", + "png": false, + "useClassSelector": true, + "color": 0, + "bgColor": 16777215, + "classSelector": ".icon", + "height": 32, + "columns": 16, + "margin": 16 + }, + "historySize": 50, + "showCodes": true, + "gridSize": 16, + "quickUsageToken": { + "dannyguo": "MGU5Yzg0MDI4ZWIzNWVjZGYyNmQ4ZGU3YWFhNTg3MGUjMSMxNTI3NDUzNTY1IyMj" + }, + "showLiga": true + } +} \ No newline at end of file diff --git a/static/images/icons.svg b/static/images/icons.svg new file mode 100755 index 0000000..3321ae3 --- /dev/null +++ b/static/images/icons.svg @@ -0,0 +1,9 @@ +