Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/Pages/BlogIndexPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use DanielWebsite\Blog\BlogPostStore;
use DanielWebsite\SitemapEntry;
use League\CommonMark\Extension\CommonMark\Node\Block\Heading;
use League\CommonMark\Extension\CommonMark\Node\Inline\Link;
use League\CommonMark\Node\Block\Paragraph;
use League\CommonMark\Node\Query;
use League\CommonMark\Parser\MarkdownParser;
Expand Down Expand Up @@ -42,6 +43,18 @@ protected function build(): void {
foreach ( $posts as $post ) {
$parsedResult = $parser->parse( $post->markdown );

// For any links in the first paragraph of a blog post that are
// relative to the blog post, adjust the paths
$links = ( new Query() )
->where( Query::type( Link::class ) )
->findAll( $parsedResult );
foreach ( $links as $link ) {
$url = $link->getUrl();
if ( str_starts_with( $url, './' ) ) {
$link->setUrl( './Blog/' . substr( $url, 2 ) );
}
}

$firstHeading = ( new Query() )
->where( Query::type( Heading::class ) )
->findOne( $parsedResult );
Expand Down
13 changes: 13 additions & 0 deletions src/Pages/LandingPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use DanielWebsite\Blog\BlogPostStore;
use DanielWebsite\SitemapEntry;
use League\CommonMark\Extension\CommonMark\Node\Block\Heading;
use League\CommonMark\Extension\CommonMark\Node\Inline\Link;
use League\CommonMark\Node\Block\Paragraph;
use League\CommonMark\Node\Query;
use League\CommonMark\Parser\MarkdownParser;
Expand Down Expand Up @@ -126,6 +127,18 @@ protected function build(): void {

$parsedResult = $parser->parse( $latestPost->markdown );

// For any links in the first paragraph of a blog post that are
// relative to the blog post, adjust the paths
$links = ( new Query() )
->where( Query::type( Link::class ) )
->findAll( $parsedResult );
foreach ( $links as $link ) {
$url = $link->getUrl();
if ( str_starts_with( $url, './' ) ) {
$link->setUrl( './Blog/' . substr( $url, 2 ) );
}
}

$firstHeading = ( new Query() )
->where( Query::type( Heading::class ) )
->findOne( $parsedResult );
Expand Down
2 changes: 1 addition & 1 deletion tests/data/Home.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Computer Science and Political Science and graduating <em>magna cum laude</em> in 2024 with a Bachelor of Science degree. As part of my work in Computer
Science, I chose to write an honors thesis in my senior year, see <a href="./Thesis">here</a> for details. I continued at Tufts for graduate school, graduating in 2025 with
a Master of Science in Computer Science degree.</p><p>See the links in the navigation bar above for more information about my
experience.</p><h2 class="subsection-header">Contact</h2><ul><li><a href="https://www.linkedin.com/in/daniel-scherzer-520539263/" target="_blank" class="external-link">LinkedIn</a></li><li>Email: <code>daniel.e.scherzer@gmail.com</code></li></ul><h2 class="subsection-header">Blog</h2><p>I also have a blog. You can see a full index of my posts <a href="/Blog">here</a>. My latest blog post is: </p><div class="blog-preview"><h3>Friends in PHP</h3><span class="blog-preview-date">Monday, 09 March 2026</span><p>As I mentioned in <a href="./20260302-confoo">my last blog post</a>, while at ConFoo I and a few
experience.</p><h2 class="subsection-header">Contact</h2><ul><li><a href="https://www.linkedin.com/in/daniel-scherzer-520539263/" target="_blank" class="external-link">LinkedIn</a></li><li>Email: <code>daniel.e.scherzer@gmail.com</code></li></ul><h2 class="subsection-header">Blog</h2><p>I also have a blog. You can see a full index of my posts <a href="/Blog">here</a>. My latest blog post is: </p><div class="blog-preview"><h3>Friends in PHP</h3><span class="blog-preview-date">Monday, 09 March 2026</span><p>As I mentioned in <a href="./Blog/20260302-confoo">my last blog post</a>, while at ConFoo I and a few
other developers worked on some ideas for adding friendship support to PHP. To
be clear, these are just ideas at the moment, but I figured they were worth
sharing. <a href="/Blog/20260309-php-friends">Continue reading...</a></p></div></div><div class="des-footer"><div class="des-footer--content">Content is © 2026 Daniel Scherzer</div></div></body></html>
2 changes: 1 addition & 1 deletion tests/data/blog-index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en"><head><link rel="icon" href="data:,"><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"><link rel="stylesheet" type="text/css" href="/resources/default-styles.css"><title>Blog index</title><link rel="stylesheet" type="text/css" href="/resources/blog-styles.css"></head><body><div class="des-navbar"><a href="/Home">Home</a><a href="/files/Resume.pdf">Résumé</a><a href="/OpenSource">Open Source</a><a href="/Work">Work</a><strong class="des-strong-page-link">Blog</strong></div><div class="content-wrapper"><h1>Blog index</h1><div class="blog-preview"><h2>Friends in PHP</h2><span class="blog-preview-date">Monday, 09 March 2026</span><p>As I mentioned in <a href="./20260302-confoo">my last blog post</a>, while at ConFoo I and a few
<html lang="en"><head><link rel="icon" href="data:,"><meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1"><link rel="stylesheet" type="text/css" href="/resources/default-styles.css"><title>Blog index</title><link rel="stylesheet" type="text/css" href="/resources/blog-styles.css"></head><body><div class="des-navbar"><a href="/Home">Home</a><a href="/files/Resume.pdf">Résumé</a><a href="/OpenSource">Open Source</a><a href="/Work">Work</a><strong class="des-strong-page-link">Blog</strong></div><div class="content-wrapper"><h1>Blog index</h1><div class="blog-preview"><h2>Friends in PHP</h2><span class="blog-preview-date">Monday, 09 March 2026</span><p>As I mentioned in <a href="./Blog/20260302-confoo">my last blog post</a>, while at ConFoo I and a few
other developers worked on some ideas for adding friendship support to PHP. To
be clear, these are just ideas at the moment, but I figured they were worth
sharing. <a href="/Blog/20260309-php-friends">Continue reading...</a></p></div><div class="blog-preview"><h2>ConFoo 2026</h2><span class="blog-preview-date">Monday, 02 March 2026</span><p>Last week, I was in Montreal for the ConFoo conference, where I gave two talks,
Expand Down