diff --git a/assets/css/compiled/main.css b/assets/css/compiled/main.css index 7ca3ba0b..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; } @@ -1689,6 +1695,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 +1767,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 +1797,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 +1824,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/exampleSite/content/docs/shortcodes/index.it.md b/exampleSite/content/docs/shortcodes/index.it.md index a5bfdd81..82cea40a 100644 --- a/exampleSite/content/docs/shortcodes/index.it.md +++ b/exampleSite/content/docs/shortcodes/index.it.md @@ -72,15 +72,17 @@ 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. | +| `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="/it/docs/welcome/" showSummary=true compactSummary=true >}}


diff --git a/exampleSite/content/docs/shortcodes/index.ja.md b/exampleSite/content/docs/shortcodes/index.ja.md index ff728e09..0bf5722e 100644 --- a/exampleSite/content/docs/shortcodes/index.ja.md +++ b/exampleSite/content/docs/shortcodes/index.ja.md @@ -72,15 +72,17 @@ Twitter で私を[フォロー](https://twitter.com/nunocoracao)するのを忘 | パラメータ | 説明 | | --------- | -------------------------------------------------------- | | `link` | **必須** ターゲット記事への `.RelPermalink`。 | +| `showSummary` | **オプション** のブール値で、記事の要約を表示するかどうかを示します。設定されていない場合は、サイトのデフォルト設定が使用されます。 | +| `compactSummary` | **オプション** のブール値で、要約をコンパクトモードで表示するかどうかを示します。デフォルトは false です。 | **例:** ```md -{{}} +{{}} ``` -{{< 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 43f45ab0..4ec2be3a 100644 --- a/exampleSite/content/docs/shortcodes/index.md +++ b/exampleSite/content/docs/shortcodes/index.md @@ -72,15 +72,17 @@ 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. | +| `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 >}}


diff --git a/exampleSite/content/docs/shortcodes/index.zh-cn.md b/exampleSite/content/docs/shortcodes/index.zh-cn.md index 8d9886b2..91ec4cf5 100644 --- a/exampleSite/content/docs/shortcodes/index.zh-cn.md +++ b/exampleSite/content/docs/shortcodes/index.zh-cn.md @@ -72,15 +72,17 @@ This is an error! | 参数 | 功能 | | ------ | ------------------------------------- | | `link` | **必填** 要嵌入文章的 `.RelPermalink` | +| `showSummary` | **可选** 布尔值,指示是否显示文章摘要。如果未设置,将使用站点的默认配置。 | +| `compactSummary` | **可选** 布尔值,指示是否以紧凑模式显示摘要。默认为 false。 | **例如:** ```md -{{}} +{{}} ``` -{{< article link="/zh-cn/docs/welcome/" >}} +{{< article link="/zh-cn/docs/welcome/" showSummary=true compactSummary=true >}}


diff --git a/layouts/partials/article-link/_shortcode.html b/layouts/partials/article-link/_shortcode.html new file mode 100644 index 00000000..db73ec3c --- /dev/null +++ b/layouts/partials/article-link/_shortcode.html @@ -0,0 +1,120 @@ +{{ $target := .target }} +{{ $shortcodeShowSummary := .showSummary }} +{{ $shortcodeCompactSummary := .compactSummary }} +{{ $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 -}} + + +
+
+ {{ with $target.Params.externalUrl }} +
+
+ {{ $target.Title | emojify }} + + + + +
+
+ {{ else }} +
+ {{ $target.Title | emojify }} +
+ {{ end }} + {{ if and $target.Draft site.Params.article.showDraftLabel }} +
+ {{ partial "badge.html" (i18n "article.draft" | emojify) }} +
+ {{ end }} + {{ if templates.Exists "partials/extend-article-link.html" }} + {{ partial "extend-article-link.html" $target }} + {{ end }} +
+
+ {{ partial "article-meta/basic.html" $target }} +
+ {{ $showSummary := false }} + {{ if ne $shortcodeShowSummary nil }} + {{ $showSummary = $shortcodeShowSummary }} + {{ else }} + {{ $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 }} +
+
+ {{ $target.Summary | plainify }} +
+
+ {{ end }} +
+
diff --git a/layouts/shortcodes/article.html b/layouts/shortcodes/article.html index b85a3ca2..299319ff 100644 --- a/layouts/shortcodes/article.html +++ b/layouts/shortcodes/article.html @@ -1,10 +1,13 @@ {{ $link := .Get "link" }} +{{ $showSummary := .Get "showSummary" }} +{{ $compactSummary := .Get "compactSummary" | default false }} {{ $target := .Page }} {{ if ne $link .Page.RelPermalink }} {{ $target = index (first 1 (where .Site.AllPages "RelPermalink" $link)) 0 }} {{ end }} {{ if $target }}
- {{ partial "article-link/simple.html" $target }} + {{ $context := dict "target" $target "showSummary" $showSummary "compactSummary" $compactSummary }} + {{ partial "article-link/_shortcode.html" $context }}
{{ end }}