You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
-
4
1
name: Node.js CI
5
2
6
3
on:
@@ -11,19 +8,17 @@ on:
11
8
12
9
jobs:
13
10
build:
14
-
15
-
runs-on: ubuntu-latest
16
-
11
+
runs-on: ${{ matrix.os }}
17
12
strategy:
18
13
matrix:
19
-
node-version: [14.x, 16.x]
20
-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
Copy file name to clipboardExpand all lines: README.md
+107-8Lines changed: 107 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
I use [Obsidian.md](https://obsidian.md/) to draft my posts before they are published on PhotoGabble. One feature of #Obsidian that I love is interlinking between notes and being able to see the connectivity graph of each note.
5
5
6
-
In January 2023 I wrote about how I [added Wiki Links support to Eleventy.js](https://www.photogabble.co.uk/noteworthy/adding-wiki-links-to-11ty/) and in doing so this plugin was borne. It has since been updated to include support for Obsidians[embedding files](https://help.obsidian.md/Linking+notes+and+files/Embedding+files).
6
+
In January 2023 I wrote about how I [added Wiki Links support to Eleventy.js](https://www.photogabble.co.uk/noteworthy/adding-wiki-links-to-11ty/) and in doing so this plugin was borne. It has since been updated to include support for Obsidian's[embedding files](https://help.obsidian.md/Linking+notes+and+files/Embedding+files).
7
7
8
8
## Install
9
9
@@ -40,9 +40,12 @@ type EleventyPluginInterlinkOptions = {
40
40
// that returns [UNABLE TO LOCATE EMBED].
41
41
unableToLocateEmbedFn?:ErrorRenderFn,
42
42
43
-
// slugifyFn is used to slugify strings. If a function
44
-
// isn't set then the default 11ty slugify filter is used.
45
-
slugifyFn?:SlugifyFn
43
+
// deadLinkReport is the desired output format of the dead link report, by default its set to 'console'
44
+
deadLinkReport?:'console'|'json'|'none',
45
+
46
+
// resolvingFns contains functions used for resolving a wikilinks output.
47
+
// see the Custom Resolving Functions section below
This plugin will now parse all Wiki Links formatted for example, `[[Eleventy.js Interlink Plugin]]` appears as [Eleventy.js Interlink Plugin](https://photogabble.co.uk/projects/eleventyjs-interlink-plugin/).
68
+
This plugin will parse both Wikilinks and internal anchor links to build each pages inbound and outbound internal links.
69
+
70
+
The Wikilink format is a **page reference** wrapped in double square brackets, for example: `[[Eleventy.js Interlink Plugin]]` will appear as [Eleventy.js Interlink Plugin](https://photogabble.co.uk/projects/eleventyjs-interlink-plugin/).
71
+
72
+
> **NOTE**: By default this plugin will use the `title` front-matter attribute of your pages or one of the aliases (as detailed below) as the **page reference**.
66
73
67
74
Using the vertical bar (`|`) you can change the text used to display a link. This can be useful when you want to work a link into a sentence without using the title of the file, for example: `[[Eleventy.js Interlink Plugin|custom display text]]` appears as [custom display text](https://www.photogabble.co.uk/projects/eleventyjs-interlink-plugin/).
68
75
69
-
> NOTE: By default this plugin will use the `title` front-matter attribute of your pages or one of the aliases (as detailed below).
76
+
### Linking to fragment identifiers
77
+
78
+
If you're using a plugin such as [markdown-it-anchor](https://www.npmjs.com/package/markdown-it-anchor) to add _anchor links_ to your headings, or have otherwise added them yourself. You can link to these in your pages by adding a `#` symbol to your page reference.
79
+
80
+
For example, `[[Three laws of motion#Second law]]`.
81
+
82
+
In cases where you have the `#` in the title of a page you're linking to you can escape using `/` foe example, `[[Programming in /#C, an introduction]]`.
83
+
84
+
### Linking to files by path
85
+
86
+
You can link to pages by their project path, or a path relative to the linking page, for example: `[[/blog/post-1234.md]]` would link to the page found at `/blog/post-1234` relative to the project root path, While `[[../../something.md]]` would link to a page two directories up.
70
87
71
88
### Aliases
72
89
73
90
Aliases provide you a way of referencing a file using different names, use the `aliases` property in your font matter to list one or more aliases that can be used to reference the file from a Wiki Link. For example, you might add _AI_ as an alias of a file titled _Artificial Intelligence_ which would then be linkable via `[[AI]]`.
74
91
92
+
These can be defined as either an array as shown below or a single alias via `aliaes: AI`.
93
+
94
+
```yaml
95
+
---
96
+
title: Artificial Intelligence
97
+
aliases:
98
+
- AI
99
+
---
100
+
```
101
+
102
+
Aliases should be unique identifiers, this plugin will halt the build with an error if it finds two pages sharing the same alias.
103
+
75
104
### Linking to Pagination generated pages
76
105
77
106
A common use of pagination in 11ty is [pagination of an object](https://www.11ty.dev/docs/pagination/#paging-an-object) or data file, by default these generated pages aren't included in the all pages collection and therefore are invisible to this plugin unless you set `addAllPagesToCollections: true`.
@@ -92,6 +121,29 @@ eleventyComputed:
92
121
---
93
122
```
94
123
124
+
### Custom Resolving Functions
125
+
126
+
Custom resolving functions can be considered pluggable extensions to the wikilink lookup and rendering logic and can be invoked by usage of a `:` character in a wikilink prefixed by the functions name, for example: `[[issue:19]]`.
127
+
128
+
These functions are added to the interlinker via its `resolvingFns` configuration options, for example:
When invoked the resolving function will be passed three arguments, the parsed Wikilink object (see _Wikilink Data Structure_ section below.) The linking page object from 11ty and the interlinker class instance.
140
+
141
+
The plugin has three internal resolving functions which are defined only if not already via the plugin config:
142
+
143
+
-`default`, this is the default resolving function and converts the Wikilink Data Structure directly into an HTML link
144
+
-`default-embed`, this is the default embed resolving function
145
+
-`404-embed`, this is invoked when the embed template is not found. This currently invokes the `unableToLocateEmbedFn` however, in a future version it will replace that config option entirely
146
+
95
147
### Embedding
96
148
97
149
Embedding files allows you to reuse content across your website while tracking what pages have used it.
@@ -144,10 +196,57 @@ You can then display this information in any way you would like, I use the below
144
196
{% endif %}
145
197
```
146
198
199
+
### Dead link Report
200
+
201
+
The default behaviour of this plugin is to report to the console every broken Wikilink and internal link. This behaviour is configurable via the `deadLinkReport` config option. This option accepts three values: `none`, `console` and `json` with `console` being the default.
202
+
203
+
Setting the value to `none` will disable the dead link report while setting it to `json` will silence console output instead writing to `.dead-links.json` within the project root folder.
204
+
205
+
### Page lookup logic
206
+
207
+
This plugin will attempt to identify the page being linked using the following steps in order:
208
+
209
+
1. if is path link, return `filePathStem` match state
210
+
2. match file url to link href
211
+
3. match file title to link identifier (name)
212
+
4. match file slug to link identifier (name)
213
+
5. match file based upon alias
214
+
215
+
### Pages Excluded from Collections
216
+
217
+
Due to how this plugin obtains a pages template content, all pages with `eleventyExcludeFromCollections:true` set will **NOT** be parsed by the interlinker.
218
+
219
+
## Wikilink Data Structure
220
+
221
+
```typescript
222
+
typeWikilinkMeta= {
223
+
title:string|null
224
+
name:string
225
+
anchor:string|null
226
+
link:string
227
+
slug:string
228
+
isEmbed:boolean
229
+
isPath:boolean
230
+
231
+
// If linked page has been found in the all collection exists will be
232
+
// true and page will be the 11ty page object.
233
+
exists:boolean
234
+
page?:any
235
+
236
+
// name of the resolving fn, if set it must exist
237
+
resolvingFnName?:string
238
+
// the resulting HTML of the resolving function
239
+
content?:string
240
+
241
+
// href and path are loaded from the linked page
242
+
href?:string
243
+
path?:string
244
+
}
245
+
```
246
+
147
247
## Known Caveats
148
248
149
-
- This plugin doesn't implement all [Obsidians wikilink support](https://help.obsidian.md/Linking+notes+and+files/Internal+links) for example linking to a block in a note and linking to a heading in a note is not currently supported by this plugin
- This plugin doesn't implement all [Obsidian's wikilink support](https://help.obsidian.md/Linking+notes+and+files/Internal+links) for example linking to a block in a note and linking to a heading in a note is not currently supported by this plugin
151
250
- Only supports embedding one note inside another, no other Obsidian file embedding functionality is currently supported by this plugin
0 commit comments