Skip to content

Commit 711bb2a

Browse files
Further email md fix
1 parent dbd6ea7 commit 711bb2a

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/diary/index.njk

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -228,26 +228,17 @@ but the content is a concise documentary/logbook about the site.
228228
// Download (more robust for iOS/Safari with setTimeout)
229229
if (dlBtn) dlBtn.addEventListener('click', function(){ var date=(dInput.value||todayStr()).slice(0,10); var filename=date+'-'+slugify(tInput.value)+'.md'; var md=buildMarkdown(tInput.value,dInput.value,bInput.value); var blob=new Blob([md],{type:'text/markdown'}); var url=URL.createObjectURL(blob); var a=document.createElement('a'); a.href=url; a.download=filename; document.body.appendChild(a); setTimeout(function(){ a.click(); setTimeout(function(){ URL.revokeObjectURL(url); document.body.removeChild(a); }, 500); }, 0); });
230230
231-
// Email .md (Web Share API with file when supported, fallback to mailto)
232-
if (emailBtn) emailBtn.addEventListener('click', async function(){
231+
// Email .md (simple mailto with Markdown in subject/body)
232+
if (emailBtn) emailBtn.addEventListener('click', function(){
233233
try {
234234
var date=(dInput.value||todayStr()).slice(0,10);
235-
var filename=date+'-'+slugify(tInput.value)+'.md';
236235
var md=buildMarkdown(tInput.value,dInput.value,bInput.value);
237-
var subject = '[Diary] ' + (tInput.value||'Untitled') + ' ('+date+')';
238-
// Try Web Share API with file attachment
239-
if (window.File && navigator.canShare) {
240-
var file = new File([md], filename, { type: 'text/markdown' });
241-
if (navigator.canShare({ files: [file] })) {
242-
await navigator.share({ title: subject, text: 'Markdown entry attached.', files: [file] });
243-
statusEl.textContent = 'Shared via your OS share sheet.';
244-
return;
245-
}
246-
}
247-
// Fallback: open mailto with content in body (attachments not possible via mailto)
236+
var rawSubject = '[Diary] ' + (tInput.value||'Untitled') + ' ('+date+')';
237+
// Keep subject reasonably short
238+
var subject = rawSubject.slice(0, 140);
248239
var mailto = 'mailto:robmcd@me.com?subject='+encodeURIComponent(subject)+'&body='+encodeURIComponent(md);
249240
window.location.href = mailto;
250-
statusEl.textContent = 'Opened email client with Markdown in the message body. Attach the .md if needed (or use Download first).';
241+
statusEl.textContent = 'Opened email client with Markdown in the message body.';
251242
} catch (e) {
252243
console.error(e);
253244
statusEl.textContent = 'Email action failed: ' + (e && e.message || e);

0 commit comments

Comments
 (0)