Skip to content

Commit 67849f7

Browse files
committed
Add prebuild
1 parent e3a1eb0 commit 67849f7

File tree

11 files changed

+90
-121
lines changed

11 files changed

+90
-121
lines changed

packages/nextra-theme/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"typecheck": "tsc --noEmit"
2626
},
2727
"peerDependencies": {
28-
"@edgeandnode/gds": "^2.6.12",
28+
"@edgeandnode/gds": "2.7.0-nps-1689105142616-64ec6ac",
2929
"@emotion/react": "^11.10.6",
3030
"next": "^13.4.5",
3131
"next-seo": "^5.15.0",
@@ -38,12 +38,11 @@
3838
"@radix-ui/react-collapsible": "^1.0.3",
3939
"@radix-ui/react-visually-hidden": "^1.0.3",
4040
"lodash": "^4.17.21",
41-
"prism-react-renderer": "^1.3.5",
4241
"react-intersection-observer": "^9.5.2",
4342
"react-use": "^17.4.0"
4443
},
4544
"devDependencies": {
46-
"@edgeandnode/gds": "^2.6.12",
45+
"@edgeandnode/gds": "2.7.0-nps-1689105142616-64ec6ac",
4746
"@emotion/react": "^11.11.1",
4847
"@types/lodash": "^4.14.195",
4948
"@types/react": "^18.2.14",

packages/nextra-theme/src/components/Blockquote.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const Blockquote = ({ children, ...props }: BlockquoteProps) => {
1010
as="blockquote"
1111
sx={{
1212
my: Spacing['32px'],
13+
'&:nth-child(1 of :not(style))': { mt: 0 },
14+
'&:nth-last-child(1 of :not(style))': { mb: 0 },
1315
p: Spacing['24px'],
1416
borderInlineStart: buildBorder('Purple', '4px'),
1517
bg: 'Purple8',
Lines changed: 31 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,48 @@
1-
import Highlight, { defaultProps, Language, PrismTheme } from 'prism-react-renderer'
2-
import { HTMLAttributes } from 'react'
1+
import { HTMLAttributes, ReactNode } from 'react'
32

4-
import { BorderRadius, FontFamily, Spacing } from '@edgeandnode/gds'
3+
import { Code, Spacing } from '@edgeandnode/gds'
54

6-
export type CodeBlockProps = HTMLAttributes<HTMLPreElement>
5+
export type CodeBlockProps = {
6+
children?:
7+
| ReactNode
8+
| {
9+
props: {
10+
children: string
11+
className?: string
12+
}
13+
}
14+
} & Omit<HTMLAttributes<HTMLPreElement>, 'children'>
715
export type CodeInlineProps = HTMLAttributes<HTMLElement>
816

9-
import theme from 'prism-react-renderer/themes/duotoneDark'
10-
1117
export const CodeBlock = ({ children, ...props }: CodeBlockProps) => {
12-
const data = (
13-
children as {
14-
props: {
15-
children: string
16-
className?: string
17-
}
18-
}
19-
).props
20-
const code = data.children.trim()
21-
let language = data.className?.substring('language-'.length)
18+
const code =
19+
children && typeof children === 'object' && 'props' in children
20+
? children.props.children.trim()
21+
: (children as string)
22+
let language =
23+
children && typeof children === 'object' && 'props' in children
24+
? children.props.className?.substring('language-'.length)
25+
: null
2226

2327
if (!language || language === 'sh') {
2428
language = 'bash'
2529
}
2630

2731
return (
28-
<div sx={{ my: Spacing['24px'] }}>
29-
<Highlight {...defaultProps} code={code} language={language as Language} theme={theme}>
30-
{({ className, tokens, getLineProps, getTokenProps }) => (
31-
<pre
32-
className={className}
33-
sx={{
34-
overflowX: 'auto',
35-
p: Spacing['16px'],
36-
borderRadius: BorderRadius.M,
37-
border: 'White4',
38-
bg: 'White4',
39-
fontFamily: FontFamily.MONOSPACE,
40-
fontSize: '16px',
41-
lineHeight: '24px',
42-
}}
43-
{...props}
44-
>
45-
{tokens.map((line, i) => (
46-
// eslint-disable-next-line react/jsx-key
47-
<div {...getLineProps({ line, key: i })}>
48-
{line.map((token, key) => (
49-
// eslint-disable-next-line react/jsx-key
50-
<span {...getTokenProps({ token, key })} />
51-
))}
52-
</div>
53-
))}
54-
</pre>
55-
)}
56-
</Highlight>
57-
</div>
58-
)
59-
}
60-
61-
export const CodeInline = ({ children, ...props }: CodeInlineProps) => {
62-
return (
63-
<code
32+
<Code.Block
33+
language={language}
6434
sx={{
65-
px: Spacing['4px'],
66-
py: Spacing['2px'],
67-
borderRadius: BorderRadius.S,
68-
border: 'White4',
69-
bg: 'White4',
70-
fontFamily: FontFamily.MONOSPACE,
71-
fontSize: '0.75em',
35+
my: Spacing['24px'],
36+
'&:nth-child(1 of :not(style))': { mt: 0 },
37+
'&:nth-last-child(1 of :not(style))': { mb: 0 },
7238
}}
7339
{...props}
7440
>
75-
{children}
76-
</code>
41+
{code}
42+
</Code.Block>
7743
)
7844
}
45+
46+
export const CodeInline = ({ children, ...props }: CodeInlineProps) => {
47+
return <Code.Inline {...props}>{children as string}</Code.Inline>
48+
}
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,35 @@
11
import { HTMLAttributes } from 'react'
22

3-
import { Spacing, Text, TextProps } from '@edgeandnode/gds'
3+
import { List, Spacing } from '@edgeandnode/gds'
44

5-
export type ListProps = Omit<
6-
Omit<TextProps, 'as'> & {
7-
as: 'ol' | 'ul'
8-
} & HTMLAttributes<HTMLElement>,
9-
'color'
10-
>
11-
12-
export type ListSpecificProps = Omit<ListProps, 'as'>
13-
14-
export const List = ({ as, children, ...props }: ListProps) => {
5+
export const ListOrdered = (props: HTMLAttributes<HTMLOListElement>) => {
156
return (
16-
<Text
17-
as={as}
18-
size="18px"
7+
<List.Numbers
198
sx={{
209
mt: Spacing['16px'],
2110
mb: Spacing['24px'],
22-
paddingInlineStart: Spacing['32px'],
23-
listStyleType: as === 'ol' ? 'decimal' : 'disc',
24-
'& > li': {
25-
display: 'list-item',
26-
my: Spacing['16px'],
27-
},
11+
'&:nth-child(1 of :not(style))': { mt: 0 },
12+
'&:nth-last-child(1 of :not(style))': { mb: 0 },
2813
}}
2914
{...props}
30-
>
31-
{children}
32-
</Text>
15+
/>
3316
)
3417
}
3518

36-
export const ListOrdered = (props: ListSpecificProps) => {
37-
return <List as="ol" {...props} />
19+
export const ListUnordered = (props: HTMLAttributes<HTMLUListElement>) => {
20+
return (
21+
<List.Arrows
22+
sx={{
23+
mt: Spacing['16px'],
24+
mb: Spacing['24px'],
25+
'&:nth-child(1 of :not(style))': { mt: 0 },
26+
'&:nth-last-child(1 of :not(style))': { mb: 0 },
27+
}}
28+
{...props}
29+
/>
30+
)
3831
}
3932

40-
export const ListUnordered = (props: ListSpecificProps) => {
41-
return <List as="ul" {...props} />
33+
export const ListItem = (props: HTMLAttributes<HTMLLIElement>) => {
34+
return <List.Item {...props} />
4235
}

packages/nextra-theme/src/components/NavTree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export type NavTreeHeadingProps = HTMLAttributes<HTMLElement>
3939
const NavTree = ({ children, textProps, ...props }: NavTreeProps) => {
4040
return (
4141
<Flex.Column as="nav" {...props}>
42-
<Text weight="SEMIBOLD" size="14px" as="ul" {...textProps}>
42+
<Text as="ul" weight="SEMIBOLD" size="14px" {...textProps}>
4343
{children}
4444
</Text>
4545
</Flex.Column>

packages/nextra-theme/src/components/Paragraph.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ export const Paragraph = ({ children, ...props }: ParagraphProps) => {
1010
sx={{
1111
mt: Spacing['16px'],
1212
mb: Spacing['24px'],
13-
'&:first-of-type': { mt: 0 },
14-
'&:last-child': { mb: 0 },
13+
'&:nth-child(1 of :not(style))': { mt: 0 },
14+
'&:nth-last-child(1 of :not(style))': { mb: 0 },
1515
}}
1616
{...props}
1717
>

packages/nextra-theme/src/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
Image,
2121
Link,
2222
LinkInline,
23+
ListItem,
2324
ListOrdered,
2425
ListUnordered,
2526
Paragraph,
@@ -41,15 +42,16 @@ const mdxComponents = {
4142
h6: Heading.H6,
4243
img: Image,
4344
a: LinkInline,
45+
li: ListItem,
4446
ol: ListOrdered,
4547
ul: ListUnordered,
4648
p: Paragraph,
4749
table: Table,
48-
VideoEmbed,
49-
Difficulty,
5050
CodeInline,
51+
Difficulty,
5152
ListUnordered,
5253
Table,
54+
VideoEmbed,
5355
}
5456

5557
const mdxStyles: ThemeUIStyleObject = {

pnpm-lock.yaml

Lines changed: 15 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/next.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ const env = {
55
ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY,
66
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID,
77
MIXPANEL_TOKEN:
8-
process.env.ENVIRONMENT === 'production' ? 'cfeac8baf33c9b4d255f28d57f3c9148' : 'e57a9892339b2acfd02943c86b746d32',
8+
process.env.NODE_ENV === 'production'
9+
? process.env.ENVIRONMENT === 'production'
10+
? 'cfeac8baf33c9b4d255f28d57f3c9148' // production
11+
: 'e57a9892339b2acfd02943c86b746d32' // staging
12+
: null, // local dev (no tracking)
913
}
1014

1115
const withNextra = nextra({

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"export": "rm -rf out && next export -o ../out/docs",
1010
"fetch-remote-filepaths": "tsx scripts/fetch-remote-filepaths.ts",
1111
"postbuild": "next-sitemap --config next-sitemap.config.cjs && node scripts/sitemap-ci.js",
12+
"prebuild": "pnpm fetch-remote-filepaths",
1213
"predev": "pnpm fetch-remote-filepaths",
1314
"start": "next start",
1415
"typecheck": "tsc --noEmit"

0 commit comments

Comments
 (0)