feat(obsidian): use readability content when available

https://discord.com/channels/1243823539426033696/1299655969420349480
This commit is contained in:
Stephen Zhou 2024-10-26 20:33:06 +08:00
parent 1ea103b7ee
commit b4a3197e6e
No known key found for this signature in database
2 changed files with 11 additions and 4 deletions

View File

@ -19,6 +19,7 @@ import { useTranslation } from "react-i18next"
import { toast } from "sonner"
import {
getReadabilityContent,
getReadabilityStatus,
ReadabilityStatus,
setReadabilityContent,
@ -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,

View File

@ -795,8 +795,6 @@ importers:
specifier: 2.10.1
version: 2.10.1(@types/react@18.3.11)(react@18.3.1)
packages/builder: {}
packages/components:
dependencies:
'@essentials/request-timeout':
@ -3610,7 +3608,7 @@ packages:
'@radix-ui/react-slot@1.1.0':
resolution: {integrity: sha512-FUCf5XMfmW4dtYl69pdS4DbxKy8nj4M7SafBgPllysxmdachynNflAdp/gCsnYWNDnge6tI9onzMp5ARYc1KNw==}
peerDependencies:
'@types/react': '*'
'@types/react': npm:types-react@19.0.0-rc.1
react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc
peerDependenciesMeta:
'@types/react':