diff --git a/Publisher.ts b/Publisher.ts index f07c5e70..e172678b 100644 --- a/Publisher.ts +++ b/Publisher.ts @@ -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; diff --git a/README.md b/README.md index a974a8fe..1989e697 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 --- -``` \ No newline at end of file +``` diff --git a/main.ts b/main.ts index 1f805b22..300e6d59 100644 --- a/main.ts +++ b/main.ts @@ -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); diff --git a/manifest.json b/manifest.json index 2b680bee..f6f78751 100644 --- a/manifest.json +++ b/manifest.json @@ -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 -} \ No newline at end of file +} diff --git a/versions.json b/versions.json index 884587dc..7480e01f 100644 --- a/versions.json +++ b/versions.json @@ -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", @@ -19,4 +20,4 @@ "1.2.0": "0.12.0", "1.1.0": "0.12.0", "1.0.0": "0.12.0" -} \ No newline at end of file +}