schema.org things.

This commit is contained in:
fiatjaf
2024-06-10 23:41:57 -03:00
parent 899dbf8441
commit aeb98ca535
7 changed files with 136 additions and 102 deletions

View File

@@ -7,11 +7,10 @@ import (
"math/rand"
"net/http"
"regexp"
"slices"
"strings"
"time"
"slices"
"github.com/microcosm-cc/bluemonday"
"mvdan.cc/xurls/v2"
@@ -241,9 +240,9 @@ func replaceNostrURLsWithHTMLTags(matcher *regexp.Regexp, input string) string {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*4)
defer cancel()
name, _ := getNameFromNip19(ctx, nip19)
return fmt.Sprintf(`<a href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1"><span>%s</span> (<span class="italic">%s</span>)</a>`, nip19, name, firstChars+"…"+lastChars)
return fmt.Sprintf(`<span itemprop="mentions" itemscope itemtype="https://schema.org/Person"><a itemprop="url" href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1"><span>%s</span> (<span class="italic">%s</span>)</a></span>`, nip19, name, firstChars+"…"+lastChars)
} else {
return fmt.Sprintf(`<a href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1">%s</a>`, nip19, firstChars+"…"+lastChars)
return fmt.Sprintf(`<span itemprop="mentions" itemscope itemtype="https://schema.org/SocialMediaPosting"><a itemprop="url" href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1">%s</a></span>`, nip19, firstChars+"…"+lastChars)
}
})
}