mirror of
https://github.com/zadam/trilium.git
synced 2026-04-14 16:07:42 +02:00
feat(share): render dates on the client side
This commit is contained in:
@@ -47,6 +47,14 @@ document.addEventListener(
|
||||
if (toggleMenuButton && layout) {
|
||||
toggleMenuButton.addEventListener("click", () => layout.classList.toggle("showMenu"));
|
||||
}
|
||||
|
||||
// Format <time> elements using the browser's locale.
|
||||
for (const el of document.querySelectorAll<HTMLTimeElement>("time[datetime]")) {
|
||||
const date = new Date(el.dateTime);
|
||||
if (!isNaN(date.getTime())) {
|
||||
el.textContent = date.toLocaleDateString();
|
||||
}
|
||||
}
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
@@ -196,7 +196,7 @@ content = content.replaceAll(headingRe, (...match) => {
|
||||
<% if (!isEmpty && !isStatic) { %>
|
||||
<div class="updated">
|
||||
<% const lastUpdated = new Date(note.utcDateModified); %>
|
||||
<%- t("share_theme.last-updated", { date: `<time datetime="${lastUpdated.toISOString()}">${lastUpdated.toLocaleDateString()}</time>`}) %>
|
||||
<%- t("share_theme.last-updated", { date: `<time datetime="${lastUpdated.toISOString()}">${lastUpdated.toLocaleDateString("en-US")}</time>`}) %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user