Merge remote-tracking branch 'origin/feature/clipboard' into feature/clipboard

This commit is contained in:
geoffreygarrett 2022-07-03 13:36:55 +02:00
commit 51786f92c6
5 changed files with 40 additions and 32 deletions

View File

@ -8,12 +8,7 @@ const syntaxTheme = document.querySelector("#theme-link");
if (currentTheme) { if (currentTheme) {
document.documentElement.setAttribute('saved-theme', currentTheme); document.documentElement.setAttribute('saved-theme', currentTheme);
if (currentTheme === 'dark') { syntaxTheme.href = currentTheme === 'dark' ? '{{ $darkSyntax.Permalink }}' : '{{ $lightSyntax.Permalink }}';
syntaxTheme.href = '{{ $darkSyntax.Permalink }}';
}
else {
syntaxTheme.href = '{{ $lightSyntax.Permalink }}';
}
} }
const switchTheme = (e) => { const switchTheme = (e) => {

View File

@ -15,26 +15,33 @@
z-index: 1; z-index: 1;
opacity: 0; opacity: 0;
transition: 0.12s; transition: 0.12s;
}
.clipboard-button > svg { & > svg {
fill: var(--light); fill: var(--light);
filter: contrast(0.3); filter: contrast(0.3);
} }
.clipboard-button:hover {
cursor: pointer; &:hover {
border-color: var(--primary); cursor: pointer;
} border-color: var(--primary);
.clipboard-button:hover > svg {
fill: var(--primary); & > svg {
} fill: var(--primary);
.clipboard-button:focus { }
outline: 0; }
}
.highlight { &:focus {
position: relative; outline: 0;
} }
.highlight:hover > .clipboard-button {
opacity: 1;
transition: 0.2s;
} }
.highlight {
position: relative;
&:hover > .clipboard-button {
opacity: 1;
transition: 0.2s;
}
}

View File

@ -66,7 +66,7 @@ Please note that the `cname` field should *not* have any path `e.g. end with /qu
[Reference `deploy.yaml` here](https://github.com/jackyzha0/quartz/blob/hugo/.github/workflows/deploy.yaml) [Reference `deploy.yaml` here](https://github.com/jackyzha0/quartz/blob/hugo/.github/workflows/deploy.yaml)
```yaml ```yaml {title=".github/workflows/deploy.yaml"}
- name: Deploy - name: Deploy
uses: peaceiris/actions-gh-pages@v3 uses: peaceiris/actions-gh-pages@v3
with: with:

View File

@ -1,8 +1,9 @@
{{$src := .Destination | safeURL }} {{$src := .Destination | safeURL }}
{{$width := index (split .Text "|") 1 | default "auto" }}
{{$external := strings.HasPrefix $src "http" }} {{$external := strings.HasPrefix $src "http" }}
{{- if $external -}} {{- if $external -}}
<img src="{{ $src }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} /> <img src="{{ $src }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
{{- else -}} {{- else -}}
{{$fixedUrl := (cond (hasPrefix $src "/") $src (print "/" $src)) | urlize}} {{$fixedUrl := (cond (hasPrefix $src "/") $src (print "/" $src)) | urlize}}
<img src="{{.Page.Site.BaseURL}}{{ $fixedUrl }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} /> <img src="{{.Page.Site.BaseURL}}{{ $fixedUrl }}" width="{{ $width }}" alt="{{ .Text }}" {{ with .Title }} title="{{ . }}" {{ end }} />
{{- end -}} {{- end -}}

View File

@ -95,6 +95,7 @@
{{if $.Site.Data.config.enableClipboard -}} {{if $.Site.Data.config.enableClipboard -}}
addCopyButtons(); addCopyButtons();
{{ end }} {{ end }}
{{if $.Site.Data.config.enableSPA -}} {{if $.Site.Data.config.enableSPA -}}
addTitleToCodeBlocks(); addTitleToCodeBlocks();
{{ end }} {{ end }}
@ -135,6 +136,7 @@
window.addEventListener("DOMContentLoaded", addCopyButtons); window.addEventListener("DOMContentLoaded", addCopyButtons);
{{ end }} {{ end }}
{{ end }} {{ end }}
{{if $.Site.Data.config.enableCodeBlockTitle -}} {{if $.Site.Data.config.enableCodeBlockTitle -}}
{{if $.Site.Data.config.enableSPA -}} {{if $.Site.Data.config.enableSPA -}}
addTitleToCodeBlocks(); addTitleToCodeBlocks();
@ -166,8 +168,11 @@
navigate: (url) => (window.location.href = url), navigate: (url) => (window.location.href = url),
prefetch: () => {}, prefetch: () => {},
} }
init()
render() window.addEventListener("DOMContentLoaded", () => {
init()
render()
})
</script> </script>
{{end}} {{end}}
</head> </head>