forked from WebMemex/webmemex-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsx
51 lines (47 loc) · 1.1 KB
/
index.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { PropTypes } from 'react'
const readerViewStyle = `
body {
margin: 80px;
font-size: 16px;
line-height: 1.5em;
}
body > main {
margin: auto;
max-width: 800px;
}
`
const pageToHTML = ({
extractedText: article,
extractedMetadata: { url } = {},
}) => `<html>
<head>
<meta charset="utf-8" />
${url ? `<link rel="canonical" href="${url}" />` : ``}
<title>💾 ${article.title}</title>
<style>
${readerViewStyle}
</style>
</head>
<body>
<main>
<h1 class="articleTitle">${article.title}</h1>
${article.content}
</main>
</body>
</html>`
export const localVersionAvailable = ({page}) => (
page.extractedText && page.extractedText.content
)
export const LinkToLocalVersion = ({page, children, ...props}) => (
<a
href={`data:text/html;charset=UTF-8,${pageToHTML(page)}`}
title='Stored text version available'
{...props}
>
{children}
</a>
)
LinkToLocalVersion.propTypes = {
page: PropTypes.object.isRequired,
children: PropTypes.node,
}