shortWikiLinks config option

This commit is contained in:
Zef Hemel
2026-01-22 08:42:30 +01:00
parent a89ab96438
commit fb10fd65b8
7 changed files with 20 additions and 3 deletions
+2
View File
@@ -20,6 +20,7 @@ export function frontmatterPlugin(client: Client) {
(state: EditorState) => {
const widgets: any[] = [];
const foldRanges = foldedRanges(state);
const shortWikiLinks = client.config.get("shortWikiLinks", true);
syntaxTree(state).iterate({
enter(node) {
@@ -136,6 +137,7 @@ export function frontmatterPlugin(client: Client) {
matchFrom: mFrom,
matchTo: mTo,
client,
shortWikiLinks,
state,
callback: (e, ref) => {
if (e.altKey) {
+1
View File
@@ -190,6 +190,7 @@ export class LuaWidget extends WidgetType {
);
html = parseHtmlString(renderMarkdownToHtml(mdTree, {
shortWikiLinks: this.client.config.get("shortWikiLinks", false),
translateUrls: (url) => {
if (isLocalURL(url)) {
url = resolveMarkdownLink(
+1
View File
@@ -63,6 +63,7 @@ class TableViewWidget extends WidgetType {
// Annotate every element with its position so we can use it to put
// the cursor there when the user clicks on the table.
annotationPositions: true,
shortWikiLinks: this.client.config.get("shortWikiLinks", false),
translateUrls: (url) => {
if (isLocalURL(url)) {
url = resolveMarkdownLink(
+4 -1
View File
@@ -28,6 +28,7 @@ export interface WikiLinkProcessorOptions {
matchTo: number;
client: Client;
state: EditorState;
shortWikiLinks: boolean;
callback: (e: MouseEvent, ref: any) => void;
}
@@ -95,7 +96,9 @@ export function processWikiLink(options: WikiLinkProcessorOptions): any[] {
// We don't want to render the meta
renderedRef.meta = false;
// We also don't want to rendered the prefix of the path
renderedRef.path = fileName(renderedRef.path);
renderedRef.path = options.shortWikiLinks
? fileName(renderedRef.path)
: renderedRef.path;
const prefix = (ref.details?.type === "position" ||
ref.details?.type === "linecolumn")
+4 -1
View File
@@ -25,6 +25,7 @@ export type MarkdownRenderOptions = {
smartHardBreak?: true;
annotationPositions?: true;
preserveAttributes?: true;
shortWikiLinks?: boolean;
// When defined, use to inline images as data: urls
translateUrls?: (url: string, type: "link" | "image") => string;
expand?: true;
@@ -296,7 +297,9 @@ function render(
// Custom stuff
case "WikiLink": {
const link = findNodeOfType(t, "WikiLinkPage")!.children![0].text!;
let linkText = link.split("/").pop()!;
let linkText = options.shortWikiLinks === true
? link.split("/").pop()!
: link;
const aliasNode = findNodeOfType(t, "WikiLinkAlias");
if (aliasNode) {
linkText = aliasNode.children![0].text!;
+6
View File
@@ -81,6 +81,11 @@ config.define("autoCloseBrackets", {
type = "string",
})
config.define("shortWikiLinks", {
description = "Render wiki links to just the last segment, e.g. Person/John becomes John",
type = "boolean"
})
config.define("emoji", {
description = "Additional emoji aliases",
type = "object",
@@ -372,6 +377,7 @@ config.set {
task = { all = true },
},
taskStates = {},
shortWikiLinks = true,
actionButtons = {
{
icon = "home",
+2 -1
View File
@@ -3,6 +3,7 @@ An attempt at documenting the changes/new features introduced in each release.
## Edge
Whenever a commit is pushed to the `main` branch, within ~10 minutes, it will be released as a docker image with the `:v2` tag, and a binary in the [edge release](https://github.com/silverbulletmd/silverbullet/releases/tag/edge). If you want to live on the bleeding edge of SilverBullet goodness (or regression) this is where to do it.
* New `shortWikiLinks` config (defaulting to `true`) that decides whether a wiki link should be rendered in its short form (rendering just the last segment, e.g. `Person/John` would show as `John`). To always render the full name, put `config.set("shortWikiLinks", false)` in your [[CONFIG]].
* Upgraded dependencies, specifically CodeMirror. CodeMirror now no longer allows `Alt-<letter>` and `Alt-<special-character>` [[Keyboard Shortcuts]], meaning I had to remap a few existing ones. It’s basically a mission impossible to pick great ones, but I tried:
* `Quick note` is now bound to both `Ctrl-q q` (type `Ctrl-q` first, then hit `q` again) and `Ctrl-q Ctrl-q` (hit `Ctrl-q` twice)
* `Navigate: Home` is now bound to `Ctrl-g h`
@@ -19,7 +20,7 @@ Whenever a commit is pushed to the `main` branch, within ~10 minutes, it will be
* `Page: Rename Linked Page` keyboard shortcut removed
* `Sync: Space` keyboard shortcut removed
* As documented in [[Keyboard Shortcuts]], it is now possible to specify _multiple_ keyboard shortcuts to a commands.
* Linked Mentions now list full page path rather than abbreviated version
* Linked Mentions now list full page path rather than abbreviated version.
## 2.4.0
* Indexer rework (note: upgrading will start a full space reindex automatically):