Skip to content

Commit

Permalink
Merge pull request #22 from oleeskild/feature/HeadingLinks
Browse files Browse the repository at this point in the history
Feature/heading links
  • Loading branch information
oleeskild authored Mar 23, 2022
2 parents afed88d + 8791721 commit 6232129
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
9 changes: 7 additions & 2 deletions Publisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,15 +224,20 @@ export default class Publisher {
let [linkedFileName, prettyName] = textInsideBrackets.split("|");

prettyName = prettyName || linkedFileName;
let headerPath = "";
if (linkedFileName.includes("#")) {
linkedFileName = linkedFileName.split("#")[0];
const headerSplit = linkedFileName.split("#");
linkedFileName = headerSplit[0];
//currently no support for linking to nested heading with multiple #s
headerPath = headerSplit.length > 1 ? `#${headerSplit[1]}` : '';

}
const fullLinkedFilePath = getLinkpath(linkedFileName);
const linkedFile = this.metadataCache.getFirstLinkpathDest(fullLinkedFilePath, filePath);

if (linkedFile.extension === "md") {
const extensionlessPath = linkedFile.path.substring(0, linkedFile.path.lastIndexOf('.'));
convertedText = convertedText.replace(linkedFileMatch, `[[${extensionlessPath}|${prettyName}]]`);
convertedText = convertedText.replace(linkedFileMatch, `[[${extensionlessPath}${headerPath}|${prettyName}]]`);
}
} catch {
continue;
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dg-publish: true
8. Go to your site's URL which you should find on [Netlify](https://app.netlify.com). If nothing shows up yet, wait a minute and refresh. Your note should now appear.

Congratulations, you now have your own digital garden, hosted free of charge!
You can now start adding links as you usually would in Obisidan, with double square brackets like this: [[Some Other Note]]) to the note that you just published. Remember to also publish the notes your are linking to as this will not happen automatically. This is by design. You are always in control of what notes you actually want to publish. If you did not publish a linked note, the link will simply lead to a site telling the user that this note does not exist.
You can now start adding links as you usually would in Obisidan, with double square brackets like this: [[Some Other Note]]) to the note that you just published. You can also link to a specific header by using the syntax [[Some Other Note#A Header]]. Remember to also publish the notes your are linking to as this will not happen automatically. This is by design. You are always in control of what notes you actually want to publish. If you did not publish a linked note, the link will simply lead to a site telling the user that this note does not exist.

## Commands

Expand Down Expand Up @@ -149,4 +149,4 @@ By default, all notes except the home-note shows a link back to the home-note. I
---
dg-home-link: false
---
```
```
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class DigitalGarden extends Plugin {
publishModal: PublishModal;

async onload() {
this.appVersion = "2.7.0";
this.appVersion = "2.8.0";
//If current appversion in settings unmatches this, show new notice with info about updating the template

console.log("Initializing DigitalGarden plugin v" + this.appVersion);
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "digitalgarden",
"name": "Digital Garden",
"version": "2.7.0",
"version": "2.8.0",
"minAppVersion": "0.12.0",
"description": "Publish your notes to a digital garden for others to enjoy.",
"author": "Ole Eskild Steensen",
"authorUrl": "https://ole.dev/garden",
"isDesktopOnly": false
}
}
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"2.8.0": "0.12.0",
"2.7.0": "0.12.0",
"2.6.2": "0.12.0",
"2.6.1": "0.12.0",
Expand All @@ -19,4 +20,4 @@
"1.2.0": "0.12.0",
"1.1.0": "0.12.0",
"1.0.0": "0.12.0"
}
}

0 comments on commit 6232129

Please sign in to comment.