-
-
Notifications
You must be signed in to change notification settings - Fork 134
feat: add territory SEO #2422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add territory SEO #2422
Conversation
32b9015
to
60df93e
Compare
a6ed68a
to
fdfa7c5
Compare
lib/territory.js
Outdated
|
||
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) + '...' | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
fdfa7c5
to
2ee5a78
Compare
2ee5a78
to
8e8e8ce
Compare
Description
Remove MD and images before creating a summary of the text in the SEO.
closes #2363
Tested using the ~AGORA description
Result
Tested using the ~AMA description
Result
Particularly short example (maybe images and Markdown being cleaned out make it too short)
Result
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