Remove #tag linkifying
This commit is contained in:
parent
e2763f3dce
commit
60d52aa900
|
@ -2,8 +2,7 @@ import clsx from 'clsx'
|
||||||
import { Fragment } from 'react'
|
import { Fragment } from 'react'
|
||||||
import { SiteLink } from './site-link'
|
import { SiteLink } from './site-link'
|
||||||
|
|
||||||
// Return a JSX span, linkifying @username, #hashtags, and https://...
|
// Return a JSX span, linkifying @username, and https://...
|
||||||
// TODO: Use a markdown parser instead of rolling our own here.
|
|
||||||
export function Linkify(props: {
|
export function Linkify(props: {
|
||||||
text: string
|
text: string
|
||||||
className?: string
|
className?: string
|
||||||
|
@ -16,7 +15,7 @@ export function Linkify(props: {
|
||||||
|
|
||||||
// Find instances of @username, #hashtag, and https://...
|
// Find instances of @username, #hashtag, and https://...
|
||||||
const regex =
|
const regex =
|
||||||
/(?:^|\s)(?:[@#][a-z0-9_]+|https?:\/\/[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_|])/gi
|
/(?:^|\s)(?:@[a-z0-9_]+|https?:\/\/[-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_|])/gi
|
||||||
const matches = text.match(regex) || []
|
const matches = text.match(regex) || []
|
||||||
const links = matches.map((match) => {
|
const links = matches.map((match) => {
|
||||||
// Matches are in the form: " @username" or "https://example.com"
|
// Matches are in the form: " @username" or "https://example.com"
|
||||||
|
@ -26,7 +25,6 @@ export function Linkify(props: {
|
||||||
const href =
|
const href =
|
||||||
{
|
{
|
||||||
'@': `/${tag}`,
|
'@': `/${tag}`,
|
||||||
'#': `/tag/${tag}`,
|
|
||||||
}[symbol] ?? match.trim()
|
}[symbol] ?? match.trim()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user