diff --git a/README.md b/README.md index 61436628..2253b448 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # FixIt Theme | Hugo [![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases) -[![Hugo](https://img.shields.io/badge/Hugo-%5E0.112.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/) +[![Hugo](https://img.shields.io/badge/Hugo-%5E0.123.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/) [![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE) 👉 English README | [简体中文说明](README.zh-cn.md) diff --git a/README.zh-cn.md b/README.zh-cn.md index 03d3aa24..3c582bde 100644 --- a/README.zh-cn.md +++ b/README.zh-cn.md @@ -1,7 +1,7 @@ # FixIt 主题 | Hugo [![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases) -[![Hugo](https://img.shields.io/badge/Hugo-%5E0.112.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/) +[![Hugo](https://img.shields.io/badge/Hugo-%5E0.123.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/) [![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE) 👉 [English README](README.md) | 简体中文说明 diff --git a/assets/css/_shortcodes/_cardlink.scss b/assets/css/_shortcodes/_cardlink.scss index 25287013..d3651ee9 100644 --- a/assets/css/_shortcodes/_cardlink.scss +++ b/assets/css/_shortcodes/_cardlink.scss @@ -76,7 +76,7 @@ white-space: nowrap; } - &icon-shortcut { + &shortcut-icon { width: 4rem; height: 4rem; flex-shrink: 0; @@ -91,6 +91,14 @@ } } + &shortcut-image { + width: 4rem; + height: 4rem !important; + flex-shrink: 0; + margin-left: 0.25rem; + object-fit: cover; + } + [data-theme='dark'] & { &content { background-color: rgba(61, 62, 65, 0.88); diff --git a/hugo.toml b/hugo.toml index a53f206a..d8a8158e 100644 --- a/hugo.toml +++ b/hugo.toml @@ -133,7 +133,7 @@ enableEmoji = true [module] [module.hugoVersion] extended = true - min = "0.112.0" + min = "0.123.0" # ------------------------------------------------------------------------------------- # Markup related configuration in Hugo diff --git a/layouts/partials/function/get-remote-json.html b/layouts/partials/function/get-remote-json.html index 52c696e8..043e3d70 100644 --- a/layouts/partials/function/get-remote-json.html +++ b/layouts/partials/function/get-remote-json.html @@ -1,5 +1,6 @@ {{- $response := dict -}} -{{- with resources.GetRemote .URL .OPTIONS -}} +{{- $options := .OPTIONS | default dict -}} +{{- with resources.GetRemote .URL $options -}} {{- with .Err -}} {{- erroridf "error-get-remote-json" "%s" . -}} {{- else -}} diff --git a/layouts/partials/plugin/link.html b/layouts/partials/plugin/link.html index 86186ade..b897175b 100644 --- a/layouts/partials/plugin/link.html +++ b/layouts/partials/plugin/link.html @@ -44,10 +44,10 @@ {{- $cardIcon := .CardIcon -}} {{- if $url.Host | and (eq .CardIcon true) -}} {{- $cardIcon = false -}} - {{- /* 中国大陆地区无法使用,如果你有更好的 API 或者方案,欢迎 PR! */ -}} - {{- $favicon := partial "function/get-remote-image.html" (dict "Path" (add "https://www.google.com/s2/favicons?sz=64&domain=" $url.Host) "Pass" true) -}} - {{- with $favicon -}} - {{- $cardIcon = .RelPermalink -}} + {{- $imageJson := partial "function/get-remote-json.html" (dict "URL" (add "https://www.zhihu.com/api/v3/scraper?url=" (.Destination | urlquery))) -}} + {{- with $imageJson.image -}} + {{- /* if need, cache remote image here and set `$params.cacheRemoteImages.shortcode` to `true` */ -}} + {{- $cardIcon = . -}} {{- end -}} {{- end -}} @@ -72,16 +72,16 @@ {{- if .Download -}} - + {{- else -}} {{- with $cardIcon -}} {{- if (strings.HasPrefix . "fa") -}} - + {{- else -}} - card icon + card image {{- end -}} {{- else -}} - + {{- end -}} {{- end -}} diff --git a/package.json b/package.json index 9d95bb34..a8d271c7 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "license": "MIT", "author": "Lruihao (https://lruihao.cn)", "scripts": { - "build": "hugo --source=demo --themesDir ../.. --theme $PWD --gc --minify --logLevel info", + "build": "hugo --source=demo --themesDir ../.. --theme $PWD --gc --minify --logLevel info", "server": "hugo server --source=demo --themesDir ../.. --theme $PWD -D --disableFastRender --navigateToChanged --ignoreCache", "server:production": "npm run server -- -e production", "server:docs": "hugo server --source=../fixit-docs -D --disableFastRender --navigateToChanged --ignoreCache", diff --git a/theme.toml b/theme.toml index 5304b9b7..9ebab62d 100644 --- a/theme.toml +++ b/theme.toml @@ -7,7 +7,7 @@ licenselink = "https://github.com/hugo-fixit/FixIt/blob/master/LICENSE" description = "A Clean, Elegant but Advanced Hugo Theme for Hugo." homepage = "https://github.com/hugo-fixit/FixIt" demosite = "https://fixit.lruihao.cn" -min_version = "0.112.0" +min_version = "0.123.0" tags = [ "blog",