Add title and URL to notebook export

This commit is contained in:
Jackson Harper
2024-05-02 13:54:21 +08:00
parent 77a328eefc
commit 68e3fce61d

View File

@ -27,12 +27,24 @@ export const NotebookHeader = (props: NotebookHeaderProps) => {
const exportHighlights = useCallback(() => {
if (articleData?.article.article.highlights) {
const markdown = highlightsAsMarkdown(
let preamble = ''
if (articleData?.article.article.title) {
preamble += `## ${articleData?.article.article.title}\n`
}
if (
articleData?.article.article.contentReader == 'WEB' &&
articleData?.article.article.originalArticleUrl
) {
preamble += `URL: ${articleData?.article.article.originalArticleUrl}\n`
}
const highlights = highlightsAsMarkdown(
articleData?.article.article.highlights
)
if (markdown.length > 1) {
if (preamble.length + highlights.length > 1) {
;(async () => {
await navigator.clipboard.writeText(markdown)
await navigator.clipboard.writeText(preamble + '\n\n' + highlights)
showSuccessToast('Highlights and notes copied')
})()
} else {