added base element to handle external links in exports, #1289

This commit is contained in:
zadam 2020-10-06 21:30:41 +02:00
parent 32d609e796
commit 287ef9b522

View File

@ -226,11 +226,13 @@ function exportToZip(taskContext, branch, format, res) {
if (!content.substr(0, 100).toLowerCase().includes("<html")) {
const cssUrl = "../".repeat(noteMeta.notePath.length - 1) + 'style.css';
// <base> element will make sure external links are openable - https://github.com/zadam/trilium/issues/1289#issuecomment-704066809
content = `<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="${cssUrl}">
<base target="_parent">
</head>
<body>
<h1>${utils.escapeHtml(title)}</h1>