@brillout/docpress 0.6.15 → 0.6.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Note.css +0 -14
- package/components/Note.tsx +7 -5
- package/css/code/block.css +24 -18
- package/package.json +2 -3
- package/renderer/onRenderHtml.tsx +1 -3
- package/parseEmojis.ts +0 -35
package/components/Note.css
CHANGED
|
@@ -47,20 +47,6 @@ blockquote.custom-icon > .blockquote-content > :first-child {
|
|
|
47
47
|
/************************/
|
|
48
48
|
/*** Icon Positioning ***/
|
|
49
49
|
/************************/
|
|
50
|
-
blockquote.type-construction img[src^="https://twemoji."]
|
|
51
|
-
{
|
|
52
|
-
margin-right: 2px;
|
|
53
|
-
}
|
|
54
|
-
blockquote.type-warning img[src^="https://twemoji."]
|
|
55
|
-
{
|
|
56
|
-
position: relative;
|
|
57
|
-
top: -1px;
|
|
58
|
-
margin-right: 2px;
|
|
59
|
-
}
|
|
60
|
-
blockquote.type-danger img[src^="https://twemoji."]
|
|
61
|
-
{
|
|
62
|
-
margin-right: 2px;
|
|
63
|
-
}
|
|
64
50
|
blockquote > p:first-child::before,
|
|
65
51
|
/* blockquote > p:first-of-type::before, */
|
|
66
52
|
blockquote > div.paragraph:first-child::before {
|
package/components/Note.tsx
CHANGED
|
@@ -51,6 +51,7 @@ function NoteGeneric({
|
|
|
51
51
|
children: React.ReactNode
|
|
52
52
|
}) {
|
|
53
53
|
assert(icon === null || icon || type, { icon, type })
|
|
54
|
+
iconMargin ??= 2
|
|
54
55
|
|
|
55
56
|
let className = 'custom-icon'
|
|
56
57
|
if (type) {
|
|
@@ -59,21 +60,20 @@ function NoteGeneric({
|
|
|
59
60
|
if (!icon && type) {
|
|
60
61
|
let classColor = ''
|
|
61
62
|
if (type === 'danger') {
|
|
62
|
-
icon = '
|
|
63
|
+
icon = '⛔'
|
|
63
64
|
classColor = 'note-color-red'
|
|
64
65
|
}
|
|
65
66
|
if (type === 'warning') {
|
|
66
|
-
icon = '
|
|
67
|
+
icon = '⚠️'
|
|
67
68
|
classColor = 'note-color-yellow'
|
|
68
69
|
}
|
|
69
70
|
if (type === 'construction') {
|
|
70
|
-
icon = '
|
|
71
|
+
icon = '🚧'
|
|
71
72
|
classColor = 'note-color-yellow'
|
|
72
73
|
}
|
|
73
74
|
if (type === 'contribution') {
|
|
74
75
|
icon = '💚'
|
|
75
76
|
classColor = 'note-color-green'
|
|
76
|
-
iconMargin = 2
|
|
77
77
|
}
|
|
78
78
|
assert(icon)
|
|
79
79
|
assert(classColor)
|
|
@@ -82,7 +82,9 @@ function NoteGeneric({
|
|
|
82
82
|
return (
|
|
83
83
|
<blockquote className={className}>
|
|
84
84
|
<div style={{ marginBottom: 20 }} />
|
|
85
|
-
|
|
85
|
+
<span style={{ fontFamily: 'emoji' }}>{icon}</span>
|
|
86
|
+
<span style={{ width: iconMargin ?? undefined, display: 'inline-block' }}></span>{' '}
|
|
87
|
+
<div className="blockquote-content">{children}</div>
|
|
86
88
|
<div style={{ marginTop: 20 }} />
|
|
87
89
|
</blockquote>
|
|
88
90
|
)
|
package/css/code/block.css
CHANGED
|
@@ -4,11 +4,6 @@ pre > code {
|
|
|
4
4
|
pre [data-line] {
|
|
5
5
|
padding: 0px 16px !important;
|
|
6
6
|
}
|
|
7
|
-
@media screen and (max-width: 900px) {
|
|
8
|
-
pre > code {
|
|
9
|
-
font-size: 0.7em;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
7
|
pre {
|
|
13
8
|
display: grid;
|
|
14
9
|
}
|
|
@@ -17,27 +12,38 @@ pre > code {
|
|
|
17
12
|
overflow-x: auto;
|
|
18
13
|
}
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
pre > code {
|
|
16
|
+
display: reset;
|
|
17
|
+
word-break: reset;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
figure[data-rehype-pretty-code-figure] {
|
|
21
|
+
margin: 0 !important;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* 821px screen width => the width of code blocks isn't shrinked anymore => no need to reduce the font-size of code blocks */
|
|
25
|
+
@media screen and (max-width: 820px) {
|
|
21
26
|
pre > code {
|
|
22
|
-
font-size: 0.
|
|
27
|
+
font-size: 0.9em !important;
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
|
-
@media screen and (max-width:
|
|
30
|
+
@media screen and (max-width: 720px) {
|
|
26
31
|
pre > code {
|
|
27
|
-
font-size: 0.8em;
|
|
32
|
+
font-size: 0.8em !important;
|
|
28
33
|
}
|
|
29
34
|
}
|
|
30
|
-
@media screen and (max-width:
|
|
35
|
+
@media screen and (max-width: 620px) {
|
|
31
36
|
pre > code {
|
|
32
|
-
font-size: 0.7em;
|
|
37
|
+
font-size: 0.7em !important;
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
|
-
|
|
36
|
-
pre > code {
|
|
37
|
-
|
|
38
|
-
|
|
40
|
+
@media screen and (max-width: 550px) {
|
|
41
|
+
pre > code {
|
|
42
|
+
font-size: 0.6em !important;
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
@media screen and (max-width: 450px) {
|
|
46
|
+
pre > code {
|
|
47
|
+
font-size: 0.5em !important;
|
|
48
|
+
}
|
|
43
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brillout/docpress",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"// Build vite.config.ts and +config.ts": "",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"rehype-pretty-code": "0.13.0",
|
|
26
26
|
"remark-gfm": "4.0.0",
|
|
27
27
|
"shiki": "1.2.0",
|
|
28
|
-
"twemoji": "13.1.1",
|
|
29
28
|
"vike-contributors": "^0.0.9"
|
|
30
29
|
},
|
|
31
30
|
"peerDependencies": {
|
|
@@ -77,7 +76,7 @@
|
|
|
77
76
|
"react": "^18.2.0",
|
|
78
77
|
"react-dom": "^18.2.0",
|
|
79
78
|
"typescript": "^5.4.3",
|
|
80
|
-
"vike": "^0.4.
|
|
79
|
+
"vike": "^0.4.180",
|
|
81
80
|
"vite": "^5.2.2"
|
|
82
81
|
},
|
|
83
82
|
"repository": "https://github.com/brillout/docpress",
|
|
@@ -6,7 +6,6 @@ import { escapeInject, dangerouslySkipEscape } from 'vike/server'
|
|
|
6
6
|
import { PageLayout } from '../PageLayout'
|
|
7
7
|
import { resolvePageContext, PageContextOriginal } from '../config/resolvePageContext'
|
|
8
8
|
import { getDocSearchJS, getDocSearchCSS } from '../algolia/DocSearch'
|
|
9
|
-
import { parseEmojis } from '../parseEmojis'
|
|
10
9
|
import { assert } from '../utils/server'
|
|
11
10
|
|
|
12
11
|
async function onRenderHtml(pageContextOriginal: PageContextOriginal) {
|
|
@@ -26,8 +25,7 @@ async function onRenderHtml(pageContextOriginal: PageContextOriginal) {
|
|
|
26
25
|
const docSearchJS = getDocSearchJS(pageContextResolved)
|
|
27
26
|
const docSearchCSS = getDocSearchCSS(pageContextResolved)
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
pageHtml = parseEmojis(pageHtml)
|
|
28
|
+
const pageHtml = ReactDOMServer.renderToString(page)
|
|
31
29
|
|
|
32
30
|
return escapeInject`<!DOCTYPE html>
|
|
33
31
|
<html>
|
package/parseEmojis.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export { parseEmojis }
|
|
2
|
-
|
|
3
|
-
import twemoji from 'twemoji'
|
|
4
|
-
|
|
5
|
-
const emojiList = {
|
|
6
|
-
// https://emojipedia.org/no-entry/
|
|
7
|
-
':no_entry:': 0x26d4,
|
|
8
|
-
// https://emojipedia.org/warning/
|
|
9
|
-
':warning:': 0x26a0,
|
|
10
|
-
// https://emojipedia.org/trophy/
|
|
11
|
-
':trophy:': 0x1f3c6,
|
|
12
|
-
// https://emojipedia.org/construction/
|
|
13
|
-
':construction:': 0x1f6a7,
|
|
14
|
-
/*
|
|
15
|
-
// https://emojipedia.org/red-heart/
|
|
16
|
-
':heart:': 0x2764,
|
|
17
|
-
*/
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function parseEmojis(html: string) {
|
|
21
|
-
Object.entries(emojiList).forEach(([shortcode, codepoint]) => {
|
|
22
|
-
if (!html.includes(shortcode)) {
|
|
23
|
-
return
|
|
24
|
-
}
|
|
25
|
-
const emojiStr = twemoji.convert.fromCodePoint(codepoint as any)
|
|
26
|
-
let emojiImg: any = twemoji.parse(emojiStr, {
|
|
27
|
-
folder: 'svg',
|
|
28
|
-
ext: '.svg',
|
|
29
|
-
})
|
|
30
|
-
const style = 'height: 1.275em; width: 1.275em; vertical-align: -20%'
|
|
31
|
-
emojiImg = emojiImg.replace('<img class="emoji" ', `<img style="${style}" `)
|
|
32
|
-
html = html.split(shortcode).join(emojiImg)
|
|
33
|
-
})
|
|
34
|
-
return html
|
|
35
|
-
}
|