Skip to content

Commit b1afe29

Browse files
committed
Desing improvements
1 parent e54f628 commit b1afe29

6 files changed

Lines changed: 40 additions & 12 deletions

File tree

_config/filters.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export default function(eleventyConfig) {
7373
);
7474

7575
eleventyConfig.addFilter("contentImgUrlShortcode", contentImgUrlShortcode);
76+
77+
eleventyConfig.addFilter("pathRelative", pathRelative);
7678
};
7779

7880
// Taken from here => https://keepinguptodate.com/pages/2019/06/creating-blog-with-eleventy/
@@ -89,6 +91,10 @@ function extractExcerpt(article) {
8991
return striptags(content.slice(0, content.indexOf("\n")));
9092
}
9193

94+
function pathRelative(to) {
95+
return path.relative(path.dirname(this.page.inputPath), to)
96+
}
97+
9298
async function contentImgUrlShortcode(src, options = {}) {
9399
const inputDir = path.dirname(this.page.inputPath);
94100
const imagePath = path.resolve(inputDir, src);

_includes/layouts/post.njk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ article {
2323
text-align: right;
2424
}
2525

26-
.post-header {
27-
28-
}
29-
3026
h1.post-title {
3127
margin-top: 1rem;
3228
margin-bottom: 1rem;

_includes/partials/aside.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
{% endcss %}
2727

2828
<div class="recents-container aside-content">
29-
<span>Recents</span>
29+
<span><b>Recents</b></span>
3030
<div>
3131
<nav>
3232
<ol>
@@ -43,7 +43,7 @@
4343
{% set outline = content | toc %}
4444
{% if outline %}
4545
<div class="toc-container aside-content">
46-
<span>Table of Contents</span>
46+
<span><b>Table of Contents</b></span>
4747
<div>
4848
{{ outline | safe }}
4949
</div>

_includes/partials/post-card.njk

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
display: flex;
55
flex-direction: column;
66
gap: 1rem;
7-
margin-bottom: 2rem;
7+
padding: 8px;
8+
margin-bottom: 1rem;
9+
background-color: var(--bg-color-secondary);
10+
box-shadow: 2px 2px 4px var(--shadow-color);
811
}
912

1013
.post-card h2 {
@@ -14,7 +17,17 @@
1417
{% endcss %}
1518

1619
<div class="post-card">
17-
<h2><a href="{{ post.url }}">{% if post.data.title %}{{ post.data.title }}{% else %}<code>{{ post.url }}</code>{% endif %}</a></h2>
20+
21+
<h2><a href="{{ post.url }}">
22+
{%- if post.data.imagePath %}
23+
<img src="{{ post.data.imagePath | pathRelative | safe }}" alt="{{ post.data.title }}" class="post-card-image" />
24+
{% endif %}
25+
26+
{% if post.data.title %}{{ post.data.title }}{% else %}<code>{{ post.url }}</code>{% endif %}
27+
</a></h2>
28+
1829
<div class="excerpt"><em>{{ post | excerpt | truncate(500) }}</em></div>
30+
1931
{% include "./post-meta.njk" %}
32+
2033
</div>

eleventy.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import markdownIt from "markdown-it";
88
import markdownItAnchor from "markdown-it-anchor";
99
import pluginTOC from "@uncenter/eleventy-plugin-toc";
1010
import faviconsPlugin from "eleventy-plugin-gen-favicons";
11+
import path from 'node:path';
1112

1213
import pluginFilters from "./_config/filters.js";
1314
import pluginShortcodes from "./_config/shortcodes.js";
@@ -49,6 +50,13 @@ export default async function(eleventyConfig) {
4950
return `/${year}${name}`;
5051
}
5152
return data.permalink; // Use the explicitly set permalink if available
53+
},
54+
imagePath: data => {
55+
if(!data.image) {
56+
return;
57+
}
58+
59+
return path.resolve(path.dirname(data.page.inputPath), data.image);
5260
}
5361
});
5462

@@ -103,7 +111,7 @@ export default async function(eleventyConfig) {
103111
extensions: "html",
104112

105113
// Output formats for each image.
106-
formats: ["avif", "webp", "auto"],
114+
formats: ["png", "avif", "webp", "auto"],
107115

108116
// widths: ["auto"],
109117

public/css/index.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,22 @@ p:last-child {
8787
margin-bottom: 0;
8888
}
8989

90-
a[href] {
90+
a {
9191
color: var(--link-color);
9292
text-decoration: none;
9393
}
94-
a[href]:hover,
95-
a[href]:active {
94+
a:hover,
95+
a:active {
9696
color: var(--link-color-hover);
9797
text-decoration: underline;
9898
transition: color 0.3s;
9999
}
100100

101+
a.ha {
102+
text-decoration: none;
103+
margin-top: -2px;
104+
}
105+
101106
h1, h2, h3, h4, h5, h6 {
102107
color: var(--heading-color);
103108
transition: color 0.3s;

0 commit comments

Comments
 (0)