Skip to content

Commit

Permalink
refactor(feed): improve content rendering in FeedCommand
Browse files Browse the repository at this point in the history
- Refactored the content rendering logic in the FeedCommand
- Used htmlspecialchars function to handle special characters in content
  • Loading branch information
guanguans committed Apr 11, 2024
1 parent 16cb0ba commit c029f3b
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions app/Commands/FeedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,17 @@ static function (Collection $carry, string $line) use (&$date): Collection {
'date' => Date::createFromTimestamp(strtotime((string) $date)),
'title' => $title = (string) $line->match('/\[.*\]/')->trim('[]'),
'link' => $link = (string) $line->match('/\(.*\)/')->trim('()'),
'content' => <<<HTML
<blockquote>
<p><a href="$link" target="_blank">$title</a></p>
</blockquote>
<ul>
<li><a href="$link" target="_blank">$link</a></li>
<li><a href="https://github.com/guanguans/favorite-link" target="_blank">https://github.com/guanguans/favorite-link</a></li>
</ul>
HTML,
'content' => htmlspecialchars(
<<<HTML
<blockquote>
<p><a href="$link" target="_blank">$title</a></p>
</blockquote>
<ul>
<li><a href="$link" target="_blank">$link</a></li>
<li><a href="https://github.com/guanguans/favorite-link" target="_blank">https://github.com/guanguans/favorite-link</a></li>
</ul>
HTML
),
]);
},
collect()
Expand Down

0 comments on commit c029f3b

Please sign in to comment.