feat: auto-load custom svg sprites from assets folder (#79)

BREAKING CHANGE: Build-in icons are prefixed with `gdoc_` now. If you use build-in icons in e.g. menus you have to rename these references!
This commit is contained in:
Robert Kaussow 2021-03-03 21:07:59 +01:00 committed by GitHub
parent f228c1b2c2
commit 5e105c9ff4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 688 additions and 39 deletions

View file

@ -14,7 +14,7 @@
<main class="gdoc-error flex-even">
<div class="flex align-center justify-center">
<div class="gdoc-error__icon">
<svg class="icon telescope"><use xlink:href="#telescope"></use></svg>
<svg class="icon gdoc_telescope"><use xlink:href="#gdoc_telescope"></use></svg>
</div>
<div class="gdoc-error__message">
<div class="gdoc-error__line gdoc-error__title">Lost?</div>

View file

@ -5,7 +5,7 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
{{ .Text | safeHTML }}
<a data-clipboard-text="{{ .Page.Permalink }}#{{ .Anchor | safeURL }}" class="gdoc-page__anchor gdoc-page__anchor--right clip" aria-label="Anchor {{ .Text | safeHTML }}" href="#{{ .Anchor | safeURL }}">
<svg class="icon link"><use xlink:href="#link"></use></svg>
<svg class="icon gdoc_link"><use xlink:href="#gdoc_link"></use></svg>
</a>
</h{{ .Level }}>
</div>

View file

@ -36,8 +36,8 @@
</a>
</span>
{{ if $hasCollapse }}
<svg class="icon keyborad_arrow_left"><use xlink:href="#keyborad_arrow_left"></use></svg>
<svg class="icon keyborad_arrow_down hidden"><use xlink:href="#keyborad_arrow_down"></use></svg>
<svg class="icon gdoc_keyborad_arrow_left"><use xlink:href="#gdoc_keyborad_arrow_left"></use></svg>
<svg class="icon gdoc_keyborad_arrow_down hidden"><use xlink:href="#gdoc_keyborad_arrow_down"></use></svg>
</label>
{{ end }}
{{ else }}

View file

@ -32,8 +32,8 @@
<span class="flex">{{ partial "title" . }}</span>
{{ end }}
{{ if $hasCollapse }}
<svg class="icon keyborad_arrow_left"><use xlink:href="#keyborad_arrow_left"></use></svg>
<svg class="icon keyborad_arrow_down hidden"><use xlink:href="#keyborad_arrow_down"></use></svg>
<svg class="icon gdoc_keyborad_arrow_left"><use xlink:href="#gdoc_keyborad_arrow_left"></use></svg>
<svg class="icon gdoc_keyborad_arrow_down hidden"><use xlink:href="#gdoc_keyborad_arrow_down"></use></svg>
</label>
{{ end }}

View file

@ -26,7 +26,7 @@
{{ if (and (not $showBreadcrumb) (not $showEdit)) }} hidden {{ end }}" itemprop="breadcrumb">
{{if $showBreadcrumb }}
<div>
<svg class="icon path hidden-mobile"><use xlink:href="#path"></use></svg>
<svg class="icon gdoc_path hidden-mobile"><use xlink:href="#gdoc_path"></use></svg>
<ol class="breadcrumb" itemscope itemtype="https://schema.org/BreadcrumbList">
{{ $position := sub (len (split .RelPermalink "/")) 1 }}
{{ $name := (partial "title" .) }}
@ -38,7 +38,7 @@
{{ if $showEdit }}
<div>
<span class="editpage">
<svg class="icon code"><use xlink:href="#code"></use></svg>
<svg class="icon gdoc_code"><use xlink:href="#gdoc_code"></use></svg>
<a href="{{ $geekdocRepo }}/{{ $geekdocEditPath }}/{{ $.Scratch.Get "geekdocFilePath" }}">
Edit this page
</a>

View file

@ -1,6 +1,6 @@
{{ if default true .Site.Params.GeekdocSearch }}
<div class="gdoc-search">
<svg class="icon search"><use xlink:href="#search"></use></svg>
<svg class="icon gdoc_search"><use xlink:href="#gdoc_search"></use></svg>
<input type="text" id="gdoc-search-input" class="gdoc-search__input" placeholder="Search..."
aria-label="Search" maxlength="64" />
<div class="gdoc-search__spinner spinner hidden"></div>

View file

@ -2,7 +2,7 @@
<div class="container flex flex-wrap">
<span class="gdoc-footer__item">
Built with <a href="https://gohugo.io/" class="gdoc-footer__link">Hugo</a> and
<svg class="icon heart"><use xlink:href="#heart"></use></svg>
<svg class="icon gdoc_heart"><use xlink:href="#gdoc_heart"></use></svg>
</span>
{{ with .Site.Params.GeekdocLegalNotice }}
<span class="gdoc-footer__item">

View file

@ -2,8 +2,8 @@
<div class="container flex align-center justify-between">
{{ if .MenuEnabled }}
<label for="menu-control" class="gdoc-nav__control">
<svg class="icon menu"><use xlink:href="#menu"></use></svg>
<svg class="icon arrow-back"><use xlink:href="#arrow_back"></use></svg>
<svg class="icon gdoc_menu"><use xlink:href="#gdoc_menu"></use></svg>
<svg class="icon gdoc_arrow_back"><use xlink:href="#gdoc_arrow_back"></use></svg>
</label>
{{ end }}
<a class="gdoc-header__link" href="{{ .Root.Site.BaseURL }}">

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 137 B

Before After
Before After

View file

@ -4,7 +4,7 @@
<header class="gdoc-post__header">
<h1 class="gdoc-post__title"><a href="{{ .RelPermalink }}">{{ .Title }}</a></h1>
<div class="gdoc-post__date">
<svg class="icon date"><use xlink:href="#date"></use></svg>
<svg class="icon gdoc_date"><use xlink:href="#gdoc_date"></use></svg>
<time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ if ne (.Lastmod.Format "2006-01-02") (.Date.Format "2006-01-02") }}
Updated on

View file

@ -3,7 +3,7 @@
<header class="gdoc-post__header">
<h1 class="gdoc-post__title">{{ .Title }}</h1>
<div class="gdoc-post__date">
<svg class="icon date"><use xlink:href="#date"></use></svg>
<svg class="icon gdoc_date"><use xlink:href="#gdoc_date"></use></svg>
<time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}">
{{ if ne (.Lastmod.Format "2006-01-02") (.Date.Format "2006-01-02") }}
Updated on

View file

@ -0,0 +1,5 @@
{{ $id := .Get 0 }}
{{- with $id -}}
<svg class="icon {{ . }}"><use xlink:href="#{{ . }}"></use></svg>
{{- end -}}