Skip to content

Commit 6e39761

Browse files
committed
Feat: Add "Open in Readwise" link
Feat: Show tags in default highlight template
1 parent 7ed5856 commit 6e39761

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

CHANGELOG.md

+11-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Changelog
2+
## 1.4.1 (2023-10-27)
3+
This update adds better support for Readwise article highlighting and default tag template support. Thanks to first time contributor @tdznr for adding to this release.
4+
5+
- Feature: Add "Open in Readwise" link when Readwise `url` field is present. The `url` field contains the link to Readwise's website showing the highlighted snippet in context of the source.
6+
- The `url` field is not available for book types, but is available for other content types such as Articles.
7+
- Feature: Show tags in default highlight template
8+
29
## 1.4.0 (2023-08-18)
310
Thanks to @johannrichard for the following contributions:
411

@@ -15,20 +22,20 @@ Thanks to @johannrichard for the following contributions:
1522
The following highlight
1623
```
1724
Multi-line text in blockquotes
18-
19-
This is an example of a multi-line highlight with line-breaks.
25+
26+
This is an example of a multi-line highlight with line-breaks.
2027
```
2128
... with this template
2229
```markdown+nunjucks
2330
> [!quote]
2431
> {{ text | bq }}
2532
```
26-
will turn into
33+
will turn into
2734
```markdown
2835
> [!quote]
2936
> Multi-line text in blockquotes
3037
>
31-
> This is an example of a multi-line highlight with line-breaks.
38+
> This is an example of a multi-line highlight with line-breaks.
3239
```
3340
### Updates
3441
- Change field names to reflect their use in frontmatter

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ The highlight template exposes the following variables:
171171
- ```note```: Your nore
172172
- ```location```: The location
173173
- ```location_url```: The url of the location
174+
- ```url```: Unique highlight link (Open in Readwise)
174175
- ```color```: The color
175176
- ```highlighted_at```: Date highlighted (empty if none)
176177
- ```tags```: A formatted string of tags

main.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,9 @@ Note: {{ note }}
7777
{%- endif %}{%- if tags %}
7878
7979
Tags: {{ tags }}
80+
{%- endif %}{%- if url %}
81+
82+
[Open in Readwise]({{ url }})
8083
{%- endif %}
8184
8285
---
@@ -119,9 +122,11 @@ export default class ReadwiseMirror extends Plugin {
119122
note: note,
120123
location: location,
121124
location_url: locationUrl,
125+
url, // URL is set for source of highlight (webpage, tweet, etc). null for books
122126
color: color,
123127
highlighted_at: highlighted_at ? this.formatDate(highlighted_at) : '',
124128
tags: formattedTagStr,
129+
125130
// Book fields
126131
category: book.category,
127132
});
@@ -272,12 +277,12 @@ export default class ReadwiseMirror extends Plugin {
272277
let authorStr =
273278
authors[0] && authors?.length > 1
274279
? authors
275-
.filter((authorName: string) => authorName.trim() != '')
276-
.map((authorName: string) => `[[${authorName.trim()}]]`)
277-
.join(', ')
280+
.filter((authorName: string) => authorName.trim() != '')
281+
.map((authorName: string) => `[[${authorName.trim()}]]`)
282+
.join(', ')
278283
: author
279-
? `[[${author}]]`
280-
: ``;
284+
? `[[${author}]]`
285+
: ``;
281286

282287
const metadata = {
283288
id: id,
@@ -302,9 +307,8 @@ export default class ReadwiseMirror extends Plugin {
302307
const headerContents = this.headerTemplate.render(metadata);
303308
const contents = `${frontMatterContents}${headerContents}${formattedHighlights}`;
304309

305-
let path = `${this.settings.baseFolderName}/${
306-
category.charAt(0).toUpperCase() + category.slice(1)
307-
}/${sanitizedTitle}.md`;
310+
let path = `${this.settings.baseFolderName}/${category.charAt(0).toUpperCase() + category.slice(1)
311+
}/${sanitizedTitle}.md`;
308312

309313
const abstractFile = vault.getAbstractFileByPath(path);
310314

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "readwise-mirror",
33
"name": "Readwise Mirror",
4-
"version": "1.4.0",
4+
"version": "1.4.1",
55
"minAppVersion": "0.11.0",
66
"description": "Mirror your Readwise library directly to an Obsidian vault",
77
"author": "jsonmartin",

0 commit comments

Comments
 (0)