From 1bc9cac8f96e9a353680bd5ae07d385442936a53 Mon Sep 17 00:00:00 2001 From: Nathan George Date: Fri, 2 Feb 2024 03:03:56 -0500 Subject: [PATCH] handle fail cases, fix content width, hide empty sidebars, 1.8.0-6b --- assets/deferred.txt.css | 7 ++++++- assets/deferred.txt.js | 18 +++++++++++++----- assets/plugin-styles.txt.css | 5 +++-- manifest-beta.json | 2 +- manifest.json | 2 +- .../assets/global-variable-styles.ts | 6 +++--- scripts/objects/website-index.ts | 11 ++++++++++- 7 files changed, 37 insertions(+), 14 deletions(-) diff --git a/assets/deferred.txt.css b/assets/deferred.txt.css index 539b381..4ebaddb 100644 --- a/assets/deferred.txt.css +++ b/assets/deferred.txt.css @@ -93,6 +93,12 @@ body.floating-sidebars .sidebar { border-bottom-left-radius: var(--radius-l); } +/* Hide empty sidebars */ +.sidebar:has(.sidebar-content:empty) +{ + display: none; +} + .sidebar-topbar { height: 2em; width: var(--sidebar-width); @@ -166,7 +172,6 @@ body.floating-sidebars .sidebar { height: 100%; } - .sidebar-section-header { margin: 0 0 1em 0; diff --git a/assets/deferred.txt.js b/assets/deferred.txt.js index 3a198ea..1490579 100644 --- a/assets/deferred.txt.js +++ b/assets/deferred.txt.js @@ -11,15 +11,23 @@ async function loadIncludes() let includeTag = includeTags[i]; let includePath = includeTag.getAttribute("src"); - const request = await fetch(includePath); - if (!request.ok) + try + { + const request = await fetch(includePath); + if (!request.ok) + { + console.log("Could not include file: " + includePath); + continue; + } + + let includeText = await request.text(); + includeTag.outerHTML = includeText; + } + catch (e) { console.log("Could not include file: " + includePath); continue; } - - let includeText = await request.text(); - includeTag.outerHTML = includeText; } } else diff --git a/assets/plugin-styles.txt.css b/assets/plugin-styles.txt.css index 2ebc312..86ce72e 100644 --- a/assets/plugin-styles.txt.css +++ b/assets/plugin-styles.txt.css @@ -371,7 +371,8 @@ body .webpage-container .tree-container .tree-scroll-area { transition: height ease-in-out, margin-bottom ease-in-out; transition-duration: 0.2s; - display: inline; + display: flex; + flex-direction: column; position: relative; } @@ -387,7 +388,7 @@ html > body > .webpage-container > .document-container > .markdown-preview-view .markdown-rendered .heading-wrapper:has(> .heading-children > div:last-child > :is(p,pre,table,ul,ol)) + .heading-wrapper > .heading:first-child { - margin-top: var(--heading-spacing); + margin-top: var(--heading-spacing) !important; } .heading-children diff --git a/manifest-beta.json b/manifest-beta.json index 1263f5f..a98c55c 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "webpage-html-export", "name": "Webpage HTML Export", - "version": "1.8.0-5b", + "version": "1.8.0-6b", "minAppVersion": "1.4.0", "description": "Export full websites or html documents from single files, canvas pages, or whole vaults. Similar to obsidian's publish or digital garden, but with direct access to the exported HTML. Focuses on flexibility, features, and style parity.", "author": "Nathan George", diff --git a/manifest.json b/manifest.json index 9f0b1e9..aea5db8 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "webpage-html-export", "name": "Webpage HTML Export", - "version": "1.8.0-5b", + "version": "1.8.0-6b", "minAppVersion": "1.4.0", "description": "Export html from single files, canvas pages, or whole vaults. Direct access to the exported HTML files allows you to publish your digital garden anywhere. Focuses on flexibility, features, and style parity.", "author": "Nathan George", diff --git a/scripts/html-generation/assets/global-variable-styles.ts b/scripts/html-generation/assets/global-variable-styles.ts index 4b01014..1f9b42a 100644 --- a/scripts/html-generation/assets/global-variable-styles.ts +++ b/scripts/html-generation/assets/global-variable-styles.ts @@ -20,11 +20,11 @@ export class GlobalVariableStyles extends Asset if (!isNaN(Number(contentWidth))) contentWidth += "px"; if (!isNaN(Number(sidebarWidth))) sidebarWidth += "px"; - let lineWidthCss = `min(${lineWidth}, calc(100vw - 2em)`; - let contentWidthCss = `min(${contentWidth}, calc(100vw - 2em)`; + let lineWidthCss = `min(${lineWidth}, calc(100vw - 2em))`; + let contentWidthCss = `min(${contentWidth}, calc(100vw - 2em))`; this.content = ` - html body + :root body { --line-width: ${lineWidthCss}; --line-width-adaptive: ${lineWidthCss}; diff --git a/scripts/objects/website-index.ts b/scripts/objects/website-index.ts index 1ee0b50..6fe6574 100644 --- a/scripts/objects/website-index.ts +++ b/scripts/objects/website-index.ts @@ -71,7 +71,16 @@ export class WebsiteIndex { let metadataPath = this.web.destination.join(Asset.libraryPath).joinString("metadata.json"); let metadata = await metadataPath.readFileString(); - if (metadata) return JSON.parse(metadata); + + try + { + if (metadata) return JSON.parse(metadata); + } + catch (e) + { + RenderLog.error(e, "Failed to parse metadata.json. Exporting all files."); + } + return undefined; }