@brillout/docpress 0.14.0 → 0.15.0
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/ExternalLinks.tsx +8 -16
- package/Layout.tsx +8 -11
- package/components/RepoLink.tsx +2 -3
- package/dist/components/RepoLink.js +2 -3
- package/dist/resolveConf.js +1 -1
- package/dist/types/Config.d.ts +19 -25
- package/package.json +1 -1
- package/renderer/onRenderHtml.tsx +10 -13
- package/resolveConf.ts +1 -1
- package/types/Config.ts +24 -25
package/ExternalLinks.tsx
CHANGED
|
@@ -12,7 +12,7 @@ import '@docsearch/css'
|
|
|
12
12
|
|
|
13
13
|
function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
14
14
|
const pageContext = usePageContext()
|
|
15
|
-
const {
|
|
15
|
+
const { github, discord, bluesky, i18n, twitter } = pageContext.globalContext.config.docpress
|
|
16
16
|
const iconI18n = !i18n ? null : (
|
|
17
17
|
<LinkIcon
|
|
18
18
|
className="decolorize-4"
|
|
@@ -31,18 +31,10 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
|
31
31
|
}}
|
|
32
32
|
>
|
|
33
33
|
{iconI18n}
|
|
34
|
-
{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<LinkIcon className="decolorize-4" icon={
|
|
38
|
-
{projectInfo.blueskyHandle && (
|
|
39
|
-
<LinkIcon
|
|
40
|
-
className="decolorize-6"
|
|
41
|
-
icon={iconBluesky}
|
|
42
|
-
href={`https://bsky.app/profile/${projectInfo.blueskyHandle}`}
|
|
43
|
-
/>
|
|
44
|
-
)}
|
|
45
|
-
<LinkIcon className="decolorize-4" icon={iconGithub} href={projectInfo.githubRepository} />
|
|
34
|
+
{discord && <LinkIcon className="decolorize-6" icon={iconDiscord} href={discord} />}
|
|
35
|
+
{twitter && <LinkIcon className="decolorize-4" icon={iconTwitter} href={`https://x.com/${twitter.slice(1)}`} />}
|
|
36
|
+
{bluesky && <LinkIcon className="decolorize-6" icon={iconBluesky} href={`https://bsky.app/profile/${bluesky}`} />}
|
|
37
|
+
<LinkIcon className="decolorize-4" icon={iconGithub} href={github} />
|
|
46
38
|
<ChangelogButton />
|
|
47
39
|
</div>
|
|
48
40
|
)
|
|
@@ -50,10 +42,10 @@ function ExternalLinks(props: { style?: React.CSSProperties }) {
|
|
|
50
42
|
|
|
51
43
|
function ChangelogButton() {
|
|
52
44
|
const pageContext = usePageContext()
|
|
53
|
-
const {
|
|
45
|
+
const { version, github } = pageContext.globalContext.config.docpress
|
|
54
46
|
return (
|
|
55
47
|
<a
|
|
56
|
-
href={`${
|
|
48
|
+
href={`${github}/blob/main/CHANGELOG.md`}
|
|
57
49
|
className="colorize-on-hover"
|
|
58
50
|
style={{
|
|
59
51
|
display: 'flex',
|
|
@@ -72,7 +64,7 @@ function ChangelogButton() {
|
|
|
72
64
|
}}
|
|
73
65
|
>
|
|
74
66
|
<span id="version-number" className="decolorize-7">
|
|
75
|
-
v{
|
|
67
|
+
v{version}
|
|
76
68
|
</span>
|
|
77
69
|
<img className="decolorize-6" src={iconChangelog} height={16} style={{ marginLeft: 6 }} />
|
|
78
70
|
</div>
|
package/Layout.tsx
CHANGED
|
@@ -282,10 +282,7 @@ const menuLinkStyle: React.CSSProperties = {
|
|
|
282
282
|
function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
283
283
|
const pageContext = usePageContext()
|
|
284
284
|
const { isLandingPage } = pageContext.conf
|
|
285
|
-
const {
|
|
286
|
-
navMaxWidth,
|
|
287
|
-
projectInfo: { projectName },
|
|
288
|
-
} = pageContext.globalContext.config.docpress
|
|
285
|
+
const { navMaxWidth, name } = pageContext.globalContext.config.docpress
|
|
289
286
|
|
|
290
287
|
const navSecondaryContent = (
|
|
291
288
|
<div
|
|
@@ -345,7 +342,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
345
342
|
maxWidth: navMaxWidth,
|
|
346
343
|
margin: 'auto',
|
|
347
344
|
height: 'var(--nav-head-height)',
|
|
348
|
-
fontSize: `min(15.2px, ${isProjectNameShort(
|
|
345
|
+
fontSize: `min(15.2px, ${isProjectNameShort(name) ? '4.8cqw' : '4.5cqw'})`,
|
|
349
346
|
color: '#666',
|
|
350
347
|
['--icon-text-padding']: 'min(8px, 1.8cqw)',
|
|
351
348
|
display: 'flex',
|
|
@@ -487,7 +484,7 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
487
484
|
function NavLogo({ className }: { className: string }) {
|
|
488
485
|
const pageContext = usePageContext()
|
|
489
486
|
const iconSize = pageContext.globalContext.config.docpress.navLogoSize ?? 39
|
|
490
|
-
const {
|
|
487
|
+
const { name } = pageContext.globalContext.config.docpress
|
|
491
488
|
return (
|
|
492
489
|
<a
|
|
493
490
|
className={cls(['nav-logo', className])}
|
|
@@ -500,7 +497,7 @@ function NavLogo({ className }: { className: string }) {
|
|
|
500
497
|
href="/"
|
|
501
498
|
>
|
|
502
499
|
<img
|
|
503
|
-
src={pageContext.globalContext.config.docpress.
|
|
500
|
+
src={pageContext.globalContext.config.docpress.logo}
|
|
504
501
|
style={{
|
|
505
502
|
height: iconSize,
|
|
506
503
|
width: iconSize,
|
|
@@ -516,17 +513,17 @@ function NavLogo({ className }: { className: string }) {
|
|
|
516
513
|
<span
|
|
517
514
|
style={{
|
|
518
515
|
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
519
|
-
fontSize: isProjectNameShort(
|
|
516
|
+
fontSize: isProjectNameShort(name) ? '1.65em' : '1.3em',
|
|
520
517
|
...pageContext.globalContext.config.docpress.navLogoTextStyle,
|
|
521
518
|
}}
|
|
522
519
|
>
|
|
523
|
-
{
|
|
520
|
+
{name}
|
|
524
521
|
</span>
|
|
525
522
|
</a>
|
|
526
523
|
)
|
|
527
524
|
}
|
|
528
|
-
function isProjectNameShort(
|
|
529
|
-
return
|
|
525
|
+
function isProjectNameShort(name: string) {
|
|
526
|
+
return name.length <= 4
|
|
530
527
|
}
|
|
531
528
|
|
|
532
529
|
let onMouseIgnore: ReturnType<typeof setTimeout> | undefined
|
package/components/RepoLink.tsx
CHANGED
|
@@ -24,9 +24,8 @@ function getRepoHref(path: string, editMode = false) {
|
|
|
24
24
|
path = '/' + path
|
|
25
25
|
}
|
|
26
26
|
const viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob'
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
let href = `${githubRepository}/${viewMode}/main${path}`
|
|
27
|
+
const { github } = pageContext.globalContext.config.docpress
|
|
28
|
+
let href = `${github}/${viewMode}/main${path}`
|
|
30
29
|
if (editMode) href += '?plain=1'
|
|
31
30
|
return href
|
|
32
31
|
}
|
|
@@ -22,9 +22,8 @@ function getRepoHref(path, editMode) {
|
|
|
22
22
|
path = '/' + path;
|
|
23
23
|
}
|
|
24
24
|
var viewMode = path.endsWith('/') && !editMode ? 'tree' : 'blob';
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
var href = "".concat(githubRepository, "/").concat(viewMode, "/main").concat(path);
|
|
25
|
+
var github = pageContext.globalContext.config.docpress.github;
|
|
26
|
+
var href = "".concat(github, "/").concat(viewMode, "/main").concat(path);
|
|
28
27
|
if (editMode)
|
|
29
28
|
href += '?plain=1';
|
|
30
29
|
return href;
|
package/dist/resolveConf.js
CHANGED
|
@@ -114,7 +114,7 @@ function getTitles(activeHeading, urlPathname, config) {
|
|
|
114
114
|
var pageTitle = isLandingPage ? null : title;
|
|
115
115
|
var documentTitle = activeHeading.titleDocument || jsxToTextContent(parseMarkdownMini(title));
|
|
116
116
|
if (!isLandingPage) {
|
|
117
|
-
documentTitle += ' | ' + config.
|
|
117
|
+
documentTitle += ' | ' + config.name;
|
|
118
118
|
}
|
|
119
119
|
if (isLandingPage) {
|
|
120
120
|
pageTitle = null;
|
package/dist/types/Config.d.ts
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
1
|
export type { Config };
|
|
2
2
|
import type { HeadingDefinition, HeadingDetachedDefinition } from './Heading';
|
|
3
3
|
type Config = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
url: string;
|
|
7
|
+
/** Sets `<meta name="description" content="${tagline}" />` */
|
|
8
|
+
tagline: string;
|
|
9
|
+
logo: string;
|
|
10
|
+
favicon?: string;
|
|
11
|
+
banner?: string;
|
|
12
|
+
github: string;
|
|
13
|
+
discord?: string;
|
|
14
|
+
twitter?: string;
|
|
15
|
+
bluesky?: string;
|
|
16
|
+
headings: HeadingDefinition[];
|
|
17
|
+
headingsDetached: HeadingDetachedDefinition[];
|
|
18
|
+
categories?: Category[];
|
|
19
|
+
algolia?: {
|
|
18
20
|
appId: string;
|
|
19
21
|
apiKey: string;
|
|
20
22
|
indexName: string;
|
|
21
23
|
};
|
|
22
|
-
headings: HeadingDefinition[];
|
|
23
|
-
headingsDetached: HeadingDetachedDefinition[];
|
|
24
|
-
categories?: Category[];
|
|
25
|
-
/** Sets `<meta name="description" content="${tagline}" />` */
|
|
26
|
-
tagline: string;
|
|
27
|
-
websiteUrl: string;
|
|
28
|
-
bannerUrl?: string;
|
|
29
|
-
twitterHandle: string;
|
|
30
|
-
globalNote?: React.ReactNode;
|
|
31
|
-
topNavigation?: React.ReactNode;
|
|
32
24
|
i18n?: true;
|
|
33
25
|
pressKit?: true;
|
|
34
|
-
|
|
26
|
+
docsDir?: string;
|
|
27
|
+
globalNote?: React.ReactNode;
|
|
28
|
+
topNavigation?: React.ReactNode;
|
|
35
29
|
navMaxWidth?: number;
|
|
36
30
|
navLogoSize?: number;
|
|
37
31
|
navLogoStyle?: React.CSSProperties;
|
package/package.json
CHANGED
|
@@ -2,9 +2,10 @@ export { onRenderHtml }
|
|
|
2
2
|
|
|
3
3
|
import ReactDOMServer from 'react-dom/server'
|
|
4
4
|
import { escapeInject, dangerouslySkipEscape } from 'vike/server'
|
|
5
|
-
import { assert } from '../utils/server'
|
|
5
|
+
import { assert, assertUsage } from '../utils/server'
|
|
6
6
|
import { getPageElement } from './getPageElement'
|
|
7
7
|
import type { PageContextServer } from 'vike/types'
|
|
8
|
+
import type { Config } from '../types/Config'
|
|
8
9
|
|
|
9
10
|
async function onRenderHtml(pageContext: PageContextServer): Promise<any> {
|
|
10
11
|
const page = getPageElement(pageContext)
|
|
@@ -17,8 +18,7 @@ async function onRenderHtml(pageContext: PageContextServer): Promise<any> {
|
|
|
17
18
|
|
|
18
19
|
const pageHtml = ReactDOMServer.renderToString(page)
|
|
19
20
|
|
|
20
|
-
const faviconUrl =
|
|
21
|
-
pageContext.globalContext.config.docpress.faviconUrl ?? pageContext.globalContext.config.docpress.logoUrl
|
|
21
|
+
const faviconUrl = pageContext.globalContext.config.docpress.favicon ?? pageContext.globalContext.config.docpress.logo
|
|
22
22
|
assert(faviconUrl)
|
|
23
23
|
|
|
24
24
|
const { documentTitle } = pageContext.conf
|
|
@@ -72,24 +72,21 @@ function getActiveCategory(pageContext: PageContextServer) {
|
|
|
72
72
|
return activeCategory
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
function getOpenGraphTags(
|
|
76
|
-
url:
|
|
77
|
-
documentTitle: string,
|
|
78
|
-
meta: { tagline: string; websiteUrl: string; twitterHandle: string; bannerUrl?: string },
|
|
79
|
-
) {
|
|
80
|
-
const { tagline, websiteUrl, twitterHandle, bannerUrl } = meta
|
|
75
|
+
function getOpenGraphTags(url: string, documentTitle: string, config: Config) {
|
|
76
|
+
const { tagline, url: websiteUrl, twitter, banner } = config
|
|
81
77
|
assert(url.startsWith('/'))
|
|
78
|
+
assertUsage(!twitter || twitter.startsWith('@'), `twitter handle must start with @`)
|
|
82
79
|
|
|
83
|
-
const metaBanner = !
|
|
80
|
+
const metaBanner = !banner
|
|
84
81
|
? ''
|
|
85
82
|
: escapeInject`
|
|
86
|
-
<meta property="og:image" content="${
|
|
83
|
+
<meta property="og:image" content="${banner}">
|
|
87
84
|
<meta name="twitter:card" content="summary_large_image">
|
|
88
85
|
`
|
|
89
|
-
const metaTwitter = !
|
|
86
|
+
const metaTwitter = !twitter
|
|
90
87
|
? ''
|
|
91
88
|
: escapeInject`
|
|
92
|
-
<meta name="twitter:site" content="${
|
|
89
|
+
<meta name="twitter:site" content="${twitter}">
|
|
93
90
|
`
|
|
94
91
|
// See view-source:https://vitejs.dev/
|
|
95
92
|
return escapeInject`
|
package/resolveConf.ts
CHANGED
|
@@ -133,7 +133,7 @@ function getTitles(activeHeading: HeadingResolved | HeadingDetachedResolved, url
|
|
|
133
133
|
let documentTitle = activeHeading.titleDocument || jsxToTextContent(parseMarkdownMini(title))
|
|
134
134
|
|
|
135
135
|
if (!isLandingPage) {
|
|
136
|
-
documentTitle += ' | ' + config.
|
|
136
|
+
documentTitle += ' | ' + config.name
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
if (isLandingPage) {
|
package/types/Config.ts
CHANGED
|
@@ -3,37 +3,36 @@ export type { Config }
|
|
|
3
3
|
import type { HeadingDefinition, HeadingDetachedDefinition } from './Heading'
|
|
4
4
|
|
|
5
5
|
type Config = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
name: string
|
|
7
|
+
version: string
|
|
8
|
+
url: string
|
|
9
|
+
/** Sets `<meta name="description" content="${tagline}" />` */
|
|
10
|
+
tagline: string
|
|
11
|
+
logo: string
|
|
12
|
+
favicon?: string
|
|
13
|
+
banner?: string
|
|
14
|
+
|
|
15
|
+
github: string
|
|
16
|
+
discord?: string
|
|
17
|
+
twitter?: string
|
|
18
|
+
bluesky?: string
|
|
19
|
+
|
|
20
|
+
headings: HeadingDefinition[]
|
|
21
|
+
headingsDetached: HeadingDetachedDefinition[]
|
|
22
|
+
categories?: Category[]
|
|
23
|
+
|
|
24
|
+
algolia?: {
|
|
20
25
|
appId: string
|
|
21
26
|
apiKey: string
|
|
22
27
|
indexName: string
|
|
23
28
|
}
|
|
24
|
-
|
|
25
|
-
headingsDetached: HeadingDetachedDefinition[]
|
|
26
|
-
categories?: Category[]
|
|
27
|
-
/** Sets `<meta name="description" content="${tagline}" />` */
|
|
28
|
-
tagline: string
|
|
29
|
-
websiteUrl: string
|
|
30
|
-
bannerUrl?: string
|
|
31
|
-
twitterHandle: string
|
|
32
|
-
globalNote?: React.ReactNode
|
|
33
|
-
topNavigation?: React.ReactNode
|
|
29
|
+
|
|
34
30
|
i18n?: true
|
|
35
31
|
pressKit?: true
|
|
36
|
-
|
|
32
|
+
docsDir?: string
|
|
33
|
+
|
|
34
|
+
globalNote?: React.ReactNode
|
|
35
|
+
topNavigation?: React.ReactNode
|
|
37
36
|
navMaxWidth?: number
|
|
38
37
|
navLogoSize?: number
|
|
39
38
|
navLogoStyle?: React.CSSProperties
|