Skip to content

Commit

Permalink
Use window.print()
Browse files Browse the repository at this point in the history
  • Loading branch information
adriaandotcom authored Jun 27, 2024
1 parent 1c77955 commit c9e2cbd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,20 @@ <h1 class="mb-0">{{ page.title }} <a href="https://github.com/simpleanalytics/do

{% if page.download != false %}
<p style="margin-top: 0.5rem;" class="print-button">
<a rel="nofollow" style="font-size: 12px; border-radius: 4px; background-color: #eef9ff; padding: 5px 10px; text-decoration: none;" href="https://simpleanalytics.com/docs-to-pdf?path={{ page.path }}">
<a rel="nofollow" style="font-size: 12px; border-radius: 4px; background-color: #eef9ff; padding: 5px 10px; text-decoration: none;">
<svg style="vertical-align: text-bottom; fill: #098195; margin-right: 5px;" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24"><path d="M15.003 3h2.997v5h-2.997v-5zm8.997 1v20h-24v-24h20l4 4zm-19 5h14v-7h-14v7zm16 4h-18v9h18v-9z"/></svg>
Download PDF
</a>
</p>
<script>
var button = document.querySelector('[class="print-button"] a');
if (button) {
button.addEventListener('click', function(event) {
event.preventDefault();
window.print();
});
}
</script>
{% endif %}

{{ content | replace: '<p><img ', '<img ' | replace: '" /></p>', '" />' | replace: '<img ', '<img loading="lazy" ' }}
Expand Down

0 comments on commit c9e2cbd

Please sign in to comment.