-
Couldn't load subscription status.
- Fork 124
feat: add character shortcode #140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| +++ | ||
| title = "Character Shortcodes Example" | ||
| date = "2025-08-11" | ||
| +++ | ||
|
|
||
| Did you know that The oldest programming language still in use is FORTRAN which was created in 1957 by John Backus? | ||
|
|
||
| {{ character(name="hooded", body="Whaaaaaaaaaaaaaaaaaaat, that's almost 70 years ago???") }} | ||
|
|
||
| I know, it's crazy. Here's an example program: | ||
|
|
||
| ``` | ||
| PROGRAM MAIN | ||
| PRINT *, 'HELLO WORLD' | ||
| STOP | ||
| END | ||
| ``` | ||
|
|
||
| {% character(name="hooded") %} | ||
| There's also a more modern version which is a bit easier to read: | ||
| ``` | ||
| program helloWorld | ||
| print *, "Hello World!" | ||
| end program helloWorld | ||
| ``` | ||
| {% end %} | ||
|
|
||
| Good to know, thanks buddy! | ||
|
|
||
| {{ character(body=":)", position="left") }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| .character-note { | ||
| display: flex; | ||
| flex-direction: row; | ||
| margin-block: 1.5rem; | ||
| margin-inline-start: auto; | ||
| margin-inline-end: auto; | ||
|
|
||
| &.character-right { | ||
| flex-direction: row-reverse; | ||
|
|
||
| .character-avatar img { | ||
| transform: scaleX(-1); | ||
| } | ||
| } | ||
|
|
||
| &.character-left { | ||
| flex-direction: row; | ||
| } | ||
|
|
||
| .character-avatar { | ||
| font-size: 2rem; | ||
| align-self: flex-start; | ||
| flex-shrink: 0; | ||
|
|
||
| img { | ||
| --head-size: 3.2em; | ||
| width: var(--head-size); | ||
| height: var(--head-size); | ||
| } | ||
| } | ||
|
|
||
| .character-content { | ||
| font-size: var(--font-size); | ||
| align-self: flex-start; | ||
| max-width: min(93%, 45em); | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .character-bubble { | ||
| --character-bubble-bg: var(--bg-1); | ||
| --character-bubble-border: var(--border-color); | ||
| --character-code-bg: var(--bg-0); | ||
|
|
||
| background: var(--character-bubble-bg); | ||
| border: 1px solid var(--character-bubble-border); | ||
| border-radius: 0.5rem; | ||
| padding-inline: 0.9em; | ||
| padding-block: 0.2em; | ||
| } | ||
|
|
||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| {% set character_name = name | default(value="hooded") %} | ||
| {% set character_text = body | default(value="") %} | ||
| {% set character_type = type | default(value="comment") %} | ||
| {% set character_position = position | default(value="right") %} | ||
| {% set character_image = image | default(value="") %} | ||
|
|
||
| <div class="character-note character-{{ character_name }} character-{{ character_type }} character-{{ character_position }}"> | ||
| <div class="character-avatar"> | ||
| {% if character_image and character_image != "" %} | ||
| <img src="/images/characters/{{ character_image }}" | ||
| alt="{{ character_name }}" | ||
| width="80" | ||
| height="80" /> | ||
| {% elif character_name == "hooded" %} | ||
| <img src="/images/characters/hooded.png" | ||
| alt="hooded" | ||
| width="80" | ||
| height="80" /> | ||
| {% else %} | ||
| {{ character_name }} | ||
| {% endif %} | ||
| </div> | ||
| <div class="character-content"> | ||
| <div class="character-bubble"> | ||
| {% if character_text %} | ||
| {{ character_text | markdown | safe }} | ||
| {% else %} | ||
| {{ body | markdown | safe }} | ||
| {% endif %} | ||
| </div> | ||
| </div> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { test, expect } from '@playwright/test'; | ||
|
|
||
| test.describe('Visual Regression - Character Shortcodes Post', () => { | ||
| test.skip(({ browserName }) => browserName === 'webkit', 'Skip visual tests on Safari mobile due to rendering variability'); | ||
|
|
||
| test('character shortcodes post visual comparison - light theme', async ({ page }) => { | ||
| test.setTimeout(45000); // Timeout for screenshot | ||
|
|
||
| await page.goto('/posts/character-shortcodes'); | ||
| await page.waitForLoadState('domcontentloaded'); | ||
|
|
||
| // Set to light theme | ||
| await page.evaluate(() => { | ||
| document.documentElement.className = 'light'; | ||
| }); | ||
|
|
||
| // Wait for theme class to be applied | ||
| await page.waitForFunction(() => { | ||
| return document.documentElement.className === 'light'; | ||
| }); | ||
|
|
||
| // Wait a moment for CSS to apply | ||
| await page.waitForTimeout(500); | ||
|
|
||
| await expect(page).toHaveScreenshot('character-shortcodes-light.png'); | ||
| }); | ||
|
|
||
| test('character shortcodes post visual comparison - dark theme', async ({ page }) => { | ||
| test.setTimeout(45000); // Timeout for screenshot | ||
|
|
||
| await page.goto('/posts/character-shortcodes'); | ||
| await page.waitForLoadState('domcontentloaded'); | ||
|
|
||
| // Set to dark theme | ||
| await page.evaluate(() => { | ||
| document.documentElement.className = 'dark'; | ||
| }); | ||
|
|
||
| // Wait for theme class to be applied | ||
| await page.waitForFunction(() => { | ||
| return document.documentElement.className === 'dark'; | ||
| }); | ||
|
|
||
| // Wait a moment for CSS to apply | ||
| await page.waitForTimeout(500); | ||
|
|
||
| await expect(page).toHaveScreenshot('character-shortcodes-dark.png'); | ||
| }); | ||
| }); |
3 changes: 3 additions & 0 deletions
3
...odes-visual.spec.ts-snapshots/character-shortcodes-dark-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...hortcodes-visual.spec.ts-snapshots/character-shortcodes-dark-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...des-visual.spec.ts-snapshots/character-shortcodes-light-Mobile-Chrome-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ortcodes-visual.spec.ts-snapshots/character-shortcodes-light-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.