Skip to content

Conversation

mschmidtkorth
Copy link
Contributor

@mschmidtkorth mschmidtkorth commented Jul 2, 2025

Hello, this PR adds a bottom widget (after Linked Mentions) to display page hierarchy, if the current page is part of it. It always shows the immediate parent and any children for easy navigation, with each page being clickable individually.

Note Collapsible is the same as for #1439, breadcrumbs as for #1448

image

@mschmidtkorth mschmidtkorth marked this pull request as draft July 2, 2025 14:33
@mschmidtkorth mschmidtkorth marked this pull request as ready for review July 2, 2025 14:45
@mschmidtkorth
Copy link
Contributor Author

Changed > to / for consistency.


if #hierarchyItems > 0 then
-- HTML instead of Markdown to make it collapsible
local html = "<div class=\"collapsible-hierarchy collapsed\">" ..
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the multiline string syntax be better suited here? [[ ... ]]


// Toggle function for collapsible hierarchy
// @ts-ignore: on purpose
globalThis.sbWidgets.toggleHierarchy = function(header: HTMLElement) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a little misplaced imo. This could just be in the widget code as a script tag, couldn't it?

if (html) {

// Combine HTML from both sources: Markdown and HTML
if (htmlFromHtml || htmlFromMarkdown) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like weird behaviour to me, it's not intuitive.
Imo, if the user decides he wants to export raw html, but still include markdown they should use the markdownToHtml syscall. 90% of the time just concatenating it in a div is not going to be what you want.

@@ -159,3 +159,63 @@ body {
.sb-markdown-toolbar:hover {
opacity: 1;
}

/* Collapsible hierarchy widget styles */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be put into a style tag in the lua. Imo, keeping as much out of SB itself is the main objective

@@ -302,3 +302,9 @@ html[data-theme="dark"] {
--admonition-icon: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"></path><line x1="12" y1="9" x2="12" y2="13"></line><line x1="12" y1="17" x2="12.01" y2="17"></line></svg>');
--admonition-color: #ff9100;
}

/* Chevron icons for collapsible sections */
html {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the other comments

@MrMugame
Copy link
Contributor

MrMugame commented Jul 3, 2025

Added my 2 cents

@zefhemel
Copy link
Collaborator

zefhemel commented Jul 9, 2025

I'm wondering if this should be included in the standard library or if it can just be a script to be shared on community.silverbullet.md. If it gets popular, we can include it in the standard distribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants