Skip to content

Commit c1b3c37

Browse files
committed
feat: Open project links in new tab
* Create custom cards.html template to override theme default * Add target="_blank" and rel="noopener" to project links
1 parent 73de988 commit c1b3c37

File tree

1 file changed

+102
-0
lines changed

1 file changed

+102
-0
lines changed

templates/cards.html

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{% extends "base.html" %}
2+
3+
4+
{% macro cards_posts(pages) %}
5+
<div class="cards">
6+
{%- for page in pages %}
7+
<div class="card">
8+
<div class="card-media">
9+
{# New wrapper div for consistent media sizing #}
10+
{% if page.extra.local_image %}
11+
{% set path = page.extra.local_image %}
12+
{% if path is not starting_with("/") %}
13+
{% set path = section.path ~ "/" ~ page.extra.local_image %}
14+
{% endif %}
15+
16+
{% set image = resize_image(path=path, height=300, op="fit_height", format="webp") %}
17+
<img class="card-image"
18+
alt="{{ page.extra.local_image }}"
19+
src="{{ image.url }}" />
20+
{% elif page.extra.remote_image %}
21+
<img class="card-image"
22+
alt="{{ page.extra.remote_image }}"
23+
src="{{ page.extra.remote_image }}" />
24+
{% elif page.extra.local_video %}
25+
{% set video_path = page.extra.local_video %}
26+
{% if video_path is not starting_with("/") %}
27+
{% set video_path = section.path ~ "/" ~ page.extra.local_video %}
28+
{% endif %}
29+
<video class="card-video" controls autoplay loop muted>
30+
<source src="{{ video_path | safe }}">
31+
Your browser does not support the video tag.
32+
</video>
33+
{% elif page.extra.remote_video %}
34+
<video class="card-video" controls autoplay loop muted>
35+
<source src="{{ page.extra.remote_video | safe }}">
36+
Your browser does not support the video tag.
37+
</video>
38+
{% else %}
39+
<div class="card-image-placeholder"></div>
40+
{% endif %}
41+
</div>
42+
{# End of card-media wrapper #}
43+
44+
<div class="card-info">
45+
<h1 class="card-title">
46+
{% if page.extra.link_to %}
47+
<a href={{ page.extra.link_to }} target="_blank" rel="noopener">{{ page.title }}</a>
48+
{% else %}
49+
<a href={{ page.permalink | safe }}>{{ page.title }}</a>
50+
{% endif %}
51+
</h1>
52+
53+
<div class="meta">
54+
{%- if page.date %}
55+
<time>{{ page.date | date(format="%Y-%m-%d") }}</time>
56+
{% endif -%}
57+
{% if page.draft %}<span class="draft-label">DRAFT</span>{% endif %}
58+
</div>
59+
60+
<div class="card-description">
61+
{% if page.description %}{{ page.description }}{% endif %}
62+
</div>
63+
</div>
64+
</div>
65+
66+
{% endfor -%}
67+
</div>
68+
{% endmacro cards_posts %}
69+
70+
{% block main_content %}
71+
{% if section.extra.section_path -%}
72+
{% set section = get_section(path=section.extra.section_path) %}
73+
{% endif -%}
74+
75+
{{ post_macros::page_header(title=section.title) }}
76+
77+
<main>
78+
{%- if paginator %}
79+
{%- set show_pages = paginator.pages -%}
80+
{% else %}
81+
{%- set show_pages = section.pages -%}
82+
{% endif -%}
83+
84+
{{ self::cards_posts(pages=show_pages) }}
85+
</main>
86+
87+
{% if paginator %}
88+
<ul class="pagination">
89+
{% if paginator.previous %}
90+
<span class="page-item page-prev">
91+
<a href={{ paginator.previous }} class="page-link" aria-label="Previous"><span aria-hidden="true">← Prev</span></a>
92+
</span>
93+
{% endif %}
94+
95+
{% if paginator.next %}
96+
<span class="page-item page-next">
97+
<a href={{ paginator.next }} class="page-link" aria-label="Next"><span aria-hidden="true">Next →</span></a>
98+
</span>
99+
{% endif %}
100+
</ul>
101+
{% endif %}
102+
{% endblock main_content %}

0 commit comments

Comments
 (0)