Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
feat: support YouTube video thumbnail in link preview (#4427)
MHZ964ae16851e7
diff --git a/plugin/httpgetter/html_meta.go b/plugin/httpgetter/html_meta.goindex 50211569e..3ac719487 100644--- a/plugin/httpgetter/html_meta.go+++ b/plugin/httpgetter/html_meta.go@@ -1,6 +1,7 @@package httpgetterimport (+ "fmt""io""net""net/http"@@ -53,6 +54,7 @@ func GetHTMLMeta(urlStr string) (*HTMLMeta, error) {// TODO: limit the size of the response bodyhtmlMeta := extractHTMLMeta(response.Body)+ enrichSiteMeta(response.Request.URL, htmlMeta)return htmlMeta, nil}@@ -151,3 +153,14 @@ func validateURL(urlStr string) error {return nil}++func enrichSiteMeta(url *url.URL, meta *HTMLMeta) {+ if url.Hostname() == "www.youtube.com" {+ if url.Path == "/watch" {+ vid := url.Query().Get("v")+ if vid != "" {+ meta.Image = fmt.Sprintf("https://img.youtube.com/vi/%s/mqdefault.jpg", vid)+ }+ }+ }+}diff --git a/web/src/components/MemoContent/Link.tsx b/web/src/components/MemoContent/Link.tsxindex 97a9e427e..8bfdeaa4b 100644--- a/web/src/components/MemoContent/Link.tsx+++ b/web/src/components/MemoContent/Link.tsx@@ -54,6 +54,9 @@ const Link: React.FC<Props> = ({ text, url }: Props) => {{linkMetadata.description && (<p className="mt-1 w-full text-sm leading-snug opacity-80 line-clamp-3">{linkMetadata.description}</p>)}+ {linkMetadata.image && (+ <img className="mt-1 w-full h-32 object-cover rounded" src={linkMetadata.image} alt={linkMetadata.title} />+ )}</div>)}