Add support for preview images #2

This commit is contained in:
david-swift 2025-03-11 14:22:03 +01:00
parent 6e2fc7da5c
commit c242520c60
10 changed files with 36 additions and 9 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

View File

@ -4,6 +4,8 @@ title = "Blogs"
description = "Duckling offers the blogs feature borrowed from Duckquill 🦆" description = "Duckling offers the blogs feature borrowed from Duckquill 🦆"
[taxonomies] [taxonomies]
tags = ["Demo", "Test"] tags = ["Demo", "Test"]
[extra]
preview = "duckling.jpg"
+++ +++
Check out the [sample blog](/blog) to see the blogging feature in action! Check out the [sample blog](/blog) to see the blogging feature in action!

View File

@ -5,7 +5,7 @@ description = "No need for a separate documentation page - coming soon!"
[taxonomies] [taxonomies]
tags = ["Demo", "Test"] tags = ["Demo", "Test"]
[extra] [extra]
featured = true preview = "pond.jpg"
+++ +++
This feature is not yet implemented. Coming soon! This feature is not yet implemented. Coming soon!

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 KiB

View File

@ -4,6 +4,8 @@ title = "Subprojects"
description = "Showcase parts of your project!" description = "Showcase parts of your project!"
[taxonomies] [taxonomies]
tags = ["Demo", "Test"] tags = ["Demo", "Test"]
[extra]
preview = "duckling.jpg"
+++ +++
I'm an example for a subproject! I'm an example for a subproject!

View File

@ -2,6 +2,12 @@
flex-direction: column; flex-direction: column;
} }
#article-list {
article {
padding: 1.5rem;
}
}
#article-list, #subproject-list { #article-list, #subproject-list {
display: flex; display: flex;
gap: 1rem; gap: 1rem;
@ -11,11 +17,10 @@
--bg-overlay: var(--accent-color-alpha); --bg-overlay: var(--accent-color-alpha);
position: relative; position: relative;
transition: var(--transition); transition: var(--transition);
border-radius: var(--rounded-corner);
background-position: center; background-position: center;
background-size: cover; background-size: cover;
background-color: var(--fg-contrast-soft); background-color: var(--fg-contrast-soft);
padding: 1.5rem; border-radius: var(--rounded-corner);
overflow: hidden; overflow: hidden;
&:hover { &:hover {

View File

@ -103,7 +103,7 @@ video {
} }
} }
img { img:not(.preview) {
transition: var(--transition-longer); transition: var(--transition-longer);
&:not( &:not(

View File

@ -6,6 +6,19 @@
width: calc(50% - 0.5rem); width: calc(50% - 0.5rem);
min-width: 300px; min-width: 300px;
flex-grow: 1; flex-grow: 1;
img {
margin: 0;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
box-shadow: none;
object-fit: cover;
height: 200px;
width: 100%;
}
#subproject-info {
padding: 1.5rem;
}
} }
} }

View File

@ -24,10 +24,15 @@
{{- article_string -}} {{- article_string -}}
</span> </span>
{%- endif %} {%- endif %}
<h3>{{ page.title }}</h3> {%- if page.extra.preview -%}
{%- if page.description %} <img class="preview" src="{{ current_url ~ page.slug ~ "/" ~ page.extra.preview }}" {% if config.markdown.lazy_async_image %}decoding="async" loading="lazy"{% endif %} />
{{ page.description | markdown | safe }} {%- endif -%}
{%- endif %} <div id="subproject-info">
<h3>{{ page.title }}</h3>
{%- if page.description %}
{{ page.description | markdown | safe }}
{%- endif %}
</div>
</article> </article>
{%- endfor %} {%- endfor %}
</div> </div>