Skip to content

Commit

Permalink
feat(obsidian): use readability content when available
Browse files Browse the repository at this point in the history
  • Loading branch information
hyoban committed Oct 26, 2024
1 parent 1ea103b commit b4a3197
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 10 additions & 1 deletion apps/renderer/src/hooks/biz/useEntryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { useTranslation } from "react-i18next"
import { toast } from "sonner"

import {
getReadabilityContent,
getReadabilityStatus,
ReadabilityStatus,
setReadabilityContent,
Expand Down Expand Up @@ -425,10 +426,18 @@ export const useEntryActions = ({
onClick: () => {
if (!isObsidianEnabled || !populatedEntry?.entries?.url || !IN_ELECTRON) return

const isReadabilityReady =
getReadabilityStatus()[populatedEntry.entries.id] === ReadabilityStatus.SUCCESS
const content =
(isReadabilityReady
? getReadabilityContent()[populatedEntry.entries.id].content
: populatedEntry.entries.content) || ""
const markdownContent = parseHtml(content).toMarkdown()

saveToObsidian.mutate({
url: populatedEntry.entries.url,
title: populatedEntry.entries.title || "",
content: parseHtml(populatedEntry.entries.content || "").toMarkdown(),
content: markdownContent,
author: populatedEntry.entries.author || "",
publishedAt: populatedEntry.entries.publishedAt || "",
vaultPath: obsidianVaultPath,
Expand Down
4 changes: 1 addition & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b4a3197

Please sign in to comment.