nycki.net/content/_includes/post.njk
nycki 8a31e8775e
All checks were successful
/ build (push) Successful in 40s
email form
2026-11-28 13:45:07 -08:00

84 lines
2.6 KiB
Text

---
layout: base.njk
---
{# Only include the syntax highlighter CSS on blog posts #}
{%- css %}{% include "node_modules/prismjs/themes/prism-okaidia.css" %}{% endcss %}
<article>
{{ content | safe }}
</article>
<ul class="post-metadata">
<li><time datetime="{{ page.date | htmlDateString }}">{{ page.date | readableDate }}</time></li>
</ul>
{%- for tag in tags | filterTagList %}
{%- set tagUrl %}/blog/tags/{{ tag | slugify }}/{% endset %}
<a href="{{ tagUrl }}" class="post-tag">{{ tag }}</a>{%- if not loop.last %}, {% endif %}
{%- endfor %}
{%- if collections.posts %}
{%- set previousPost = collections.posts | getPreviousCollectionItem %}
{%- set nextPost = collections.posts | getNextCollectionItem %}
{%- if nextPost or previousPost %}
<ul class="links-nextprev">
{%- if previousPost %}<li>Previous: <a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a></li>{% endif %}
{%- if nextPost %}<li>Next: <a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a></li>{% endif %}
</ul>
{%- endif %}
{%- endif %}
<p>Comments? Write me an email! Be sure to let me know if you want it posted publically.</p>
<noscript>
<a href="mailto:nupanick@gmail.com">Click Here To Email Nycki</a>
</noscript>
<div hidden class="comment-form">
<textarea></textarea>
<p><a href="" id="send">Send it!</a> Link opens in your default email application.</p>
</div>
<style>
.comment-form textarea {
width: 100%;
height: 10lh;
margin: 1ch;
}
</style>
<script>
const commentForm = document.querySelector('.comment-form');
commentForm.hidden = false;
const comment = document.querySelector('.comment-form textarea');
const send = document.querySelector('.comment-form #send');
const name = 'nupanick';
const domain = 'gmail.com';
const subject = `RE: ${document.title}`;
function updateEmailLink() {
let value = comment.value;
// escape things in the comment that look like part of a query string.
value = value.replace('%', '%25');
value = value.replace('&', '%26');
send.href = `mailto:${name}@${domain}?subject=${subject}&body=${value}`;
}
updateEmailLink();
// update the link whenever it changes, so desktop users can preview on hover.
// you can remove this line if you don't need link previews.
comment.addEventListener('change', updateEmailLink);
// update the link again right before sending.
send.addEventListener('click', (ev) => {
updateEmailLink();
window.open(send.href);
return false;
});
</script>
{#
{%- if process.env.NODE_ENV == 'localhost' %}
<script defer src="https://xnil.io/comentario/comentario.js"></script>
<comentario-comments theme="dark"></comentario-comments>
{%- endif %}
#}