Facets. It's specific to bsky at the moment.

This commit is contained in:
CatAClock 2025-06-13 16:53:45 -07:00
parent 3772dbffc9
commit 9185e649be

View file

@ -350,6 +350,11 @@ export function ApplyFacets(record, text) {
SplitAreas.push(i.index.byteEnd);
Hrefs.push(i.features[0].uri);
}
if (i.features[0].$type == "app.bsky.richtext.facet#tag") {
SplitAreas.push(i.index.byteStart);
SplitAreas.push(i.index.byteEnd);
Hrefs.push("https://bsky.app/hashtag/" + i.features[0].tag);
}
}
// Last minute append.
SplitAreas.push(text.length);
@ -365,8 +370,8 @@ export function ApplyFacets(record, text) {
}
// Finally, we append the string with <a>
for (let i = 0; i < StringArray.length; i += 2) {
if (Hrefs[(i / 2)] != undefined) {
TempText += StringArray[i] + "<a href='" + Hrefs[(i / 2)] + "'>" + StringArray[i + 1] + "</a>";
if (Hrefs[(i / 2)] != undefined && Hrefs[(i / 2)].split("https://").length != 1) {
TempText += StringArray[i] + "<a href=\"" + Hrefs[(i / 2)] + "\">" + StringArray[i + 1] + "</a>";
} else {
TempText += StringArray[i];
}