File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
web/src/components/MemoContent Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
package httpgetter
2
2
3
3
import (
4
+ "fmt"
4
5
"io"
5
6
"net"
6
7
"net/http"
@@ -53,6 +54,7 @@ func GetHTMLMeta(urlStr string) (*HTMLMeta, error) {
53
54
// TODO: limit the size of the response body
54
55
55
56
htmlMeta := extractHTMLMeta (response .Body )
57
+ enrichSiteMeta (response .Request .URL , htmlMeta )
56
58
return htmlMeta , nil
57
59
}
58
60
@@ -151,3 +153,14 @@ func validateURL(urlStr string) error {
151
153
152
154
return nil
153
155
}
156
+
157
+ func enrichSiteMeta (url * url.URL , meta * HTMLMeta ) {
158
+ if url .Hostname () == "www.youtube.com" {
159
+ if url .Path == "/watch" {
160
+ vid := url .Query ().Get ("v" )
161
+ if vid != "" {
162
+ meta .Image = fmt .Sprintf ("https://img.youtube.com/vi/%s/mqdefault.jpg" , vid )
163
+ }
164
+ }
165
+ }
166
+ }
Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ const Link: React.FC<Props> = ({ text, url }: Props) => {
54
54
{ linkMetadata . description && (
55
55
< p className = "mt-1 w-full text-sm leading-snug opacity-80 line-clamp-3" > { linkMetadata . description } </ p >
56
56
) }
57
+ { linkMetadata . image && (
58
+ < img className = "mt-1 w-full h-32 object-cover rounded" src = { linkMetadata . image } alt = { linkMetadata . title } />
59
+ ) }
57
60
</ div >
58
61
)
59
62
}
You can’t perform that action at this time.
0 commit comments