Influx previews are incorrect when backlinks use Markdown Links (with possible solution)
kenlim opened this issue · comments
Describe the bug
When a document uses Markdown Links instead of the default "Shortest path when Possible" WikiLinks, Influx does not render the preview correctly.
To Reproduce
Steps to reproduce the behavior:
- Create a target note called "target"
- Create a referring note called "markdown referral"
- In the note "markdown referral", add the following block of text:
# This is the top heading
This is the first paragraph
# This uses Markdown Links
[Target](./target.md) This will not appear in the Influx preview
- Return to "target.md", and observe the Influx widget.
- Notice that it links to the correct "markdown link" note, but only displays "This is the top heading"
Expected behavior
The Influx widget should link to the correct "markdown link" note, and displays:
# This uses Markdown Links
[Target](./target.md) This will not appear in the Influx preview
Desktop (please complete the following information):
- OS:MacOS
- Version: 11.6.8
- influx version: 2.0.7
- Obsidian version: 1.0.3
Additional context
Influx preview works correctly for "Shortest path when Possible" WikiLinks.
Hey there, I think there is a solution to this. The compareLinkName
method in the apiAdapter.tsx
file doesn't return true when the link is a Markdown link.
with some additional code, you can make it work with Markdown links.
Very quickly, here it is:
compareLinkName(link: LinkCache, basename: string) {
// format link name to be comparable with base names:
const path = link.link;
// grab only the filename from a multi-folder path
const filenameOnly = path.split("/").slice(-1)[0]
// strip any block references from the end and the ".md" extension
const linkname = filenameOnly.split("#^")[0].split(".md")[0]
if (linkname.toLowerCase() === basename.toLowerCase()) {
return true
}
return false
}
markdown links that used to fail and will now work:
- "./target.md"
- "./folder/subfolder/target.md"
- "./target.md#^3e2345"
With this, it works for me on my install:
Implemented. Thanks!