Skip to content

Commit

Permalink
docs: update README, improve error message
Browse files Browse the repository at this point in the history
  • Loading branch information
tuchandra committed Jan 13, 2024
1 parent 4cbf712 commit f567e19
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,21 @@ To develop the project:
- Start the development server with `bun dev`.
- Format and lint (with autofixes) with `bun fix`.

The build process generates main.js and places it in the root of the repo.
I commit this file to Github for simplicity.

To create a release:

- Increment the version: `bun version <name>`, where the name is e.g., `1.0.0-beta4`.
- Commit the (now-changed) package.json and manifest.json files.
- Create a new tag with the same name: `git tag -a <name> -m <name>`
- Push the commit(s) & tag.

In response to pushing the tag, Github Actions will create a new release that includes the main.js & manifest.json files..

## Releases
I have not released this plugin and don't plan to.
If you're interested in using this plugin, please install it via the excellent and community-maintained [BRAT](https://github.com/TfTHacker/obsidian42-brat)
I have created beta releases to support installation with the excellent, community-maintained [BRAT](https://github.com/TfTHacker/obsidian42-brat).
I don't plan to submit this as an official plugin unless there is interest from not-just-me.

Issues, PRs, and discussions are welcome.
If you like this, please let me know!
7 changes: 4 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,13 @@ class DailyHighlightsPlugin extends obsidian.Plugin {
* highlight. This uses the Readwise plugin settings, which already map book titles
* to book IDs for the usual syncing.
*/
findFile({ bookId }) {
findFile({ bookId, title }) {
const { booksIDsMap } = this.getOfficialPluginSettings();
const bookTitle = Object.keys(booksIDsMap).find(
(title) => booksIDsMap[title] === bookId.toString()
(title2) => booksIDsMap[title2] === bookId.toString()
);
if (!bookTitle) {
throw new Error(`No book found for id ${bookId}`);
throw new Error(`No book found for '${title}' with id ${bookId}`);
}
const maybeFile = this.app.vault.getAbstractFileByPath(bookTitle);
if (maybeFile instanceof obsidian.TFile)
Expand All @@ -155,6 +155,7 @@ class DailyHighlightsPlugin extends obsidian.Plugin {
const highlightsWithLinks = blocks.flatMap(
(x) => x.status === "fulfilled" ? [x.value] : []
);
console.log(blocks, highlightsWithLinks);
const modalContents = highlightsWithLinks.map((x) => ({
highlightId: x.block.id,
text: x.highlight.text,
Expand Down
4 changes: 2 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,15 +141,15 @@ export default class DailyHighlightsPlugin extends Plugin {
* highlight. This uses the Readwise plugin settings, which already map book titles
* to book IDs for the usual syncing.
*/
findFile({ bookId }: Highlight): TFile {
findFile({ bookId, title }: Highlight): TFile {
const { booksIDsMap } = this.getOfficialPluginSettings();

// Find the key/value pair where the value matches the book ID
const bookTitle = Object.keys(booksIDsMap).find(
(title) => booksIDsMap[title] === bookId.toString(),
);
if (!bookTitle) {
throw new Error(`No book found for id ${bookId}`);
throw new Error(`No book found for '${title}' with id ${bookId}`);
}

const maybeFile = this.app.vault.getAbstractFileByPath(bookTitle);
Expand Down

0 comments on commit f567e19

Please sign in to comment.