Skip to content

Commit 31b98ca

Browse files
committed
feat: add character shortcode
1 parent 334733e commit 31b98ca

File tree

5 files changed

+104
-0
lines changed

5 files changed

+104
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
+++
2+
title = "Character Shortcodes Example"
3+
date = "2025-08-11"
4+
+++
5+
6+
Did you know that The oldest programming language still in use is FORTRAN which was created in 1957 by John Backus?
7+
8+
{{ character(name="hooded", body="Whaaaaaaaaaaaaaaaaaaat, that's almost 70 years ago???") }}
9+
10+
I know, it's crazy. Here's an example program:
11+
12+
```FORTRAN
13+
PROGRAM MAIN
14+
PRINT *, 'HELLO WORLD'
15+
STOP
16+
END
17+
```
18+
19+
{% character(name="hooded") %}
20+
There's also a more modern version which is a bit easier to read:
21+
```FORTRAN
22+
program helloWorld
23+
print *, "Hello World!"
24+
end program helloWorld
25+
```
26+
{% end %}
27+
28+
Good to know, thanks buddy!
29+
30+
{{ character(body=":)", position="left") }}

sass/main.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@import "parts/_cards.scss";
2+
@import "parts/_character.scss";
23
@import "parts/_code.scss";
34
@import "parts/_header.scss";
45
@import "parts/_image.scss";

sass/parts/_character.scss

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.character-note {
2+
display: flex;
3+
flex-direction: row;
4+
margin-block: 1.5rem;
5+
margin-inline-start: auto;
6+
margin-inline-end: auto;
7+
8+
&.character-right {
9+
flex-direction: row-reverse;
10+
11+
.character-avatar img {
12+
transform: scaleX(-1);
13+
}
14+
}
15+
16+
.character-avatar {
17+
font-size: 2rem;
18+
align-self: flex-start;
19+
flex-shrink: 0;
20+
21+
img {
22+
--head-size: 3.2em;
23+
width: var(--head-size);
24+
height: var(--head-size);
25+
}
26+
}
27+
28+
29+
.character-content {
30+
font-size: var(--font-size);
31+
align-self: flex-start;
32+
max-width: min(93%, 45em);
33+
overflow: hidden;
34+
}
35+
36+
.character-bubble {
37+
--character-bubble-bg: var(--bg-1);
38+
--character-bubble-border: var(--border-color);
39+
--character-code-bg: var(--bg-0);
40+
41+
background: var(--character-bubble-bg);
42+
border: 1px solid var(--character-bubble-border);
43+
border-radius: 0.5rem;
44+
padding-inline: 0.9em;
45+
padding-block: 0.2em;
46+
}
47+
}
4.9 KB
Loading
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{% set character_name = name | default(value="hooded") %}
2+
{% set character_text = body | default(value="") %}
3+
{% set character_type = type | default(value="comment") %}
4+
{% set character_position = position | default(value="right") %}
5+
{% set character_image = image | default(value="") %}
6+
7+
<div class="character-note character-{{ character_name }} character-{{ character_type }} character-{{ character_position }}">
8+
<div class="character-avatar">
9+
{% if character_image %}
10+
<img src="/images/character/{{ character_image }}" alt="{{ character_name }}">
11+
{% elif character_name == "hooded" %}
12+
<img src="/images/characters/hooded.png" alt="hooded">
13+
{% else %}
14+
{{ character_name }}
15+
{% endif %}
16+
</div>
17+
<div class="character-content">
18+
<div class="character-bubble">
19+
{% if character_text %}
20+
{{ character_text | markdown | safe }}
21+
{% else %}
22+
{{ body | markdown | safe }}
23+
{% endif %}
24+
</div>
25+
</div>
26+
</div>

0 commit comments

Comments
 (0)