mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 10:21:46 +01:00
refactor(article): remove color tag & add custom category color (#75)
closes: https://github.com/CaiJimmy/hugo-theme-stack/issues/71
This commit is contained in:
parent
31c42bcfe7
commit
e606dca404
3 changed files with 6 additions and 29 deletions
|
@ -22,20 +22,6 @@ let Stack = {
|
|||
new StackGallery(articleContent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add color to tags
|
||||
*/
|
||||
document.querySelectorAll('.color-tag').forEach(async (tag: HTMLLinkElement) => {
|
||||
const imageURL = tag.getAttribute('data-image'),
|
||||
key = tag.getAttribute('data-key'),
|
||||
hash = tag.getAttribute('data-hash');
|
||||
|
||||
const colors = await getColor(key, hash, imageURL);
|
||||
|
||||
tag.style.color = colors.Vibrant.bodyTextColor;
|
||||
tag.style.background = colors.Vibrant.hex;
|
||||
})
|
||||
|
||||
/**
|
||||
* Add linear gradient background to tile style article
|
||||
*/
|
||||
|
|
|
@ -3,4 +3,7 @@ title: "Test"
|
|||
description: "This is a example category"
|
||||
slug: "test"
|
||||
image: "hutomo-abrianto-l2jk-uxb1BY-unsplash.jpg"
|
||||
style:
|
||||
background: "#2a9d8f"
|
||||
color: "#fff"
|
||||
---
|
|
@ -1,22 +1,10 @@
|
|||
{{ $image := partialCached "helper/image" (dict "Context" . "Type" "article") .RelPermalink "article" }}
|
||||
{{- $context := . -}}
|
||||
<div class="article-details">
|
||||
{{ if .Params.categories }}
|
||||
<header class="article-category">
|
||||
{{ range (.GetTerms "categories") }}
|
||||
{{ if and $image.exists $image.resource }}
|
||||
{{- $imageRaw := $image.resource | resources.Fingerprint "md5" -}}
|
||||
{{- $20x := $imageRaw.Fill "20x20 smart" -}}
|
||||
<a href="{{ .RelPermalink }}"
|
||||
class="color-tag"
|
||||
data-image="{{ $20x.RelPermalink }}"
|
||||
data-key="{{ $context.Slug }}"
|
||||
data-hash="{{ $imageRaw.Data.Integrity }}">
|
||||
{{ .LinkTitle }}
|
||||
</a>
|
||||
{{ else }}
|
||||
<a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
|
||||
{{ end }}
|
||||
<a href="{{ .RelPermalink }}" {{ with .Params.style }}style="background-color: {{ .background }}; color: {{ .color }};"{{ end }}>
|
||||
{{ .LinkTitle }}
|
||||
</a>
|
||||
{{ end }}
|
||||
</header>
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in a new issue