[PR #7157] feat: Add shareHtml relation for custom HTML snippets in shared pages #4678

Open
opened 2025-10-01 16:39:51 -05:00 by giteasync · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/TriliumNext/Trilium/pull/7157
Author: @kleutzinger
Created: 9/30/2025
Status: 🔄 Open

Base: mainHead: kev/share-html


📝 Commits (4)

  • d483b6e add shareHTML relation
  • 0a25d4d shareHTML to shareHtml
  • 888d0d1 add docs about shareHtml and shareHtmlLocation
  • b885156 docs: clarify shareHtmlLocation goes on snippet note

📊 Changes

4 files changed (+52 additions, -4 deletions)

View changed files

📝 apps/server/src/services/builtin_attributes.ts (+2 -0)
📝 docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md (+1 -0)
📝 docs/User Guide/User Guide/Advanced Usage/Sharing.md (+18 -1)
📝 packages/share-theme/src/templates/page.ejs (+31 -3)

📄 Description

closes https://github.com/TriliumNext/Trilium/issues/7156

Summary

Adds support for injecting custom HTML snippets into shared pages using the ~shareHTML relation, similar to existing ~shareJs and ~shareCss relations.

Usage

Add ~shareHTML=@snippetNote relation to your shared page. Optionally add #shareHTMLLocation=<location>[:<position>] label to the snippet note to control placement:

Locations: head, body, content (default)
Positions: :start, :end (default)

Examples:

  • #shareHTMLLocation=head → end of <head>
  • #shareHTMLLocation=body:start → start of <body>
  • No label → defaults to content:end

Multiple ~shareHTML relations are supported.

Changes

  • Added ~shareHTML relation and #shareHTMLLocation label to builtin_attributes.ts
  • Modified page.ejs template to collect and inject HTML snippets at specified locations

Use Cases

Analytics scripts, custom meta tags, comment systems, custom widgets, headers/footers.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/TriliumNext/Trilium/pull/7157 **Author:** [@kleutzinger](https://github.com/kleutzinger) **Created:** 9/30/2025 **Status:** 🔄 Open **Base:** `main` ← **Head:** `kev/share-html` --- ### 📝 Commits (4) - [`d483b6e`](https://github.com/TriliumNext/Trilium/commit/d483b6e8401cea9659b2388f5746b9a0e22b2a15) add shareHTML relation - [`0a25d4d`](https://github.com/TriliumNext/Trilium/commit/0a25d4db0d5be2a50ef510549c6f8479f250fb9f) shareHTML to shareHtml - [`888d0d1`](https://github.com/TriliumNext/Trilium/commit/888d0d10846d55c44c6b3f438f774303db53cfd1) add docs about shareHtml and shareHtmlLocation - [`b885156`](https://github.com/TriliumNext/Trilium/commit/b8851565ebcba216d5dc025a513edda9242e73ca) docs: clarify shareHtmlLocation goes on snippet note ### 📊 Changes **4 files changed** (+52 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `apps/server/src/services/builtin_attributes.ts` (+2 -0) 📝 `docs/User Guide/User Guide/Advanced Usage/Attributes/Relations.md` (+1 -0) 📝 `docs/User Guide/User Guide/Advanced Usage/Sharing.md` (+18 -1) 📝 `packages/share-theme/src/templates/page.ejs` (+31 -3) </details> ### 📄 Description closes https://github.com/TriliumNext/Trilium/issues/7156 ## Summary Adds support for injecting custom HTML snippets into shared pages using the `~shareHTML` relation, similar to existing `~shareJs` and `~shareCss` relations. ## Usage Add `~shareHTML=@snippetNote` relation to your shared page. Optionally add `#shareHTMLLocation=<location>[:<position>]` label to the snippet note to control placement: **Locations:** `head`, `body`, `content` (default) **Positions:** `:start`, `:end` (default) **Examples:** - `#shareHTMLLocation=head` → end of `<head>` - `#shareHTMLLocation=body:start` → start of `<body>` - No label → defaults to `content:end` Multiple `~shareHTML` relations are supported. ## Changes - Added `~shareHTML` relation and `#shareHTMLLocation` label to `builtin_attributes.ts` - Modified `page.ejs` template to collect and inject HTML snippets at specified locations ## Use Cases Analytics scripts, custom meta tags, comment systems, custom widgets, headers/footers. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
giteasync added the
pull-request
label 2025-10-01 16:39:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TriliumNext/Trilium#4678
No description provided.