4 ms·
The double-backlink at the bottom is amusing - I recognize this bug from painful experience. OP counted each of the 2 links in the other article as a backlink,
by gwern 3y ago
The double-backlink at the bottom is amusing - I recognize this bug from painful experience. OP counted each of the 2 links in the other article as a backlink, and didn't deduplicate. But... if you deduplicate, then you are unable to do true bidirectional backlinks to the original caller. You can't figure out 'which' link in the other article is meant.
You need HTML IDs set on each, but they have to be different ID-anchors (obviously, and also because it'd be bad/invalid HTML to have duplicate IDs). So you actually need to track not just the other article but the ID inside the other article, and a way to generate those link IDs to begin with (since you definitely don't want to do it by hand). Gets tricky.
- algas 3y agoYup, here's the problem [0]: def calculate_backlinks( pages: Dict[str, Page], attachments: Dict[str, Attachment] ) -> None: for page in pages.values(): for link in page.links: linked_page = find(pages, attachments, link) if not linked_page: info(f"unable to find link", link, page.title) continue linked_page.backlinks.append(page) No deduplication performed. Since he's parsing the backlinks directly out of the markdown, you don't have to worry about a recursive loop where the backlinks section on one page appears as links in another. A simple solution would be to change the datatype of backlinks from list to set. [0] From OP's static site generator: https://github.com/llimllib/obsidian_notes/blob/main/run.py https://github.com/llimllib/obsidian_notes/blob/main/run.py