Skip to content

Commit f4423c2

Browse files
authored
Fix search regression (#465)
* Fix search regression * Change “Blockquote” to “Callout” which is more semantically correct
1 parent cce9e25 commit f4423c2

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

algolia-crawler.config.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ new Crawler({
2525
selectors: '.graph-docs-current-group',
2626
defaultValue: 'The Graph Docs',
2727
},
28-
lvl1: '.graph-docs-content h1 > span:first-of-type',
29-
lvl2: '.graph-docs-content h2 > span:first-of-type',
30-
lvl3: '.graph-docs-content h3 > span:first-of-type',
31-
lvl4: '.graph-docs-content h4 > span:first-of-type',
32-
lvl5: '.graph-docs-content h5 > span:first-of-type',
33-
lvl6: '.graph-docs-content h6 > span:first-of-type',
28+
lvl1: '.graph-docs-content h1',
29+
lvl2: '.graph-docs-content h2',
30+
lvl3: '.graph-docs-content h3',
31+
lvl4: '.graph-docs-content h4',
32+
lvl5: '.graph-docs-content h5',
33+
lvl6: '.graph-docs-content h6',
3434
content: '.graph-docs-content p, .graph-docs-content li',
3535
},
3636
})

packages/nextra-theme/src/components/Blockquote.tsx renamed to packages/nextra-theme/src/components/Callout.tsx

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import { BlockquoteHTMLAttributes } from 'react'
2-
31
import { buildBorder, Spacing, Text, TextProps } from '@edgeandnode/gds'
42

5-
export type BlockquoteProps = Omit<TextProps & BlockquoteHTMLAttributes<HTMLQuoteElement>, 'color'>
3+
export type CalloutProps = Omit<TextProps, 'color'>
64

7-
export const Blockquote = ({ children, ...props }: BlockquoteProps) => {
5+
export const Callout = ({ children, ...props }: CalloutProps) => {
86
return (
97
<Text
10-
as="blockquote"
118
sx={{
129
my: Spacing['32px'],
1310
'/* emotion-disable-server-rendering-unsafe-selector-warning-please-do-not-use-this-the-warning-exists-for-a-reason */ &:nth-child(1 of :not(style))':

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

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as VisuallyHidden from '@radix-ui/react-visually-hidden'
2-
import { HTMLAttributes, useContext } from 'react'
2+
import { ElementType, useContext } from 'react'
33
import { useInView } from 'react-intersection-observer'
44
import { useDebounce } from 'react-use'
55

@@ -10,13 +10,15 @@ import { DocumentContext } from '@/layout/DocumentContext'
1010

1111
export type HeadingProps = TextProps & {
1212
level: 1 | 2 | 3 | 4 | 5 | 6
13-
} & HTMLAttributes<HTMLHeadingElement>
13+
}
1414

1515
const BaseHeading = ({ level, id, children, ...props }: HeadingProps) => {
1616
const { markOutlineItem } = useContext(DocumentContext)!
17+
1718
const { ref, inView: inOrAboveView } = useInView({
18-
rootMargin: '99999px 0px -90% 0px', // consider it "in or above view" if it's anywhere above 10% from the top of the viewport
19+
rootMargin: '99999px 0px -80% 0px', // consider it "in or above view" if it's anywhere above 20% from the top of the viewport
1920
})
21+
2022
useDebounce(
2123
() => {
2224
if (id) {
@@ -26,17 +28,20 @@ const BaseHeading = ({ level, id, children, ...props }: HeadingProps) => {
2628
100,
2729
[id, inOrAboveView, markOutlineItem],
2830
)
31+
32+
const Heading: ElementType = `h${level}`
33+
2934
const { t } = useI18n<any>()
3035

3136
return (
32-
<Text ref={ref} as={`h${level}`} id={id} weight="SEMIBOLD" color="White" {...props}>
33-
{children}
37+
<Text ref={ref} id={id} weight="SEMIBOLD" color="White" {...props}>
38+
<Heading sx={{ display: 'inline' }}>{children}</Heading>
3439
{id ? (
3540
<span
3641
sx={{
3742
marginInlineStart: '0.35em',
3843
opacity: Opacity['0%'],
39-
[`h${level}:hover &, &:focus-within`]: { opacity: Opacity['100%'] },
44+
[`*:hover > &, &:focus-within`]: { opacity: Opacity['100%'] },
4045
transition: buildTransition('OPACITY'),
4146
}}
4247
>

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

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { HTMLAttributes } from 'react'
2-
31
import { Spacing, Text, TextProps } from '@edgeandnode/gds'
42

5-
export type ParagraphProps = Omit<TextProps & HTMLAttributes<HTMLParagraphElement>, 'color'>
3+
export type ParagraphProps = Omit<TextProps, 'color'>
64

75
export const Paragraph = ({ children, ...props }: ParagraphProps) => {
86
return (

packages/nextra-theme/src/components/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export * from './Blockquote'
1+
export * from './Callout'
22
export * from './Code'
33
export * from './Difficulty'
44
export * from './DocSearch'

packages/nextra-theme/src/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { Divider, DividerProps, Flex, Icon, Spacing, useI18n } from '@edgeandnod
1212
import { NPSForm } from '@edgeandnode/organisms'
1313

1414
import {
15-
Blockquote,
15+
Callout,
1616
CodeBlock,
1717
CodeInline,
1818
Difficulty,
@@ -30,7 +30,7 @@ import {
3030
import { DocumentContext, MDXLayoutNav, MDXLayoutOutline, MDXLayoutPagination, NavContext } from '@/layout'
3131

3232
const mdxComponents = {
33-
blockquote: Blockquote,
33+
blockquote: Callout,
3434
pre: CodeBlock,
3535
code: CodeInline,
3636
hr: (props: DividerProps) => <Divider sx={{ my: Spacing['32px'] }} {...props} />,

0 commit comments

Comments
 (0)