Skip to content

Commit e859fa0

Browse files
authored
Merge pull request #17 from BlockScience/hackmd-update-type
update hackmd
2 parents d9a4efe + 452d46f commit e859fa0

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

src/rid_lib/types/hackmd_note.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33

44
class HackMDNote(ORN):
55
namespace = "hackmd.note"
6-
7-
def __init__(self, note_id: str):
6+
7+
def __init__(self, note_id: str, workspace_id: str | None = None):
88
self.note_id = note_id
9-
9+
self.workspace_id = workspace_id
10+
1011
@property
11-
def reference(self):
12+
def reference(self) -> str:
13+
if self.workspace_id:
14+
return f"{self.workspace_id}/{self.note_id}"
1215
return self.note_id
13-
16+
1417
@classmethod
15-
def from_reference(cls, reference):
16-
return cls(reference)
18+
def from_reference(cls, reference: str) -> "HackMDNote":
19+
if "/" in reference:
20+
workspace_id, note_id = reference.split("/", 1)
21+
return cls(note_id=note_id, workspace_id=workspace_id)
22+
return cls(note_id=reference)

0 commit comments

Comments
 (0)