@brillout/docpress 0.14.0 → 0.15.1
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 +9 -13
- 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
|
@@ -18,7 +18,6 @@ import { autoScrollNav_SSR } from './autoScrollNav'
|
|
|
18
18
|
import { SearchLink } from './docsearch/SearchLink'
|
|
19
19
|
import { navigate } from 'vike/client/router'
|
|
20
20
|
import { css } from './utils/css'
|
|
21
|
-
import { PassThrough } from './utils/PassTrough'
|
|
22
21
|
import { Style } from './utils/Style'
|
|
23
22
|
import { cls } from './utils/cls'
|
|
24
23
|
import { iconBooks } from './icons'
|
|
@@ -282,10 +281,7 @@ const menuLinkStyle: React.CSSProperties = {
|
|
|
282
281
|
function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
283
282
|
const pageContext = usePageContext()
|
|
284
283
|
const { isLandingPage } = pageContext.conf
|
|
285
|
-
const {
|
|
286
|
-
navMaxWidth,
|
|
287
|
-
projectInfo: { projectName },
|
|
288
|
-
} = pageContext.globalContext.config.docpress
|
|
284
|
+
const { navMaxWidth, name, algolia } = pageContext.globalContext.config.docpress
|
|
289
285
|
|
|
290
286
|
const navSecondaryContent = (
|
|
291
287
|
<div
|
|
@@ -345,7 +341,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
345
341
|
maxWidth: navMaxWidth,
|
|
346
342
|
margin: 'auto',
|
|
347
343
|
height: 'var(--nav-head-height)',
|
|
348
|
-
fontSize: `min(15.2px, ${isProjectNameShort(
|
|
344
|
+
fontSize: `min(15.2px, ${isProjectNameShort(name) ? '4.8cqw' : '4.5cqw'})`,
|
|
349
345
|
color: '#666',
|
|
350
346
|
['--icon-text-padding']: 'min(8px, 1.8cqw)',
|
|
351
347
|
display: 'flex',
|
|
@@ -354,7 +350,7 @@ function NavHead({ isNavLeft }: { isNavLeft?: true }) {
|
|
|
354
350
|
>
|
|
355
351
|
<NavLogo className="grow-half" />
|
|
356
352
|
{!isNavLeft && <div className="desktop-grow" />}
|
|
357
|
-
<SearchLink className="grow-half" style={menuLinkStyle} />
|
|
353
|
+
{algolia && <SearchLink className="grow-half" style={menuLinkStyle} />}
|
|
358
354
|
<MenuToggleMain className="grow-full" style={menuLinkStyle} />
|
|
359
355
|
{navSecondaryContent}
|
|
360
356
|
</div>
|
|
@@ -487,7 +483,7 @@ function NavHeaderLeftFullWidthBackground() {
|
|
|
487
483
|
function NavLogo({ className }: { className: string }) {
|
|
488
484
|
const pageContext = usePageContext()
|
|
489
485
|
const iconSize = pageContext.globalContext.config.docpress.navLogoSize ?? 39
|
|
490
|
-
const {
|
|
486
|
+
const { name } = pageContext.globalContext.config.docpress
|
|
491
487
|
return (
|
|
492
488
|
<a
|
|
493
489
|
className={cls(['nav-logo', className])}
|
|
@@ -500,7 +496,7 @@ function NavLogo({ className }: { className: string }) {
|
|
|
500
496
|
href="/"
|
|
501
497
|
>
|
|
502
498
|
<img
|
|
503
|
-
src={pageContext.globalContext.config.docpress.
|
|
499
|
+
src={pageContext.globalContext.config.docpress.logo}
|
|
504
500
|
style={{
|
|
505
501
|
height: iconSize,
|
|
506
502
|
width: iconSize,
|
|
@@ -516,17 +512,17 @@ function NavLogo({ className }: { className: string }) {
|
|
|
516
512
|
<span
|
|
517
513
|
style={{
|
|
518
514
|
marginLeft: `calc(var(--icon-text-padding) + 2px)`,
|
|
519
|
-
fontSize: isProjectNameShort(
|
|
515
|
+
fontSize: isProjectNameShort(name) ? '1.65em' : '1.3em',
|
|
520
516
|
...pageContext.globalContext.config.docpress.navLogoTextStyle,
|
|
521
517
|
}}
|
|
522
518
|
>
|
|
523
|
-
{
|
|
519
|
+
{name}
|
|
524
520
|
</span>
|
|
525
521
|
</a>
|
|
526
522
|
)
|
|
527
523
|
}
|
|
528
|
-
function isProjectNameShort(
|
|
529
|
-
return
|
|
524
|
+
function isProjectNameShort(name: string) {
|
|
525
|
+
return name.length <= 4
|
|
530
526
|
}
|
|
531
527
|
|
|
532
528
|
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
|
+
topNavigation?: React.ReactNode;
|
|
28
|
+
globalNote?: 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
|
+
topNavigation?: React.ReactNode
|
|
35
|
+
globalNote?: React.ReactNode
|
|
37
36
|
navMaxWidth?: number
|
|
38
37
|
navLogoSize?: number
|
|
39
38
|
navLogoStyle?: React.CSSProperties
|