@brillout/docpress 0.6.14 → 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.
@@ -18,6 +18,22 @@ blockquote.note-color-yellow {
18
18
  --color-strengh-border: 8;
19
19
  --color: 255, 204, 50;
20
20
  }
21
+ blockquote.note-color-green {
22
+ --color-strengh-bg: 4;
23
+ --color-strengh-border: 4;
24
+ --color: 000, 204, 50;
25
+ border-left-color: rgb(0, 179, 0, 0.3);
26
+ background-color: rgb(0, 179, 0, 0.08);
27
+ }
28
+ /*
29
+ blockquote.note-color-pink {
30
+ --color-strengh-bg: 4;
31
+ --color-strengh-border: 4;
32
+ --color: 000, 204, 50;
33
+ border-left-color: rgb(255, 0, 100, 0.3);
34
+ background-color: rgb(255, 0, 100, 0.1);
35
+ }
36
+ */
21
37
  .blockquote-content {
22
38
  display: inline;
23
39
  }
@@ -31,20 +47,6 @@ blockquote.custom-icon > .blockquote-content > :first-child {
31
47
  /************************/
32
48
  /*** Icon Positioning ***/
33
49
  /************************/
34
- blockquote.type-construction img[src^="https://twemoji."]
35
- {
36
- margin-right: 2px;
37
- }
38
- blockquote.type-warning img[src^="https://twemoji."]
39
- {
40
- position: relative;
41
- top: -1px;
42
- margin-right: 2px;
43
- }
44
- blockquote.type-danger img[src^="https://twemoji."]
45
- {
46
- margin-right: 2px;
47
- }
48
50
  blockquote > p:first-child::before,
49
51
  /* blockquote > p:first-of-type::before, */
50
52
  blockquote > div.paragraph:first-child::before {
@@ -1,5 +1,6 @@
1
1
  export { Warning }
2
2
  export { Construction }
3
+ export { Contribution }
3
4
  export { Danger }
4
5
  export { NoteWithoutIcon }
5
6
  export { NoteWithCustomIcon }
@@ -23,6 +24,9 @@ function Warning({ children }: { children: React.ReactNode }) {
23
24
  function Construction({ children }: { children: React.ReactNode }) {
24
25
  return <NoteGeneric type="construction">{children}</NoteGeneric>
25
26
  }
27
+ function Contribution({ children }: { children: React.ReactNode }) {
28
+ return <NoteGeneric type="contribution">{children}</NoteGeneric>
29
+ }
26
30
  function Danger({ children }: { children: React.ReactNode }) {
27
31
  return <NoteGeneric type="danger">{children}</NoteGeneric>
28
32
  }
@@ -38,13 +42,16 @@ function NoteWithCustomIcon({ icon, children }: { children: React.ReactNode; ico
38
42
  function NoteGeneric({
39
43
  type,
40
44
  icon,
45
+ iconMargin,
41
46
  children,
42
47
  }: {
43
48
  icon?: null | CustomIcon
44
- type?: 'danger' | 'warning' | 'construction'
49
+ iconMargin?: null | number
50
+ type?: 'danger' | 'warning' | 'construction' | 'contribution'
45
51
  children: React.ReactNode
46
52
  }) {
47
53
  assert(icon === null || icon || type, { icon, type })
54
+ iconMargin ??= 2
48
55
 
49
56
  let className = 'custom-icon'
50
57
  if (type) {
@@ -53,17 +60,21 @@ function NoteGeneric({
53
60
  if (!icon && type) {
54
61
  let classColor = ''
55
62
  if (type === 'danger') {
56
- icon = ':no_entry:'
63
+ icon = ''
57
64
  classColor = 'note-color-red'
58
65
  }
59
66
  if (type === 'warning') {
60
- icon = ':warning:'
67
+ icon = '⚠️'
61
68
  classColor = 'note-color-yellow'
62
69
  }
63
70
  if (type === 'construction') {
64
- icon = ':construction:'
71
+ icon = '🚧'
65
72
  classColor = 'note-color-yellow'
66
73
  }
74
+ if (type === 'contribution') {
75
+ icon = '💚'
76
+ classColor = 'note-color-green'
77
+ }
67
78
  assert(icon)
68
79
  assert(classColor)
69
80
  className = `${className} ${classColor}`
@@ -71,7 +82,9 @@ function NoteGeneric({
71
82
  return (
72
83
  <blockquote className={className}>
73
84
  <div style={{ marginBottom: 20 }} />
74
- {icon} <div className="blockquote-content">{children}</div>
85
+ <span style={{ fontFamily: 'emoji' }}>{icon}</span>
86
+ <span style={{ width: iconMargin ?? undefined, display: 'inline-block' }}></span>{' '}
87
+ <div className="blockquote-content">{children}</div>
75
88
  <div style={{ marginTop: 20 }} />
76
89
  </blockquote>
77
90
  )
@@ -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
- @media screen and (max-width: 1139px) {
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.95em;
27
+ font-size: 0.9em !important;
23
28
  }
24
29
  }
25
- @media screen and (max-width: 1040px) {
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: 940px) {
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
- display: reset;
38
- word-break: reset;
40
+ @media screen and (max-width: 550px) {
41
+ pre > code {
42
+ font-size: 0.6em !important;
43
+ }
39
44
  }
40
-
41
- figure[data-rehype-pretty-code-figure] {
42
- margin: 0 !important;
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.14",
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.174",
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
- let pageHtml = ReactDOMServer.renderToString(page)
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
- }