about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--html.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/html.c b/html.c
index e404434..f078b75 100644
--- a/html.c
+++ b/html.c
@@ -30,7 +30,7 @@ static const char *Mailto = {
 static const char *Summary = TEMPLATE(
 	<details class="message" id="[messageID]">
 	<summary>
-		<h1 class="subject"><a href="#[messageID]">[subject]</a></h1>
+		<h1 class="subject"><a href="[fragment]">[subject]</a></h1>
 		<address class="from"><a href="[mailto]">[from]</a></address>
 		<time datetime="[utc]">[date]</time>
 	</summary>
@@ -41,6 +41,12 @@ static const char *Address = TEMPLATE(
 );
 
 int htmlEnvelope(FILE *file, const struct Envelope *envelope) {
+	struct Variable fragmentVars[] = {
+		{ "messageID", envelope->messageID },
+		{0},
+	};
+	char *fragment = templateURL("#[messageID]", fragmentVars);
+
 	struct Variable mailtoVars[] = {
 		{ "mailbox", envelope->replyTo.mailbox },
 		{ "host", envelope->replyTo.host },
@@ -62,6 +68,7 @@ int htmlEnvelope(FILE *file, const struct Envelope *envelope) {
 
 	struct Variable summaryVars[] = {
 		{ "messageID", envelope->messageID },
+		{ "fragment", fragment },
 		{ "subject", envelope->subject },
 		{ "mailto", mailto },
 		{ "from", from },
@@ -70,6 +77,7 @@ int htmlEnvelope(FILE *file, const struct Envelope *envelope) {
 		{0},
 	};
 	int error = templateRender(file, Summary, summaryVars, escapeXML);
+	free(fragment);
 	free(mailto);
 	if (error) return error;