Skip to content

Commit

Permalink
Render svg images from markdown (#43)
Browse files Browse the repository at this point in the history
* Feature: allow svgs from markdown to be rendered

* Feature: add example for render image type svg
  • Loading branch information
ThomasBoom89 authored May 25, 2024
1 parent 8e78440 commit e049463
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions exampleSite/content/post/image-process/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ image = "images/hugo-logo-wide.svg"

![placeholder](https://placeholder.co/1024x768/png "Test for external image")

![svg](./images/hugo-logo-wide.svg "Test for svg")

<p align="center" width="100%">
<img src="./images/logo.png">
</p>
6 changes: 6 additions & 0 deletions exampleSite/content/post/image-process/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@ image = "images/hugo-logo-wide.svg"
![Photo by Behnam Norouzi on Unsplash](./images/behnam-norouzi-_1ok63FFlM4-unsplash.jpg "Photo by Behnam Norouzi on Unsplash")

![placeholder](https://placeholder.co/1024x768/png "Test for external image")

![svg](./images/hugo-logo-wide.svg "Test for svg")

<p align="center" width="100%">
<img src="./images/logo.png">
</p>
2 changes: 1 addition & 1 deletion layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="not-prose">
<!-- check if it exists as a page resource -->
{{- with .Page.Resources.Get $dest -}}
{{- with and (ne (.Page.Resources.Get $dest).MediaType.SubType "svg") (.Page.Resources.Get $dest) -}}
{{- $src := . -}}
{{- $dataSzes := "(min-width: 1024px) 100vw, 50vw" -}}
{{- $actualImg := $src.Resize (print "640x jpg " $filter) -}}
Expand Down

0 comments on commit e049463

Please sign in to comment.