fix: exclude link-only text blocks from search results; refs #180
This commit is contained in:
parent
c0f584918a
commit
124e70a968
|
@ -22,12 +22,14 @@ export const TextBlockDataType: UnbodyDataTypeConfig<
|
|||
|
||||
if (text.length > 0 || html.length > 0) {
|
||||
const isLink =
|
||||
/^<p[^>]*><span[^>]*><a[^>]*href="(https):\/\/[^ "]+"[^>]*>.*<\/a><\/span><\/p>$/.test(
|
||||
/^<p[^>]*>(<span[^>]*>[\s]*<\/span>)*<span[^>]*><a[^>]*href="(https):\/\/[^ "]+"[^>]*>.*<\/a><\/span>(<span[^>]*>(\s|(<br(\/)?>))*<\/span>)*<\/p>$/.test(
|
||||
html,
|
||||
)
|
||||
const isIframe = /<iframe[^>]*>(?:<\/iframe>|[^]*?<\/iframe>)/.test(text)
|
||||
|
||||
if (isLink) {
|
||||
labels.push(LPE.Post.ContentBlockLabels.LinkOnly)
|
||||
|
||||
const youtube = html.match(
|
||||
/(https?\:\/\/)?((www\.)?youtube\.com|youtu\.?be)\/[^ "]+/gi,
|
||||
)
|
||||
|
|
|
@ -62,6 +62,7 @@ export namespace LPE {
|
|||
Paragraph: 'paragraph',
|
||||
CoverImage: 'cover_image',
|
||||
Embed: 'embed',
|
||||
LinkOnly: 'link_only',
|
||||
YoutubeEmbed: 'youtube_embed',
|
||||
SimplecastEmbed: 'simplecast_embed',
|
||||
} as const
|
||||
|
|
|
@ -13,7 +13,8 @@ export const searchBlocksBasicFilter = (
|
|||
if (block.type === LPE.ContentTypes.Text) {
|
||||
return (
|
||||
!isTitle(block.data as LPE.Post.TextBlock) &&
|
||||
isLongEnough(block.data as LPE.Post.TextBlock)
|
||||
isLongEnough(block.data as LPE.Post.TextBlock) &&
|
||||
!block.data.labels.includes('link_only')
|
||||
)
|
||||
} else {
|
||||
const isPodcastImage = block.data.document.type === LPE.PostTypes.Podcast
|
||||
|
|
Loading…
Reference in New Issue