From 6bed0f26242fa6182e7789a1d631907673685d20 Mon Sep 17 00:00:00 2001
From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com>
Date: Tue, 1 Jul 2025 00:21:58 +0800
Subject: [PATCH 1/4] docs: document showSummary option in article shortcode
---
exampleSite/content/docs/shortcodes/index.it.md | 1 +
exampleSite/content/docs/shortcodes/index.ja.md | 1 +
exampleSite/content/docs/shortcodes/index.md | 2 ++
exampleSite/content/docs/shortcodes/index.zh-cn.md | 2 ++
4 files changed, 6 insertions(+)
diff --git a/exampleSite/content/docs/shortcodes/index.it.md b/exampleSite/content/docs/shortcodes/index.it.md
index a5bfdd81..42aaaeb2 100644
--- a/exampleSite/content/docs/shortcodes/index.it.md
+++ b/exampleSite/content/docs/shortcodes/index.it.md
@@ -72,6 +72,7 @@ This is an error!
| Parameter | Description |
| --------- | -------------------------------------------------------- |
| `link` | **Required.** the `.RelPermalink` to the target article. |
+| `showSummary` | **Optional.** A boolean value indicating whether to show the article summary. If not set, the site's default configuration will be used. |
**Example:**
diff --git a/exampleSite/content/docs/shortcodes/index.ja.md b/exampleSite/content/docs/shortcodes/index.ja.md
index ff728e09..6cb83f3e 100644
--- a/exampleSite/content/docs/shortcodes/index.ja.md
+++ b/exampleSite/content/docs/shortcodes/index.ja.md
@@ -72,6 +72,7 @@ Twitter で私を[フォロー](https://twitter.com/nunocoracao)するのを忘
| パラメータ | 説明 |
| --------- | -------------------------------------------------------- |
| `link` | **必須** ターゲット記事への `.RelPermalink`。 |
+| `showSummary` | **任意。** 記事の要約を表示するかどうかを示すブール値。設定されていない場合、サイトのデフォルト設定が使用されます。 |
**例:**
diff --git a/exampleSite/content/docs/shortcodes/index.md b/exampleSite/content/docs/shortcodes/index.md
index 43f45ab0..052a2e81 100644
--- a/exampleSite/content/docs/shortcodes/index.md
+++ b/exampleSite/content/docs/shortcodes/index.md
@@ -72,6 +72,8 @@ This is an error!
| Parameter | Description |
| --------- | -------------------------------------------------------- |
| `link` | **Required.** the `.RelPermalink` to the target article. |
+| `showSummary` | **Optional.** A boolean value indicating whether to show the article summary. If not set, the site's default configuration will be used. |
+
**Example:**
diff --git a/exampleSite/content/docs/shortcodes/index.zh-cn.md b/exampleSite/content/docs/shortcodes/index.zh-cn.md
index 8d9886b2..acd32b4a 100644
--- a/exampleSite/content/docs/shortcodes/index.zh-cn.md
+++ b/exampleSite/content/docs/shortcodes/index.zh-cn.md
@@ -72,6 +72,8 @@ This is an error!
| 参数 | 功能 |
| ------ | ------------------------------------- |
| `link` | **必填** 要嵌入文章的 `.RelPermalink` |
+| `showSummary` | **可选。** 一个布尔值,指示是否显示文章摘要。如果未设置,将使用站点的默认配置。 |
+
**例如:**
From b4a7741b39e12a8ad6d2bb90255ea0aeb130ae1e Mon Sep 17 00:00:00 2001
From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com>
Date: Tue, 1 Jul 2025 01:24:34 +0800
Subject: [PATCH 2/4] feat: add support for showSummary in article shortcode
---
assets/css/compiled/main.css | 12 ++
layouts/partials/article-link/_shortcode.html | 113 ++++++++++++++++++
layouts/shortcodes/article.html | 4 +-
3 files changed, 128 insertions(+), 1 deletion(-)
create mode 100644 layouts/partials/article-link/_shortcode.html
diff --git a/assets/css/compiled/main.css b/assets/css/compiled/main.css
index 7ca3ba0b..8f462959 100644
--- a/assets/css/compiled/main.css
+++ b/assets/css/compiled/main.css
@@ -1689,6 +1689,9 @@ body.zen-mode-enable {
.p-1\.5 {
padding: calc(var(--spacing) * 1.5);
}
+ .p-2\.5 {
+ padding: calc(var(--spacing) * 2.5);
+ }
.p-4 {
padding: calc(var(--spacing) * 4);
}
@@ -1758,6 +1761,9 @@ body.zen-mode-enable {
.py-\[1px\] {
padding-block: 1px;
}
+ .pt-1 {
+ padding-top: calc(var(--spacing) * 1);
+ }
.pt-2 {
padding-top: calc(var(--spacing) * 2);
}
@@ -1785,6 +1791,9 @@ body.zen-mode-enable {
.pr-\[24px\] {
padding-right: 24px;
}
+ .pb-0 {
+ padding-bottom: calc(var(--spacing) * 0);
+ }
.pb-2 {
padding-bottom: calc(var(--spacing) * 2);
}
@@ -1809,6 +1818,9 @@ body.zen-mode-enable {
.pl-2 {
padding-left: calc(var(--spacing) * 2);
}
+ .pl-4 {
+ padding-left: calc(var(--spacing) * 4);
+ }
.pl-\[24px\] {
padding-left: 24px;
}
diff --git a/layouts/partials/article-link/_shortcode.html b/layouts/partials/article-link/_shortcode.html
new file mode 100644
index 00000000..79756146
--- /dev/null
+++ b/layouts/partials/article-link/_shortcode.html
@@ -0,0 +1,113 @@
+{{ $target := .target }}
+{{ $shortcodeShowSummary := .showSummary }}
+{{ $constrainItemsWidth := site.Params.list.constrainItemsWidth | default false }}
+{{ $disableImageOptimization := site.Params.disableImageOptimization | default false }}
+
+{{ $articleClasses := "flex flex-wrap md:flex-nowrap article" }}
+{{ if site.Params.list.showCards }}
+ {{ $articleClasses = delimit (slice $articleClasses "border border-neutral-200 dark:border-neutral-700 border-2 rounded-md overflow-hidden") " " }}
+{{ else }}
+ {{ $articleClasses = delimit (slice $articleClasses "") " " }}
+{{ end }}
+
+{{ $articleImageClasses := "w-full md:w-auto h-full thumbnail nozoom" }}
+{{ if site.Params.list.showCards }}
+ {{ $articleImageClasses = delimit (slice $articleImageClasses "") " " }}
+{{ else }}
+ {{ $articleImageClasses = delimit (slice $articleImageClasses "thumbnailshadow md:mr-7") " " }}
+{{ end }}
+
+{{ $articleInnerClasses := "" }}
+{{ if site.Params.list.showCards }}
+ {{ $articleInnerClasses = delimit (slice $articleInnerClasses "p-2.5 pl-4 pb-0") " " }}
+{{ else }}
+ {{ $articleInnerClasses = delimit (slice $articleInnerClasses "mt-3 md:mt-0") " " }}
+{{ end }}
+
+{{ if $constrainItemsWidth }}
+ {{ $articleClasses = delimit (slice $articleClasses "max-w-prose") " " }}
+{{ end }}
+
+
+
+ {{- with $target.Params.images -}}
+ {{- range first 6 . }}
+
+ {{ end -}}
+ {{- else -}}
+ {{- $images := $target.Resources.ByType "image" -}}
+ {{- $featured := $images.GetMatch "*feature*" -}}
+ {{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
+ {{ if and $target.Params.featureimage (not $featured) }}
+ {{- $url:= $target.Params.featureimage -}}
+ {{ $featured = resources.GetRemote $url }}
+ {{ end }}
+ {{- if not $featured }}
+ {{ with site.Params.defaultFeaturedImage }}{{ $featured = resources.Get . }}{{ end }}
+ {{ end -}}
+ {{ if $target.Params.hideFeatureImage }}{{ $featured = false }}{{ end }}
+ {{- with $featured -}}
+ {{ if or $disableImageOptimization (strings.HasSuffix $featured ".svg") }}
+ {{ with . }}
+
+ {{ end }}
+ {{ else }}
+ {{ with .Resize "600x" }}
+
+ {{ end }}
+ {{ end }}
+ {{- else -}}
+ {{- with site.Params.images }}
+
+ {{ end -}}
+ {{- end -}}
+ {{- end -}}
+
+
+
diff --git a/exampleSite/content/docs/shortcodes/index.ja.md b/exampleSite/content/docs/shortcodes/index.ja.md
index 6cb83f3e..0bf5722e 100644
--- a/exampleSite/content/docs/shortcodes/index.ja.md
+++ b/exampleSite/content/docs/shortcodes/index.ja.md
@@ -72,16 +72,17 @@ Twitter で私を[フォロー](https://twitter.com/nunocoracao)するのを忘
| パラメータ | 説明 |
| --------- | -------------------------------------------------------- |
| `link` | **必須** ターゲット記事への `.RelPermalink`。 |
-| `showSummary` | **任意。** 記事の要約を表示するかどうかを示すブール値。設定されていない場合、サイトのデフォルト設定が使用されます。 |
+| `showSummary` | **オプション** のブール値で、記事の要約を表示するかどうかを示します。設定されていない場合は、サイトのデフォルト設定が使用されます。 |
+| `compactSummary` | **オプション** のブール値で、要約をコンパクトモードで表示するかどうかを示します。デフォルトは false です。 |
**例:**
```md
-{{* article link="/docs/welcome/" */>}}
+{{* article link="/ja/docs/welcome/" showSummary=true compactSummary=true */>}}
```
-{{< article link="/docs/welcome/" >}}
+{{< article link="/ja/docs/welcome/" showSummary=true compactSummary=true >}}
diff --git a/exampleSite/content/docs/shortcodes/index.md b/exampleSite/content/docs/shortcodes/index.md
index 052a2e81..4ec2be3a 100644
--- a/exampleSite/content/docs/shortcodes/index.md
+++ b/exampleSite/content/docs/shortcodes/index.md
@@ -73,16 +73,16 @@ This is an error!
| --------- | -------------------------------------------------------- |
| `link` | **Required.** the `.RelPermalink` to the target article. |
| `showSummary` | **Optional.** A boolean value indicating whether to show the article summary. If not set, the site's default configuration will be used. |
-
+| `compactSummary` | **Optional.** A boolean value indicating whether to display the summary in compact mode. Default to false. |
**Example:**
```md
-{{* article link="/docs/welcome/" */>}}
+{{* article link="/docs/welcome/" showSummary=true compactSummary=true */>}}
```
-{{< article link="/docs/welcome/" >}}
+{{< article link="/docs/welcome/" showSummary=true compactSummary=true >}}
diff --git a/exampleSite/content/docs/shortcodes/index.zh-cn.md b/exampleSite/content/docs/shortcodes/index.zh-cn.md
index acd32b4a..91ec4cf5 100644
--- a/exampleSite/content/docs/shortcodes/index.zh-cn.md
+++ b/exampleSite/content/docs/shortcodes/index.zh-cn.md
@@ -72,17 +72,17 @@ This is an error!
| 参数 | 功能 |
| ------ | ------------------------------------- |
| `link` | **必填** 要嵌入文章的 `.RelPermalink` |
-| `showSummary` | **可选。** 一个布尔值,指示是否显示文章摘要。如果未设置,将使用站点的默认配置。 |
-
+| `showSummary` | **可选** 布尔值,指示是否显示文章摘要。如果未设置,将使用站点的默认配置。 |
+| `compactSummary` | **可选** 布尔值,指示是否以紧凑模式显示摘要。默认为 false。 |
**例如:**
```md
-{{* article link="/zh-cn/docs/welcome/" */>}}
+{{* article link="/zh-cn/docs/welcome/" showSummary=true compactSummary=true */>}}
```
-{{< article link="/zh-cn/docs/welcome/" >}}
+{{< article link="/zh-cn/docs/welcome/" showSummary=true compactSummary=true >}}
From 965c241f8c080950354d48886feb9cf58dfb610d Mon Sep 17 00:00:00 2001
From: ZhenShuo Leo <98386542+ZhenShuo2021@users.noreply.github.com>
Date: Tue, 1 Jul 2025 00:42:56 +0800
Subject: [PATCH 4/4] feat: add support for compactSummary option in article
shortcode
---
assets/css/compiled/main.css | 6 ++++++
layouts/partials/article-link/_shortcode.html | 9 ++++++++-
layouts/shortcodes/article.html | 3 ++-
3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/assets/css/compiled/main.css b/assets/css/compiled/main.css
index 8f462959..402e86f1 100644
--- a/assets/css/compiled/main.css
+++ b/assets/css/compiled/main.css
@@ -1028,6 +1028,12 @@ body.zen-mode-enable {
height: 8px;
}
}
+ .line-clamp-3 {
+ overflow: hidden;
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ -webkit-line-clamp: 3;
+ }
.\!block {
display: block !important;
}
diff --git a/layouts/partials/article-link/_shortcode.html b/layouts/partials/article-link/_shortcode.html
index 79756146..db73ec3c 100644
--- a/layouts/partials/article-link/_shortcode.html
+++ b/layouts/partials/article-link/_shortcode.html
@@ -1,5 +1,6 @@
{{ $target := .target }}
{{ $shortcodeShowSummary := .showSummary }}
+{{ $shortcodeCompactSummary := .compactSummary }}
{{ $constrainItemsWidth := site.Params.list.constrainItemsWidth | default false }}
{{ $disableImageOptimization := site.Params.disableImageOptimization | default false }}
@@ -103,8 +104,14 @@
{{ $showSummary = $target.Params.showSummary | default (site.Params.list.showSummary | default false) }}
{{ end }}
{{ if $showSummary }}
+ {{ $compactSummary := false }}
+ {{ if ne $shortcodeCompactSummary nil }}
+ {{ $compactSummary = $shortcodeCompactSummary }}
+ {{ else }}
+ {{ $compactSummary = $target.Params.compactSummary | default (site.Params.list.compactSummary | default false) }}
+ {{ end }}