fix footnote links
This commit is contained in:
parent
633c96d619
commit
fdf8f8e395
|
@ -214,7 +214,7 @@ export default function Comment ({
|
||||||
{item.searchText
|
{item.searchText
|
||||||
? <SearchText text={item.searchText} />
|
? <SearchText text={item.searchText} />
|
||||||
: (
|
: (
|
||||||
<Text topLevel={topLevel} nofollow={item.sats + item.boost < NOFOLLOW_LIMIT} imgproxyUrls={item.imgproxyUrls}>
|
<Text itemId={item.id} topLevel={topLevel} nofollow={item.sats + item.boost < NOFOLLOW_LIMIT} imgproxyUrls={item.imgproxyUrls}>
|
||||||
{truncate ? truncateString(item.text) : item.text}
|
{truncate ? truncateString(item.text) : item.text}
|
||||||
</Text>)}
|
</Text>)}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -171,7 +171,7 @@ function TopLevelItem ({ item, noReply, ...props }) {
|
||||||
function ItemText ({ item }) {
|
function ItemText ({ item }) {
|
||||||
return item.searchText
|
return item.searchText
|
||||||
? <SearchText text={item.searchText} />
|
? <SearchText text={item.searchText} />
|
||||||
: <Text topLevel nofollow={item.sats + item.boost < NOFOLLOW_LIMIT} imgproxyUrls={item.imgproxyUrls}>{item.text}</Text>
|
: <Text itemId={item.id} topLevel nofollow={item.sats + item.boost < NOFOLLOW_LIMIT} imgproxyUrls={item.imgproxyUrls}>{item.text}</Text>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ItemFull ({ item, bio, rank, ...props }) {
|
export default function ItemFull ({ item, bio, rank, ...props }) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import reactStringReplace from 'react-string-replace'
|
||||||
import { rehypeInlineCodeProperty } from '../lib/md'
|
import { rehypeInlineCodeProperty } from '../lib/md'
|
||||||
import { Button } from 'react-bootstrap'
|
import { Button } from 'react-bootstrap'
|
||||||
import { useRouter } from 'next/router'
|
import { useRouter } from 'next/router'
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
export function SearchText ({ text }) {
|
export function SearchText ({ text }) {
|
||||||
return (
|
return (
|
||||||
|
@ -32,7 +33,7 @@ export function SearchText ({ text }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is one of the slowest components to render
|
// this is one of the slowest components to render
|
||||||
export default memo(function Text ({ nofollow, imgproxyUrls, children, tab, ...outerProps }) {
|
export default memo(function Text ({ nofollow, imgproxyUrls, children, tab, itemId, ...outerProps }) {
|
||||||
const [overflowing, setOverflowing] = useState(false)
|
const [overflowing, setOverflowing] = useState(false)
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const [show, setShow] = useState(false)
|
const [show, setShow] = useState(false)
|
||||||
|
@ -153,6 +154,9 @@ export default memo(function Text ({ nofollow, imgproxyUrls, children, tab, ...o
|
||||||
h6: Heading,
|
h6: Heading,
|
||||||
table: Table,
|
table: Table,
|
||||||
p: P,
|
p: P,
|
||||||
|
li: props => {
|
||||||
|
return <li {...props} id={props.id && itemId ? `${props.id}-${itemId}` : props.id} />
|
||||||
|
},
|
||||||
code: Code,
|
code: Code,
|
||||||
a: ({ node, href, children, ...props }) => {
|
a: ({ node, href, children, ...props }) => {
|
||||||
children = children ? Array.isArray(children) ? children : [children] : []
|
children = children ? Array.isArray(children) ? children : [children] : []
|
||||||
|
@ -165,8 +169,19 @@ export default memo(function Text ({ nofollow, imgproxyUrls, children, tab, ...o
|
||||||
// we don't render it as an image since it was probably a conscious choice to include text.
|
// we don't render it as an image since it was probably a conscious choice to include text.
|
||||||
const text = children[0]
|
const text = children[0]
|
||||||
if (!!text && !/^https?:\/\//.test(text)) {
|
if (!!text && !/^https?:\/\//.test(text)) {
|
||||||
|
if (props['data-footnote-ref'] || typeof props['data-footnote-backref'] !== 'undefined') {
|
||||||
|
return (
|
||||||
|
<Link
|
||||||
|
{...props}
|
||||||
|
id={props.id && itemId ? `${props.id}-${itemId}` : props.id}
|
||||||
|
rel={`noreferrer ${nofollow ? 'nofollow' : ''} noopener`}
|
||||||
|
href={itemId ? `${href}-${itemId}` : href}
|
||||||
|
>{text}
|
||||||
|
</Link>
|
||||||
|
)
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<a target='_blank' rel={`noreferrer ${nofollow ? 'nofollow' : ''} noopener`} href={href}>{text}</a>
|
<a id={props.id} target='_blank' rel={`noreferrer ${nofollow ? 'nofollow' : ''} noopener`} href={href}>{text}</a>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue