Skip to content

Commit

Permalink
2.3.1 Smarter link references
Browse files Browse the repository at this point in the history
  • Loading branch information
TfT Hacker committed Dec 5, 2024
1 parent 2d8eadd commit ef3455d
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# # 2.3.1
- Change: if a link is the only link in the vault to a destination (thus the reference count is 1), the reference counter will not be shown next to the link, regardless of the minimum threshold count set in settings. This makes sense. If the link is used once, its obvious without the counter, and the counter simply stating the link has one reference was redudant and annoying to many users.

# 2.3.0
- New: Added support for references to show up in the kanban plugin. This can be toggled on and off in settings.
- Changed: SNW's internal index did not include file extensions, which in some cases led to issues. the index now uses the full path with the extension, which means every file whether it is a MD file or not is included in the index.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian42-strange-new-worlds",
"name": "Strange New Worlds",
"version": "2.3.0",
"version": "2.3.1",
"minAppVersion": "1.7.2",
"description": "Help see how your vault is interconnected with visual indicators.",
"author": "TfTHacker",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian42-strange-new-worlds",
"version": "2.3.0",
"version": "2.3.1",
"description": "Revealing networked thought and the strange new worlds created by your vault",
"scripts": {
"dev": "node --no-warnings esbuild.config.mjs",
Expand Down
5 changes: 4 additions & 1 deletion src/view-extensions/gutters-cm6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ const ReferenceGutterExtension = gutter({
for (const embed of embedsFromMetaDataCache) {
if (embed.position.start.line + 1 === lineNumberInFile) {
for (const ref of transformedCache?.embeds ?? []) {
if (ref?.references.length >= plugin.settings.minimumRefCountThreshold && ref?.pos.start.line + 1 === lineNumberInFile) {
if (
ref?.references.length >= Math.max(2, plugin.settings.minimumRefCountThreshold) &&
ref?.pos.start.line + 1 === lineNumberInFile
) {
const lineToAnalyze = editorView.state.doc.lineAt(line.from).text.trim();
if (lineToAnalyze.startsWith("!")) {
// Remove [[ and ]] and split by | to get the link text if aliased
Expand Down
2 changes: 2 additions & 0 deletions src/view-extensions/references-cm6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ const constructWidgetForInlineReference = (
modifyKey = modifyKey.replace(/^\s+|\s+$/g, ""); // should be not leading spaces
}

if (refType === "link" && ref.references.length === 1) continue; // if this is a link and there is only one reference, don't show the widget

if (refType === "embed" || refType === "link") {
// check for aliased references
if (modifyKey.contains("|")) modifyKey = modifyKey.substring(0, key.search(/\|/));
Expand Down
5 changes: 4 additions & 1 deletion src/view-extensions/references-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,10 @@ class snwChildComponentForMarkdownFile extends MarkdownRenderChild {
) || dataHref;

for (const value of transformedCache.links ?? []) {
if (value.references.length >= minRefCountThreshold && value.key.toLocaleUpperCase() === link.toLocaleUpperCase()) {
if (
value.references.length >= Math.max(2, minRefCountThreshold) &&
value.key.toLocaleUpperCase() === link.toLocaleUpperCase()
) {
const referenceElement = htmlDecorationForReferencesElement(
value.references.length,
"link",
Expand Down
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"2.1.5": "1.7.2",
"2.2.0": "1.7.2",
"2.2.1": "1.7.2",
"2.3.0": "1.7.2"
"2.3.0": "1.7.2",
"2.3.1": "1.7.2"
}

0 comments on commit ef3455d

Please sign in to comment.