Skip to content

Conversation

brymut
Copy link
Contributor

@brymut brymut commented Aug 15, 2025

Description

Remove MD and images before creating a summary of the text in the SEO.
closes #2363

Tested using the ~AGORA description

Screenshot 2025-08-23 at 09 18 29

Result

Screenshot 2025-08-23 at 09 16 52

Tested using the ~AMA description

Screenshot 2025-08-23 at 09 31 25

Result

Screenshot 2025-08-23 at 09 31 41

Particularly short example (maybe images and Markdown being cleaned out make it too short)

Screenshot 2025-08-23 at 09 39 06

Result

Screenshot 2025-08-23 at 09 39 46

Checklist

Are your changes backward compatible? Please answer below:
Y
For example, a change is not backward compatible if you removed a GraphQL field or dropped a database column.

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
10

For frontend changes: Tested on mobile, light and dark mode? Please answer below:
Y

Did you introduce any new environment variables? If so, call them out explicitly here:
N

cursor[bot]

This comment was marked as outdated.

@brymut brymut force-pushed the feat/add-sub-seo branch 2 times, most recently from a6ed68a to fdfa7c5 Compare August 23, 2025 06:40
lib/territory.js Outdated
Comment on lines 32 to 77

function cleanMarkdownText (text) {
if (!text) return ''

let cleaned = removeMd(text)
cleaned = cleaned
.replace(/\s+/g, ' ') // Replace multiple spaces with single space
.replace(/\[\[([^\]]+)\]\]\([^)]+\)/g, '$1') // Remove nested markdown links, keep inner text
.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1') // Remove regular markdown links, keep text
.replace(/!\[([^\]]*)\]\([^)]+\)/g, '') // Remove images completely
.replace(/`([^`]+)`/g, '$1') // Remove code formatting
.replace(/\*\*([^*]+)\*\*/g, '$1') // Remove bold formatting
.replace(/\*([^*]+)\*/g, '$1') // Remove italic formatting
.trim()

return cleaned
}

function truncateAtSentenceBoundary (text, maxLength = 160) {
if (!text || text.length <= maxLength) return text
const sentences = text
.split(/[.!?]+/)
.map(s => s.trim())
.filter(Boolean)

let result = ''
let currentLength = 0

for (const sentence of sentences) {
const separator = result ? '. ' : ''
const newLength = currentLength + separator.length + sentence.length

if (newLength <= maxLength - 3) {
result += separator + sentence
currentLength = newLength
} else {
break
}
}
if (result) {
return result + '...'
}
// Fallback to simple truncation
return text.substring(0, maxLength - 3) + '...'
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not share the item seo stuff?

if the item seo stuff is lame in some way, improve and share it with territories. I think they should share seo - they are both mostly markdown documents.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just following the issue spec

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not share the item seo stuff?

Applied changes for users and item seo stuff too

@brymut brymut requested a review from huumn September 2, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom OG meta tags for territories
2 participants