Skip to content

Commit

Permalink
Release 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
scottwillmoore committed Apr 10, 2023
1 parent 4b17b50 commit f28393a
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:
- name: Create release
uses: ncipollo/release-action@v1
with:
artifacts: "main.js,manifest.json"
artifacts: "main.js,manifest.json,styles.css"
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,25 @@

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.1.0] - 2023-04-10

## Added

- A settings tab to configure the plugin.
- Shorten internal links to blocks, headings, notes and files.
- Show icons next to internal links to indicate their types.
- Replace external link icons with the icons provided by this plugin.
- Reload the editing and preview view when settings are changed.

## Changed

- Refactor the structure of the plugin.
- Rewrite the internal system to be more generic and robust.
- Update the [`README.md`](./README.md) with new documentation.
- Change the plugin name to be less specific.
- Update GitHub workflow to include `styles.css`.

## [1.0.2] - 2023-01-15

Expand Down Expand Up @@ -33,6 +50,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Project settings for Visual Studio Code.
- A [`README.md`](./README.md) and a [`LICENSE`](./LICENSE).

[1.1.0]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.1.0
[1.0.2]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.0.2
[1.0.1]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.0.1
[1.0.0]: https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings/releases/tag/v1.0.0
23 changes: 18 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# Short Internal Links to Headings
# Short links

An [Obsidian plugin](https://obsidian.md/) to display [internal links to headings](https://help.obsidian.md/How+to/Internal+link) as just the heading name instead of the the note name, followed by the the parent heading names, and then the heading name. This plugin updates the behaviour in both the **editing (live preview)** and **reading view**. This a temporary plugin, that will not be needed if the [feature request](https://forum.obsidian.md/t/option-to-display-heading-without-note-title-in-internal-links/22253) is implemented. Please create an issue on [GitHub](https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings) if you find any problems with the plugin, or have any suggestions or questions.
An [Obsidian plugin](https://obsidian.md/) to display short [internal links](https://help.obsidian.md/How+to/Internal+link).

## Overview

Internal links to **files**, **notes**, **headings**, and **blocks** can be shortened. There are various configuration options to adjust how this is applied. In addition, icons can be displayed at the start or end of links to indicate their type.

This plugin updates the behaviour in both the **editing (live preview)** and **reading view**. This a temporary plugin, that will not be needed if the [feature request](https://forum.obsidian.md/t/option-to-display-heading-without-note-title-in-internal-links/22253) is implemented.

Please create an issue on [GitHub](https://github.com/scottwillmoore/obsidian-short-internal-links-to-headings) if you find any problems with the plugin, or have any suggestions or questions.

## Preview

<center>

| Without plugin | With Plugin |
| --------------------------------------------------------- | --------------------------------------------------- |
| ![Screenshot without the plugin](screenshots/without.png) | ![Screenshot with the plugin](screenshots/with.png) |
| Without plugin | With Plugin |
| ------------------------------------------------------------------- | ------------------------------------------------------------- |
| ![Screenshot without the plugin](screenshots/australia-without.png) | ![Screenshot with the plugin](screenshots/australia-with.png) |
| ![Screenshot without the plugin](screenshots/example-without.png) | ![Screenshot with the plugin](screenshots/example-with.png) |

![Screenshot of settings](screenshots/configuration.png)

</center>

Expand Down
24 changes: 1 addition & 23 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
# Tasks

## Next release

- [x] Add support for files, notes, headings and blocks
- [x] Live preview
- [x] Preview
- [x] Add ability to set icon side
- [x] Add support for icons
- [x] Allow Markdown post-processor to be reloaded
- [x] Clean up implementation
- [x] Clean up the notes in the sources
- [ ] Check that the live preview and preview implementation is identical
- [ ] Update `manifest.json` and `versions.json`
- [ ] Update `README.md` with documentation
- [ ] Update `CHANGELOG.md`
- [ ] Update GitHub workflow to include `styles.css` and `versions.json`?
- [ ] Release next version with Git tag
- [ ] Close related issues

# Future release

- [ ] Add support for customization of the icons
- [ ] Add versions to the configuration schema
- [ ] Rename plugin for expanded scope
- [ ] Add issue labels for GitHub
- [ ] Add issue templates for GitHub
- [ ] Bug report
- [ ] Feature request
- [ ] Allow users to customize the link icons
8 changes: 4 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"id": "short-internal-links-to-headings",
"name": "Short Internal Links to Headings",
"description": "Display internal links to headings as just the heading name.",
"name": "Short links",
"description": "An Obsidian plugin to display short internal links.",
"author": "Scott Moore",
"version": "1.0.2",
"minAppVersion": "0.16.0",
"version": "1.1.0",
"minAppVersion": "1.1.1",
"isDesktopOnly": false
}
File renamed without changes.
23 changes: 23 additions & 0 deletions notes/Example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# External links

[Obsidian](https://obsidian.md/)

# Internal links

## Files

[[Folder1/Folder2/File.png]]

## Notes

[[Folder1/Folder2/Note]]

## Headings

[[Folder1/Folder2/Note#Heading 1]]

[[Folder1/Folder2/Note#Heading 1#Heading 2]]

## Blocks

[[Folder1/Folder2/Note#^2dbed0]]
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"private": true,
"name": "short-internal-links-to-headings",
"description": "An Obsidian plugin to display internal links to headings as just the heading name.",
"description": "An Obsidian plugin to display short internal links.",
"author": "Scott Moore",
"license": "MIT",
"version": "1.0.2",
"version": "1.1.0",
"scripts": {
"build": "node --require esbuild-register scripts/build.ts",
"format": "prettier --write .",
Expand Down
Binary file added screenshots/australia-with.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/australia-without.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/configuration.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/example-with.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/example-without.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed screenshots/with.png
Binary file not shown.
Binary file removed screenshots/without.png
Binary file not shown.
44 changes: 26 additions & 18 deletions sources/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ import { PluginSettingTab, Setting } from "obsidian";
import { ShortLinkPlugin } from "./plugin";

export enum Position {
Start,
End,
Start = "start",
End = "end",
}

// NOTE: It would be a good idea to attempt to maintain a versioned
// configuration, therefore making it easier to support forward and backward
// compatibility.

export interface Configuration {
version: 1;

// Files
shortLinksToFiles: boolean;

Expand All @@ -30,6 +28,8 @@ export interface Configuration {
}

export const defaultConfiguration: Configuration = {
version: 1,

// Files
shortLinksToFiles: true,

Expand All @@ -45,7 +45,7 @@ export const defaultConfiguration: Configuration = {
// Icons
showIcons: true,
replaceExternalLinkIcons: true,
iconPosition: Position.End,
iconPosition: Position.Start,
};

// NOTE: It would be nice to have a live preview of example Markdown that would
Expand All @@ -68,7 +68,7 @@ export class ShortLinkPluginSettingTab extends PluginSettingTab {

new Setting(this.containerEl)
.setName("Short links to files")
.setDesc("Only show the file name in internal links to files.")
.setDesc("Only show the file name in links to headings.")
.addToggle((toggle) =>
toggle.setValue(configuration.shortLinksToFiles).onChange((newValue) => {
configuration.shortLinksToFiles = newValue;
Expand All @@ -79,7 +79,7 @@ export class ShortLinkPluginSettingTab extends PluginSettingTab {

new Setting(this.containerEl)
.setName("Short links to headings")
.setDesc("Only show the heading name in internal links to headings.")
.setDesc("Only show the last heading name in links to headings.")
.addToggle((toggle) =>
toggle.setValue(configuration.shortLinksToHeadings).onChange((newValue) => {
configuration.shortLinksToHeadings = newValue;
Expand All @@ -88,27 +88,35 @@ export class ShortLinkPluginSettingTab extends PluginSettingTab {

new Setting(this.containerEl)
.setName("Show subheadings")
.setDesc("Show both headings and subheadings in shortened internal links to headings.")
.setDesc("Show all heading names in links to headings.")
.addToggle((toggle) =>
toggle.setValue(configuration.showSubheadings).onChange((newValue) => {
configuration.showSubheadings = newValue;
})
);
new Setting(this.containerEl)
.setName("Show hash")
.setDesc("Show the hash at the start of links to headings.")
.addToggle((toggle) =>
toggle.setValue(configuration.showHash).onChange((newValue) => {
configuration.showHash = newValue;
})
);

new Setting(this.containerEl).setHeading().setName("Blocks");

new Setting(this.containerEl)
.setName("Short links to blocks")
.setDesc("Only show the block name in internal links to blocks.")
.setDesc("Only show the block name in links to blocks.")
.addToggle((toggle) =>
toggle.setValue(configuration.shortLinksToBlocks).onChange((newValue) => {
configuration.shortLinksToBlocks = newValue;
})
);

new Setting(this.containerEl)
.setName("Show carets")
.setDesc("Show the block name with a caret.")
.setName("Show caret")
.setDesc("Show the caret at the start of links to blocks.")
.addToggle((toggle) =>
toggle.setValue(configuration.showCaret).onChange((newValue) => {
configuration.showCaret = newValue;
Expand All @@ -119,7 +127,7 @@ export class ShortLinkPluginSettingTab extends PluginSettingTab {

new Setting(this.containerEl)
.setName("Show icons")
.setDesc("Show icons with links to indicate their type.")
.setDesc("Show icons to indicate the type of internal link.")
.addToggle((toggle) =>
toggle.setValue(configuration.showIcons).onChange((newValue) => {
configuration.showIcons = newValue;
Expand All @@ -128,7 +136,7 @@ export class ShortLinkPluginSettingTab extends PluginSettingTab {

new Setting(this.containerEl)
.setName("Replace external link icons")
.setDesc("For consistency, let this plugin replace the default icon for external links.")
.setDesc("For consistency, replace the default icon used for external links.")
.addToggle((toggle) =>
toggle.setValue(configuration.replaceExternalLinkIcons).onChange((newValue) => {
configuration.replaceExternalLinkIcons = newValue;
Expand All @@ -137,16 +145,16 @@ export class ShortLinkPluginSettingTab extends PluginSettingTab {

new Setting(this.containerEl)
.setName("Icon position")
.setDesc("Set whether icons are show before or after the link.")
.setDesc("Set whether icons are show at the start or end of links.")
.addDropdown((dropdown) =>
dropdown
.addOptions({
[Position.Start]: "Start",
[Position.End]: "End",
})
.setValue(String(configuration.iconPosition))
.setValue(configuration.iconPosition)
.onChange((newValue) => {
configuration.iconPosition = Number(newValue);
configuration.iconPosition = newValue as Position;
})
);
}
Expand Down
14 changes: 7 additions & 7 deletions sources/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { getIcon } from "obsidian";
import { Position } from "./configuration";

export enum LinkType {
External,
Internal,
External = "external",
Internal = "internal",
}

export enum InternalLinkType {
Block,
Heading,
Note,
File,
Block = "block",
Heading = "heading",
Note = "note",
File = "file",
}

export interface LinkMap<T> {
Expand Down Expand Up @@ -104,7 +104,7 @@ export const parseInternalLink = (link: string): InternalLink => {

return { type, heading, headingIndex, lastHeading, lastHeadingIndex };
} else {
const pathIndex = Math.max(link.lastIndexOf("/"), 0);
const pathIndex = link.lastIndexOf("/");
const path = link.substring(0, pathIndex);

const nameIndex = pathIndex + 1;
Expand Down

0 comments on commit f28393a

Please sign in to comment.