rishikanthc / markopolis

Markdown Programmable Interface
https://markopolis.app
MIT License
156 stars 2 forks source link

Issue with Links in subfolders #8

Closed cromelex closed 2 months ago

cromelex commented 2 months ago

Seeing an issue with links for pages in subfolders.

Where I have:

home.md
/folder A
        page1.md
        page2.md

in home.md I have a link as [[page1]] and another one as [[page2]]

Markopolis is making page1 and page2 available under domain.tld/folder A/page 1 and domain.tld/folder A/page 2, but the links are directing to domain.tld/page 1 and so on.

If I set the links as [[folder A/page1]] they are not being rendered as links.

Thanks again and keep up the good work.

rishikanthc commented 2 months ago

Are you on the latest release ? Can you try re-pulling the image ? I'm running 0.3.0 at https://markopolis.fly.dev and just tested this For me it's rendered under domain.tld/folder/file1.md and domain.tld/folder/file2.md and they direct to the same URL.

linking [[folder/file1]] is not supposed to work as it's not obsidian syntax. Obsidian automatically changes [[folder/file1]] to [[file1]].

cromelex commented 2 months ago

Are you on the latest release ? Can you try re-pulling the image ? I'm running 0.3.0 at https://markopolis.fly.dev and just tested this For me it's rendered under domain.tld/folder/file1.md and domain.tld/folder/file2.md and they direct to the same URL.

Yes, on 0.3.0. I did re-pull. Can you try with "folder A" and "file 1.md" ? Wondering if it is the spaces.

linking [[folder/file1]] is not supposed to work as it's not obsidian syntax. Obsidian automatically changes [[folder/file1]] to [[file1]].

It works in Obsidian though, Obsidian sets the shortest path possible. If you have 2 files with the same name in different folders, Obsidian includes the folder name in the link:

I have a folder “F1”, and a file “file.md” inside. I also have a folder “F2”, and a file “file.md” inside too. In another file “abc.md”, if I write[[, it will let me choose "[[F1/file.md]]"or “[[F2/file.md]]”.

rishikanthc commented 2 months ago

Still works with spaces. Is cache disabled ? I'm not able to think why this wouldn't work.. Let me try and recreate this on my end..

Screenshot 2024-08-15 at 2 21 54 PM

Gotcha. That logic is currently not supported. So it will not work if for example there are 2 files with the same name. I'll add that in sometime.

cromelex commented 2 months ago

Not cache. Just to be clear, it's not the links on the left menu, ie "folder A/file1". Those are fine.

But if I link to [[file1]] on the body of home.md, that link is ignoring the folder and therefore breaks.

rishikanthc commented 2 months ago

Ohhh. Okay my bad. I misunderstood. Let me look into this.

rishikanthc commented 2 months ago

Okay I have added a temporary fix now. Wikilinks work by calculating relative paths. so [[folder/file1]] will work. [[file1]] will not work unless file1 is in the same folder. Closing this for now. Let me know if you face any issues.

cromelex commented 2 months ago

Okay I have added a temporary fix now. Wikilinks work by calculating relative paths. so [[folder/file1]] will work. [[file1]] will not work unless file1 is in the same folder. Closing this for now. Let me know if you face any issues.

Not quite fixed yet.

[[folder A/file1]] on the home.md is linking to domain.tld/folder-A/file1 . However, file1 is being served on domain.tld/folder A/file1 - meaning the link in the body of home.md is actually broken.

Markopolis is hyphenating the blank space on the folder name in the link.


As a note for documentation, setting Obsidian to use relative paths under link format will ensure they are generated as [[folder/file]]. image

rishikanthc commented 2 months ago

Ahhh I see. Got it. I'll fix this soon. This is an easy fix.

rishikanthc commented 2 months ago

This has been fixed now. If you are using your Obsidian Vault set this setting to Absolute path in Vault. Let me know if that works. Also delete has been added as well

cromelex commented 2 months ago

This has been fixed now. If you are using your Obsidian Vault set this setting to Absolute path in Vault. Let me know if that works. Also delete has been added as well

Okay 2 things here.

1st, I am still seeing the hyphenation issue.

[[folder A/file1]] on home.md is linking to domain.tld/folder-A/file1 . However, file1 is being served on domain.tld/folder A/file1 - meaning the link in the body of home.md is actually broken. The space is being replaced with a hyphen for the link itself.

2nd, just for sake of documentation, I think this needs to be "Relative Path", not absolute.

home.md
/folder A
        file1.md
        file2.md

Relative path to home.md is the correct one, as it'll create [[folder A/file1]]. Markopolis is generating domain.tld/folder-A/file1 so at the moment is just the hyphen that needs fixing.

However, if you do something like I do,

/Vault
    /Personal
    /Publish
        home.md
        /folder A
            file1.md
            file2.md

An "Absolute path" would generate domain.tld/Personal/Publish/folder A/file1

This is because I am not publishing( ie running the consume command) the vault from root, but rather, from /Publish

Relative path should work. Might just need to do some further testing from within the subfolder files to see if the links would all be generated ok.

cromelex commented 2 months ago

Okay so the relative doesn't quite work either out of the box.

Based on this example:

/Vault
    /Personal
    /Publish
        home.md
        /folder A
            file1.md
            file2.md

Creating a link in file1.md to home.md works, as it generates as [[../home|home]] which generates properly as domain.tld/home

However, a link to file2.md from file1.md would generate as [[file2.md]]. This doesn't work because it becomes domain.tld/file2, instead i'd need to modify the link to [[folder A/file2]] so it properly becomes domain.tld/folder A/file2

This is fine (provided the hyphen thing gets fixed), ie, it can be made to work, but if you can improve to be able to always use a relative path that would be great.

Otherwise, I think it just needs to be documented, as in, either the user consumes from the root directory (and as such, "Absolute Path" will always work) or a relative path might need editing within subfolders.

rishikanthc commented 2 months ago

Gotcha.. Relative path is a bit tricky so I implemented this as a stop gap. I'll work on adding support for that. The hyphen thing is easy to fix. Will do that shortly. Sorry for reintroducing the hyphen bug. thought I fixed it.

cromelex commented 2 months ago

No problem. I think the current implementation is good enough, as long as this gets documented so that people know then it is going to be manageable.

rishikanthc commented 2 months ago

Fixed the problem of handling urls with space. Also updated documentation to let people know about the path to use.