Skip to content

Commit dd1187f

Browse files
committed
v0.0.16
2 parents 4c0de36 + a75e0ab commit dd1187f

7 files changed

+29
-13
lines changed

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-raindrop-highlights",
33
"name": "Raindrop Highlights",
4-
"version": "0.0.15",
4+
"version": "0.0.16",
55
"minAppVersion": "0.14.0",
66
"description": "Sync your Raindrop.io highlights.",
77
"author": "kaiiiz",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-raindrop-highlights",
3-
"version": "0.0.15",
3+
"version": "0.0.16",
44
"description": "Sync your Raindrop.io highlights.",
55
"main": "main.js",
66
"scripts": {

src/api.ts

+22-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import axios from "axios";
33
import type { RaindropBookmark, RaindropCollection, RaindropHighlight, RaindropUser } from "./types";
44
import TokenManager from "./tokenManager";
55

6-
const BASEURL = "https://api.raindrop.io/rest/v1"
6+
const BASEURL = "https://api.raindrop.io/rest/v1";
7+
8+
interface NestedRaindropCollection {
9+
title: string,
10+
parentId: number,
11+
}
712

813
export class RaindropAPI {
914
app: App;
@@ -42,35 +47,45 @@ export class RaindropAPI {
4247

4348
async getCollections(): Promise<RaindropCollection[]> {
4449
let res = await this.get(`${BASEURL}/collections`, {});
45-
const collectionMap: {[id: number]: string} = {};
4650

4751
let collections: RaindropCollection[] = [
4852
{ id: -1, title: 'Unsorted' },
4953
{ id: -99, title: 'Trash' },
5054
];
55+
56+
const rootCollectionMap: {[id: number]: string} = {};
5157
res.items.forEach((collection: any) => {
5258
const id = collection['_id'];
5359
const title = collection['title'];
54-
collectionMap[id] = title;
60+
rootCollectionMap[id] = title;
5561
collections.push({
5662
title: title,
5763
id: id,
5864
});
5965
});
6066

6167
res = await this.get(`${BASEURL}/collections/childrens`, {});
68+
const nestedCollectionMap: {[id: number]: NestedRaindropCollection} = {};
69+
res.items.forEach((collection: any) => {
70+
const id = collection['_id'];
71+
nestedCollectionMap[id] = {
72+
title: collection['title'],
73+
parentId: collection['parent']['$id'],
74+
};
75+
});
76+
6277
res.items.forEach((collection: any) => {
6378
const id = collection['_id'];
64-
const parentId = collection['parent']['$id'];
79+
let parentId = collection['parent']['$id'];
6580
let title = collection['title'];
66-
if (parentId in collectionMap) {
67-
title = `${collectionMap[parentId]}/${collection['title']}`;
81+
while (!(parentId in rootCollectionMap)) {
82+
title = `${nestedCollectionMap[parentId].title}/${title}`;
83+
parentId = nestedCollectionMap[parentId].parentId;
6884
}
6985
collections.push({
7086
title: title,
7187
id: id,
7288
});
73-
collectionMap[id] = title;
7489
});
7590

7691
return collections;

src/assets/defaultTemplate.njk

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% if is_new_article %}
22
# Metadata
33
{% if link %}Source URL:: {{link}}{% endif %}
4-
{% if tags|length %}Topics:: {{ tags | join(", ") }}{% endif %}
4+
{% if tags|length %}Topics:: {{ tags | map("#{}") | join(", ") }}{% endif %}
55

66
---
77
# {{title}}

src/constants.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import DEFAULT_TEMPLATE from './assets/defaultTemplate.njk';
22
import type { RaindropPluginSettings } from "./types";
33

4-
export const VERSION = '0.0.15';
4+
export const VERSION = '0.0.16';
55

66
export const DEFAULT_SETTINGS: RaindropPluginSettings = {
77
version: VERSION,

src/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface RaindropHighlight { // Remote state
2121
export interface RaindropCreatorRef { // Remote state
2222
name: string,
2323
id: number,
24-
};
24+
}
2525

2626
export interface RaindropBookmark { // Remote state
2727
id: number,

versions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"0.0.12": "0.14.0",
1414
"0.0.13": "0.14.0",
1515
"0.0.14": "0.14.0",
16-
"0.0.15": "0.14.0"
16+
"0.0.15": "0.14.0",
17+
"0.0.16": "0.14.0"
1718
}

0 commit comments

Comments
 (0)