Skip to content

Commit c6a6b9c

Browse files
feat(frontend): support different card uses
1 parent 032d32b commit c6a6b9c

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

helpers/frontend/views/frontend-components.njk

+8
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,14 @@
197197
}]
198198
}) }}
199199

200+
{{ card({
201+
locale: application.locale,
202+
title: "Card",
203+
description: "Description",
204+
published: "2024-12-22",
205+
permalink: "#"
206+
}) }}
207+
200208
<h2><code>cardGrid</code></h2>
201209

202210
{{ cardGrid({

packages/frontend/components/card/styles.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
font: var(--card-title-font, var(--font-subhead));
4949
}
5050

51-
.card__title a {
51+
.card a[rel="bookmark"] {
5252
&::before {
5353
border-radius: var(--border-radius-small);
5454
content: "";

packages/frontend/components/card/template.njk

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@
99
</div>
1010
{% endif %}
1111
<div class="card__body">
12+
{% if opts.title %}
1213
<h{{ headingLevel }} class="card__title">
13-
<a href="{{ opts.url }}">
14+
{% if opts.url and not opts.permalink %}
15+
<a href="{{ opts.url }}" rel="bookmark">
16+
{% endif %}
1417
{{- icon(opts.icon) if opts.icon -}}
1518
{{- opts.title | safe -}}
19+
{% if opts.url and not opts.permalink %}
1620
</a>
21+
{% endif %}
1722
</h{{ headingLevel }}>
23+
{% endif %}
1824
{{ prose({
1925
classes: "card__meta",
2026
text: opts.description | markdown | striptags
@@ -24,9 +30,15 @@
2430
{% for item in opts.badges %}
2531
{{ badge(item) | indent(6) if item }}
2632
{% endfor %}
33+
{% if opts.permalink and not opts.url %}
34+
<a href="{{ opts.permalink }}" rel="bookmark">
35+
{% endif %}
2736
<time datetime="{{ opts.published }}">
2837
{{ opts.published | date("PPp", { locale: opts.locale, timeZone: application.timeZone }) }}
2938
</time>
39+
{% if opts.permalink and not opts.url %}
40+
</a>
41+
{% endif %}
3042
</footer>
3143
{% endif %}
3244
</div>

0 commit comments

Comments
 (0)