Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
335a0312
Commit
335a0312
authored
Mar 16, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak link styles
parent
9c1e2f81
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
201 deletions
+166
-201
link_service.proto
proto/api/v2/link_service.proto
+8
-8
README.md
proto/gen/api/v2/README.md
+1
-1
link_service.pb.go
proto/gen/api/v2/link_service.pb.go
+96
-95
link_service.pb.gw.go
proto/gen/api/v2/link_service.pb.gw.go
+3
-3
apidocs.swagger.yaml
server/route/api/v2/apidocs.swagger.yaml
+20
-20
link_service.go
server/route/api/v2/link_service.go
+1
-1
Link.tsx
web/src/components/MemoContent/Link.tsx
+37
-73
No files found.
proto/api/v2/link_service.proto
View file @
335a0312
...
@@ -8,20 +8,20 @@ option go_package = "gen/api/v2";
...
@@ -8,20 +8,20 @@ option go_package = "gen/api/v2";
service
LinkService
{
service
LinkService
{
rpc
GetLinkMetadata
(
GetLinkMetadataRequest
)
returns
(
GetLinkMetadataResponse
)
{
rpc
GetLinkMetadata
(
GetLinkMetadataRequest
)
returns
(
GetLinkMetadataResponse
)
{
option
(
google.api.http
)
=
{
get
:
"/api/v2/metadata"
};
option
(
google.api.http
)
=
{
get
:
"/api/v2/
link_
metadata"
};
}
}
}
}
message
LinkMetadata
{
string
title
=
1
;
string
description
=
2
;
string
image
=
3
;
}
message
GetLinkMetadataRequest
{
message
GetLinkMetadataRequest
{
string
link
=
1
;
string
link
=
1
;
}
}
message
GetLinkMetadataResponse
{
message
GetLinkMetadataResponse
{
LinkMetadata
metadata
=
1
;
LinkMetadata
link_metadata
=
1
;
}
message
LinkMetadata
{
string
title
=
1
;
string
description
=
2
;
string
image
=
3
;
}
}
proto/gen/api/v2/README.md
View file @
335a0312
...
@@ -1135,7 +1135,7 @@ Used internally for obfuscating the page token.
...
@@ -1135,7 +1135,7 @@ Used internally for obfuscating the page token.
| Field | Type | Label | Description |
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| ----- | ---- | ----- | ----------- |
| metadata |
[
LinkMetadata
](
#memos-api-v2-LinkMetadata
)
| | |
|
link_
metadata |
[
LinkMetadata
](
#memos-api-v2-LinkMetadata
)
| | |
...
...
proto/gen/api/v2/link_service.pb.go
View file @
335a0312
...
@@ -21,18 +21,16 @@ const (
...
@@ -21,18 +21,16 @@ const (
_
=
protoimpl
.
EnforceVersion
(
protoimpl
.
MaxVersion
-
20
)
_
=
protoimpl
.
EnforceVersion
(
protoimpl
.
MaxVersion
-
20
)
)
)
type
LinkMetadata
struct
{
type
GetLinkMetadataRequest
struct
{
state
protoimpl
.
MessageState
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
unknownFields
protoimpl
.
UnknownFields
Title
string
`protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
Link
string
`protobuf:"bytes,1,opt,name=link,proto3" json:"link,omitempty"`
Description
string
`protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
Image
string
`protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"`
}
}
func
(
x
*
LinkMetadata
)
Reset
()
{
func
(
x
*
GetLinkMetadataRequest
)
Reset
()
{
*
x
=
LinkMetadata
{}
*
x
=
GetLinkMetadataRequest
{}
if
protoimpl
.
UnsafeEnabled
{
if
protoimpl
.
UnsafeEnabled
{
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
0
]
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
0
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
...
@@ -40,13 +38,13 @@ func (x *LinkMetadata) Reset() {
...
@@ -40,13 +38,13 @@ func (x *LinkMetadata) Reset() {
}
}
}
}
func
(
x
*
LinkMetadata
)
String
()
string
{
func
(
x
*
GetLinkMetadataRequest
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
}
func
(
*
LinkMetadata
)
ProtoMessage
()
{}
func
(
*
GetLinkMetadataRequest
)
ProtoMessage
()
{}
func
(
x
*
LinkMetadata
)
ProtoReflect
()
protoreflect
.
Message
{
func
(
x
*
GetLinkMetadataRequest
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
0
]
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
0
]
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
...
@@ -58,42 +56,28 @@ func (x *LinkMetadata) ProtoReflect() protoreflect.Message {
...
@@ -58,42 +56,28 @@ func (x *LinkMetadata) ProtoReflect() protoreflect.Message {
return
mi
.
MessageOf
(
x
)
return
mi
.
MessageOf
(
x
)
}
}
// Deprecated: Use
LinkMetadata
.ProtoReflect.Descriptor instead.
// Deprecated: Use
GetLinkMetadataRequest
.ProtoReflect.Descriptor instead.
func
(
*
LinkMetadata
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GetLinkMetadataRequest
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_api_v2_link_service_proto_rawDescGZIP
(),
[]
int
{
0
}
return
file_api_v2_link_service_proto_rawDescGZIP
(),
[]
int
{
0
}
}
}
func
(
x
*
LinkMetadata
)
GetTitle
()
string
{
func
(
x
*
GetLinkMetadataRequest
)
GetLink
()
string
{
if
x
!=
nil
{
return
x
.
Title
}
return
""
}
func
(
x
*
LinkMetadata
)
GetDescription
()
string
{
if
x
!=
nil
{
return
x
.
Description
}
return
""
}
func
(
x
*
LinkMetadata
)
GetImage
()
string
{
if
x
!=
nil
{
if
x
!=
nil
{
return
x
.
Image
return
x
.
Link
}
}
return
""
return
""
}
}
type
GetLinkMetadataRe
quest
struct
{
type
GetLinkMetadataRe
sponse
struct
{
state
protoimpl
.
MessageState
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
unknownFields
protoimpl
.
UnknownFields
Link
string
`protobuf:"bytes,1,opt,name=link,proto3" json:"link
,omitempty"`
Link
Metadata
*
LinkMetadata
`protobuf:"bytes,1,opt,name=link_metadata,json=linkMetadata,proto3" json:"link_metadata
,omitempty"`
}
}
func
(
x
*
GetLinkMetadataRe
quest
)
Reset
()
{
func
(
x
*
GetLinkMetadataRe
sponse
)
Reset
()
{
*
x
=
GetLinkMetadataRe
quest
{}
*
x
=
GetLinkMetadataRe
sponse
{}
if
protoimpl
.
UnsafeEnabled
{
if
protoimpl
.
UnsafeEnabled
{
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
1
]
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
1
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
...
@@ -101,13 +85,13 @@ func (x *GetLinkMetadataRequest) Reset() {
...
@@ -101,13 +85,13 @@ func (x *GetLinkMetadataRequest) Reset() {
}
}
}
}
func
(
x
*
GetLinkMetadataRe
quest
)
String
()
string
{
func
(
x
*
GetLinkMetadataRe
sponse
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
}
func
(
*
GetLinkMetadataRe
quest
)
ProtoMessage
()
{}
func
(
*
GetLinkMetadataRe
sponse
)
ProtoMessage
()
{}
func
(
x
*
GetLinkMetadataRe
quest
)
ProtoReflect
()
protoreflect
.
Message
{
func
(
x
*
GetLinkMetadataRe
sponse
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
1
]
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
1
]
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
...
@@ -119,28 +103,30 @@ func (x *GetLinkMetadataRequest) ProtoReflect() protoreflect.Message {
...
@@ -119,28 +103,30 @@ func (x *GetLinkMetadataRequest) ProtoReflect() protoreflect.Message {
return
mi
.
MessageOf
(
x
)
return
mi
.
MessageOf
(
x
)
}
}
// Deprecated: Use GetLinkMetadataRe
quest
.ProtoReflect.Descriptor instead.
// Deprecated: Use GetLinkMetadataRe
sponse
.ProtoReflect.Descriptor instead.
func
(
*
GetLinkMetadataRe
quest
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
GetLinkMetadataRe
sponse
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_api_v2_link_service_proto_rawDescGZIP
(),
[]
int
{
1
}
return
file_api_v2_link_service_proto_rawDescGZIP
(),
[]
int
{
1
}
}
}
func
(
x
*
GetLinkMetadataRe
quest
)
GetLink
()
string
{
func
(
x
*
GetLinkMetadataRe
sponse
)
GetLinkMetadata
()
*
LinkMetadata
{
if
x
!=
nil
{
if
x
!=
nil
{
return
x
.
Link
return
x
.
Link
Metadata
}
}
return
""
return
nil
}
}
type
GetLinkMetadataResponse
struct
{
type
LinkMetadata
struct
{
state
protoimpl
.
MessageState
state
protoimpl
.
MessageState
sizeCache
protoimpl
.
SizeCache
sizeCache
protoimpl
.
SizeCache
unknownFields
protoimpl
.
UnknownFields
unknownFields
protoimpl
.
UnknownFields
Metadata
*
LinkMetadata
`protobuf:"bytes,1,opt,name=metadata,proto3" json:"metadata,omitempty"`
Title
string
`protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"`
Description
string
`protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
Image
string
`protobuf:"bytes,3,opt,name=image,proto3" json:"image,omitempty"`
}
}
func
(
x
*
GetLinkMetadataResponse
)
Reset
()
{
func
(
x
*
LinkMetadata
)
Reset
()
{
*
x
=
GetLinkMetadataResponse
{}
*
x
=
LinkMetadata
{}
if
protoimpl
.
UnsafeEnabled
{
if
protoimpl
.
UnsafeEnabled
{
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
2
]
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
2
]
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
...
@@ -148,13 +134,13 @@ func (x *GetLinkMetadataResponse) Reset() {
...
@@ -148,13 +134,13 @@ func (x *GetLinkMetadataResponse) Reset() {
}
}
}
}
func
(
x
*
GetLinkMetadataResponse
)
String
()
string
{
func
(
x
*
LinkMetadata
)
String
()
string
{
return
protoimpl
.
X
.
MessageStringOf
(
x
)
return
protoimpl
.
X
.
MessageStringOf
(
x
)
}
}
func
(
*
GetLinkMetadataResponse
)
ProtoMessage
()
{}
func
(
*
LinkMetadata
)
ProtoMessage
()
{}
func
(
x
*
GetLinkMetadataResponse
)
ProtoReflect
()
protoreflect
.
Message
{
func
(
x
*
LinkMetadata
)
ProtoReflect
()
protoreflect
.
Message
{
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
2
]
mi
:=
&
file_api_v2_link_service_proto_msgTypes
[
2
]
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
if
protoimpl
.
UnsafeEnabled
&&
x
!=
nil
{
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
ms
:=
protoimpl
.
X
.
MessageStateOf
(
protoimpl
.
Pointer
(
x
))
...
@@ -166,16 +152,30 @@ func (x *GetLinkMetadataResponse) ProtoReflect() protoreflect.Message {
...
@@ -166,16 +152,30 @@ func (x *GetLinkMetadataResponse) ProtoReflect() protoreflect.Message {
return
mi
.
MessageOf
(
x
)
return
mi
.
MessageOf
(
x
)
}
}
// Deprecated: Use
GetLinkMetadataResponse
.ProtoReflect.Descriptor instead.
// Deprecated: Use
LinkMetadata
.ProtoReflect.Descriptor instead.
func
(
*
GetLinkMetadataResponse
)
Descriptor
()
([]
byte
,
[]
int
)
{
func
(
*
LinkMetadata
)
Descriptor
()
([]
byte
,
[]
int
)
{
return
file_api_v2_link_service_proto_rawDescGZIP
(),
[]
int
{
2
}
return
file_api_v2_link_service_proto_rawDescGZIP
(),
[]
int
{
2
}
}
}
func
(
x
*
GetLinkMetadataResponse
)
GetMetadata
()
*
LinkMetadata
{
func
(
x
*
LinkMetadata
)
GetTitle
()
string
{
if
x
!=
nil
{
if
x
!=
nil
{
return
x
.
Metadata
return
x
.
Title
}
}
return
nil
return
""
}
func
(
x
*
LinkMetadata
)
GetDescription
()
string
{
if
x
!=
nil
{
return
x
.
Description
}
return
""
}
func
(
x
*
LinkMetadata
)
GetImage
()
string
{
if
x
!=
nil
{
return
x
.
Image
}
return
""
}
}
var
File_api_v2_link_service_proto
protoreflect
.
FileDescriptor
var
File_api_v2_link_service_proto
protoreflect
.
FileDescriptor
...
@@ -185,41 +185,42 @@ var file_api_v2_link_service_proto_rawDesc = []byte{
...
@@ -185,41 +185,42 @@ var file_api_v2_link_service_proto_rawDesc = []byte{
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x12
,
0x0c
,
0x6d
,
0x65
,
0x6d
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x12
,
0x0c
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x1a
,
0x1c
,
0x67
,
0x6f
,
0x6f
,
0x67
,
0x6c
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x1a
,
0x1c
,
0x67
,
0x6f
,
0x6f
,
0x67
,
0x6c
,
0x65
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x61
,
0x6e
,
0x6e
,
0x6f
,
0x74
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x65
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x61
,
0x6e
,
0x6e
,
0x6f
,
0x74
,
0x61
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x73
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x22
,
0x5c
,
0x0a
,
0x0c
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x73
,
0x2e
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x22
,
0x2c
,
0x0a
,
0x16
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x12
,
0x14
,
0x0a
,
0x05
,
0x74
,
0x69
,
0x74
,
0x6c
,
0x65
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x05
,
0x74
,
0x69
,
0x74
,
0x6c
,
0x65
,
0x12
,
0x20
,
0x0a
,
0x74
,
0x12
,
0x12
,
0x0a
,
0x04
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0b
,
0x64
,
0x65
,
0x73
,
0x63
,
0x72
,
0x69
,
0x70
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x18
,
0x02
,
0x20
,
0x01
,
0x04
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x22
,
0x5a
,
0x0a
,
0x17
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x28
,
0x09
,
0x52
,
0x0b
,
0x64
,
0x65
,
0x73
,
0x63
,
0x72
,
0x69
,
0x70
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x12
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x73
,
0x70
,
0x6f
,
0x6e
,
0x73
,
0x65
,
0x14
,
0x0a
,
0x05
,
0x69
,
0x6d
,
0x61
,
0x67
,
0x65
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x05
,
0x12
,
0x3f
,
0x0a
,
0x0d
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x5f
,
0x6d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x69
,
0x6d
,
0x61
,
0x67
,
0x65
,
0x22
,
0x2c
,
0x0a
,
0x16
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x61
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x0b
,
0x32
,
0x1a
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x12
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x2e
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x12
,
0x0a
,
0x04
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x04
,
0x6c
,
0x61
,
0x74
,
0x61
,
0x52
,
0x0c
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x69
,
0x6e
,
0x6b
,
0x22
,
0x51
,
0x0a
,
0x17
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x61
,
0x22
,
0x5c
,
0x0a
,
0x0c
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x73
,
0x70
,
0x6f
,
0x6e
,
0x73
,
0x65
,
0x12
,
0x36
,
0x61
,
0x12
,
0x14
,
0x0a
,
0x05
,
0x74
,
0x69
,
0x74
,
0x6c
,
0x65
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x09
,
0x0a
,
0x08
,
0x6d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x18
,
0x01
,
0x20
,
0x01
,
0x28
,
0x0b
,
0x52
,
0x05
,
0x74
,
0x69
,
0x74
,
0x6c
,
0x65
,
0x12
,
0x20
,
0x0a
,
0x0b
,
0x64
,
0x65
,
0x73
,
0x63
,
0x72
,
0x32
,
0x1a
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x2e
,
0x69
,
0x70
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x18
,
0x02
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x0b
,
0x64
,
0x65
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x08
,
0x6d
,
0x65
,
0x73
,
0x63
,
0x72
,
0x69
,
0x70
,
0x74
,
0x69
,
0x6f
,
0x6e
,
0x12
,
0x14
,
0x0a
,
0x05
,
0x69
,
0x6d
,
0x61
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x32
,
0x87
,
0x01
,
0x0a
,
0x0b
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x53
,
0x67
,
0x65
,
0x18
,
0x03
,
0x20
,
0x01
,
0x28
,
0x09
,
0x52
,
0x05
,
0x69
,
0x6d
,
0x61
,
0x67
,
0x65
,
0x32
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x12
,
0x78
,
0x0a
,
0x0f
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x8c
,
0x01
,
0x0a
,
0x0b
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x53
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x12
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x12
,
0x24
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x7d
,
0x0a
,
0x0f
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x2e
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x74
,
0x61
,
0x12
,
0x24
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x1a
,
0x32
,
0x2e
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x25
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x2e
,
0x47
,
0x61
,
0x52
,
0x65
,
0x71
,
0x75
,
0x65
,
0x73
,
0x74
,
0x1a
,
0x25
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x2e
,
0x47
,
0x65
,
0x74
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x4d
,
0x73
,
0x70
,
0x6f
,
0x6e
,
0x73
,
0x65
,
0x22
,
0x18
,
0x82
,
0xd3
,
0xe4
,
0x93
,
0x02
,
0x12
,
0x12
,
0x10
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x52
,
0x65
,
0x73
,
0x70
,
0x6f
,
0x6e
,
0x73
,
0x65
,
0x22
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x76
,
0x32
,
0x2f
,
0x6d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x1d
,
0x82
,
0xd3
,
0xe4
,
0x93
,
0x02
,
0x17
,
0x12
,
0x15
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x2f
,
0x76
,
0x32
,
0x42
,
0xa8
,
0x01
,
0x0a
,
0x10
,
0x63
,
0x6f
,
0x6d
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x2f
,
0x6c
,
0x69
,
0x6e
,
0x6b
,
0x5f
,
0x6d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0x42
,
0xa8
,
0x70
,
0x69
,
0x2e
,
0x76
,
0x32
,
0x42
,
0x10
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x53
,
0x65
,
0x72
,
0x76
,
0x69
,
0x01
,
0x0a
,
0x10
,
0x63
,
0x6f
,
0x6d
,
0x2e
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x61
,
0x70
,
0x69
,
0x63
,
0x65
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x30
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x2e
,
0x76
,
0x32
,
0x42
,
0x10
,
0x4c
,
0x69
,
0x6e
,
0x6b
,
0x53
,
0x65
,
0x72
,
0x76
,
0x69
,
0x63
,
0x65
,
0x62
,
0x2e
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x50
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x50
,
0x01
,
0x5a
,
0x30
,
0x67
,
0x69
,
0x74
,
0x68
,
0x75
,
0x62
,
0x2e
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x61
,
0x63
,
0x6f
,
0x6d
,
0x2f
,
0x75
,
0x73
,
0x65
,
0x6d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2f
,
0x6d
,
0x65
,
0x6d
,
0x70
,
0x69
,
0x2f
,
0x76
,
0x32
,
0x3b
,
0x61
,
0x70
,
0x69
,
0x76
,
0x32
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x41
,
0x6f
,
0x73
,
0x2f
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x2f
,
0x67
,
0x65
,
0x6e
,
0x2f
,
0x61
,
0x70
,
0x69
,
0x58
,
0xaa
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x41
,
0x70
,
0x69
,
0x2e
,
0x56
,
0x32
,
0x2f
,
0x76
,
0x32
,
0x3b
,
0x61
,
0x70
,
0x69
,
0x76
,
0x32
,
0xa2
,
0x02
,
0x03
,
0x4d
,
0x41
,
0x58
,
0xaa
,
0xca
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x32
,
0xe2
,
0x02
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x2e
,
0x41
,
0x70
,
0x69
,
0x2e
,
0x56
,
0x32
,
0xca
,
0x02
,
0x02
,
0x18
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x32
,
0x5c
,
0x47
,
0x0c
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x32
,
0xe2
,
0x02
,
0x18
,
0x50
,
0x42
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0e
,
0x4d
,
0x65
,
0x6d
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x5c
,
0x41
,
0x70
,
0x69
,
0x5c
,
0x56
,
0x32
,
0x5c
,
0x47
,
0x50
,
0x42
,
0x6f
,
0x73
,
0x3a
,
0x3a
,
0x41
,
0x70
,
0x69
,
0x3a
,
0x3a
,
0x56
,
0x32
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x4d
,
0x65
,
0x74
,
0x61
,
0x64
,
0x61
,
0x74
,
0x61
,
0xea
,
0x02
,
0x0e
,
0x4d
,
0x65
,
0x6d
,
0x6f
,
0x73
,
0x74
,
0x6f
,
0x33
,
0x3a
,
0x3a
,
0x41
,
0x70
,
0x69
,
0x3a
,
0x3a
,
0x56
,
0x32
,
0x62
,
0x06
,
0x70
,
0x72
,
0x6f
,
0x74
,
0x6f
,
0x33
,
}
}
var
(
var
(
...
@@ -236,14 +237,14 @@ func file_api_v2_link_service_proto_rawDescGZIP() []byte {
...
@@ -236,14 +237,14 @@ func file_api_v2_link_service_proto_rawDescGZIP() []byte {
var
file_api_v2_link_service_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
3
)
var
file_api_v2_link_service_proto_msgTypes
=
make
([]
protoimpl
.
MessageInfo
,
3
)
var
file_api_v2_link_service_proto_goTypes
=
[]
interface
{}{
var
file_api_v2_link_service_proto_goTypes
=
[]
interface
{}{
(
*
LinkMetadata
)(
nil
),
// 0: memos.api.v2.LinkMetadata
(
*
GetLinkMetadataRequest
)(
nil
),
// 0: memos.api.v2.GetLinkMetadataRequest
(
*
GetLinkMetadataRe
quest
)(
nil
),
// 1: memos.api.v2.GetLinkMetadataRequest
(
*
GetLinkMetadataRe
sponse
)(
nil
),
// 1: memos.api.v2.GetLinkMetadataResponse
(
*
GetLinkMetadataResponse
)(
nil
),
// 2: memos.api.v2.GetLinkMetadataResponse
(
*
LinkMetadata
)(
nil
),
// 2: memos.api.v2.LinkMetadata
}
}
var
file_api_v2_link_service_proto_depIdxs
=
[]
int32
{
var
file_api_v2_link_service_proto_depIdxs
=
[]
int32
{
0
,
// 0: memos.api.v2.GetLinkMetadataResponse.
metadata:type_name -> memos.api.v2.LinkMetadata
2
,
// 0: memos.api.v2.GetLinkMetadataResponse.link_
metadata:type_name -> memos.api.v2.LinkMetadata
1
,
// 1: memos.api.v2.LinkService.GetLinkMetadata:input_type -> memos.api.v2.GetLinkMetadataRequest
0
,
// 1: memos.api.v2.LinkService.GetLinkMetadata:input_type -> memos.api.v2.GetLinkMetadataRequest
2
,
// 2: memos.api.v2.LinkService.GetLinkMetadata:output_type -> memos.api.v2.GetLinkMetadataResponse
1
,
// 2: memos.api.v2.LinkService.GetLinkMetadata:output_type -> memos.api.v2.GetLinkMetadataResponse
2
,
// [2:3] is the sub-list for method output_type
2
,
// [2:3] is the sub-list for method output_type
1
,
// [1:2] is the sub-list for method input_type
1
,
// [1:2] is the sub-list for method input_type
1
,
// [1:1] is the sub-list for extension type_name
1
,
// [1:1] is the sub-list for extension type_name
...
@@ -258,7 +259,7 @@ func file_api_v2_link_service_proto_init() {
...
@@ -258,7 +259,7 @@ func file_api_v2_link_service_proto_init() {
}
}
if
!
protoimpl
.
UnsafeEnabled
{
if
!
protoimpl
.
UnsafeEnabled
{
file_api_v2_link_service_proto_msgTypes
[
0
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
file_api_v2_link_service_proto_msgTypes
[
0
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
switch
v
:=
v
.
(
*
LinkMetadata
);
i
{
switch
v
:=
v
.
(
*
GetLinkMetadataRequest
);
i
{
case
0
:
case
0
:
return
&
v
.
state
return
&
v
.
state
case
1
:
case
1
:
...
@@ -270,7 +271,7 @@ func file_api_v2_link_service_proto_init() {
...
@@ -270,7 +271,7 @@ func file_api_v2_link_service_proto_init() {
}
}
}
}
file_api_v2_link_service_proto_msgTypes
[
1
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
file_api_v2_link_service_proto_msgTypes
[
1
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
switch
v
:=
v
.
(
*
GetLinkMetadataRe
quest
);
i
{
switch
v
:=
v
.
(
*
GetLinkMetadataRe
sponse
);
i
{
case
0
:
case
0
:
return
&
v
.
state
return
&
v
.
state
case
1
:
case
1
:
...
@@ -282,7 +283,7 @@ func file_api_v2_link_service_proto_init() {
...
@@ -282,7 +283,7 @@ func file_api_v2_link_service_proto_init() {
}
}
}
}
file_api_v2_link_service_proto_msgTypes
[
2
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
file_api_v2_link_service_proto_msgTypes
[
2
]
.
Exporter
=
func
(
v
interface
{},
i
int
)
interface
{}
{
switch
v
:=
v
.
(
*
GetLinkMetadataResponse
);
i
{
switch
v
:=
v
.
(
*
LinkMetadata
);
i
{
case
0
:
case
0
:
return
&
v
.
state
return
&
v
.
state
case
1
:
case
1
:
...
...
proto/gen/api/v2/link_service.pb.gw.go
View file @
335a0312
...
@@ -81,7 +81,7 @@ func RegisterLinkServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
...
@@ -81,7 +81,7 @@ func RegisterLinkServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
var
err
error
var
err
error
var
annotatedContext
context
.
Context
var
annotatedContext
context
.
Context
annotatedContext
,
err
=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.LinkService/GetLinkMetadata"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/metadata"
))
annotatedContext
,
err
=
runtime
.
AnnotateIncomingContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.LinkService/GetLinkMetadata"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/
link_
metadata"
))
if
err
!=
nil
{
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
return
...
@@ -145,7 +145,7 @@ func RegisterLinkServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
...
@@ -145,7 +145,7 @@ func RegisterLinkServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
inboundMarshaler
,
outboundMarshaler
:=
runtime
.
MarshalerForRequest
(
mux
,
req
)
var
err
error
var
err
error
var
annotatedContext
context
.
Context
var
annotatedContext
context
.
Context
annotatedContext
,
err
=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.LinkService/GetLinkMetadata"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/metadata"
))
annotatedContext
,
err
=
runtime
.
AnnotateContext
(
ctx
,
mux
,
req
,
"/memos.api.v2.LinkService/GetLinkMetadata"
,
runtime
.
WithHTTPPathPattern
(
"/api/v2/
link_
metadata"
))
if
err
!=
nil
{
if
err
!=
nil
{
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
runtime
.
HTTPError
(
ctx
,
mux
,
outboundMarshaler
,
w
,
req
,
err
)
return
return
...
@@ -165,7 +165,7 @@ func RegisterLinkServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
...
@@ -165,7 +165,7 @@ func RegisterLinkServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux
}
}
var
(
var
(
pattern_LinkService_GetLinkMetadata_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"api"
,
"v2"
,
"metadata"
},
""
))
pattern_LinkService_GetLinkMetadata_0
=
runtime
.
MustPattern
(
runtime
.
NewPattern
(
1
,
[]
int
{
2
,
0
,
2
,
1
,
2
,
2
},
[]
string
{
"api"
,
"v2"
,
"
link_
metadata"
},
""
))
)
)
var
(
var
(
...
...
server/route/api/v2/apidocs.swagger.yaml
View file @
335a0312
...
@@ -151,6 +151,25 @@ paths:
...
@@ -151,6 +151,25 @@ paths:
type
:
string
type
:
string
tags
:
tags
:
-
InboxService
-
InboxService
/api/v2/link_metadata
:
get
:
operationId
:
LinkService_GetLinkMetadata
responses
:
"
200"
:
description
:
A successful response.
schema
:
$ref
:
'
#/definitions/v2GetLinkMetadataResponse'
default
:
description
:
An unexpected error response.
schema
:
$ref
:
'
#/definitions/googlerpcStatus'
parameters
:
-
name
:
link
in
:
query
required
:
false
type
:
string
tags
:
-
LinkService
/api/v2/memos
:
/api/v2/memos
:
get
:
get
:
summary
:
ListMemos lists memos with pagination and filter.
summary
:
ListMemos lists memos with pagination and filter.
...
@@ -650,25 +669,6 @@ paths:
...
@@ -650,25 +669,6 @@ paths:
type
:
string
type
:
string
tags
:
tags
:
-
MemoService
-
MemoService
/api/v2/metadata
:
get
:
operationId
:
LinkService_GetLinkMetadata
responses
:
"
200"
:
description
:
A successful response.
schema
:
$ref
:
'
#/definitions/v2GetLinkMetadataResponse'
default
:
description
:
An unexpected error response.
schema
:
$ref
:
'
#/definitions/googlerpcStatus'
parameters
:
-
name
:
link
in
:
query
required
:
false
type
:
string
tags
:
-
LinkService
/api/v2/resources
:
/api/v2/resources
:
get
:
get
:
summary
:
ListResources lists all resources.
summary
:
ListResources lists all resources.
...
@@ -1813,7 +1813,7 @@ definitions:
...
@@ -1813,7 +1813,7 @@ definitions:
v2GetLinkMetadataResponse
:
v2GetLinkMetadataResponse
:
type
:
object
type
:
object
properties
:
properties
:
m
etadata
:
linkM
etadata
:
$ref
:
'
#/definitions/v2LinkMetadata'
$ref
:
'
#/definitions/v2LinkMetadata'
v2GetMemoByNameResponse
:
v2GetMemoByNameResponse
:
type
:
object
type
:
object
...
...
server/route/api/v2/link_service.go
View file @
335a0312
...
@@ -14,7 +14,7 @@ func (*APIV2Service) GetLinkMetadata(_ context.Context, request *apiv2pb.GetLink
...
@@ -14,7 +14,7 @@ func (*APIV2Service) GetLinkMetadata(_ context.Context, request *apiv2pb.GetLink
}
}
return
&
apiv2pb
.
GetLinkMetadataResponse
{
return
&
apiv2pb
.
GetLinkMetadataResponse
{
Metadata
:
&
apiv2pb
.
LinkMetadata
{
Link
Metadata
:
&
apiv2pb
.
LinkMetadata
{
Title
:
htmlMeta
.
Title
,
Title
:
htmlMeta
.
Title
,
Description
:
htmlMeta
.
Description
,
Description
:
htmlMeta
.
Description
,
Image
:
htmlMeta
.
Image
,
Image
:
htmlMeta
.
Image
,
...
...
web/src/components/MemoContent/Link.tsx
View file @
335a0312
import
{
Tooltip
,
Card
,
AspectRatio
,
Box
}
from
"@mui/joy"
;
import
{
Link
as
MLink
,
Tooltip
}
from
"@mui/joy"
;
import
{
Link
as
MLink
}
from
"@mui/joy"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
{
linkServiceClient
}
from
"@/grpcweb"
;
import
{
linkServiceClient
}
from
"@/grpcweb"
;
import
useResponsiveWidth
from
"@/hooks/useResponsiveWidth"
;
import
{
LinkMetadata
}
from
"@/types/proto/api/v2/link_service"
;
import
{
LinkMetadata
}
from
"@/types/proto/api/v2/link_service"
;
interface
Props
{
interface
Props
{
...
@@ -10,83 +8,49 @@ interface Props {
...
@@ -10,83 +8,49 @@ interface Props {
text
?:
string
;
text
?:
string
;
}
}
const
getFaviconWithGoogleS2
=
(
url
:
string
)
=>
{
try
{
const
urlObject
=
new
URL
(
url
);
return
`https://www.google.com/s2/favicons?sz=128&domain=
${
urlObject
.
hostname
}
`
;
}
catch
(
error
)
{
return
undefined
;
}
};
const
Link
:
React
.
FC
<
Props
>
=
({
text
,
url
}:
Props
)
=>
{
const
Link
:
React
.
FC
<
Props
>
=
({
text
,
url
}:
Props
)
=>
{
const
[
linkMetadata
,
setLinkMetadata
]
=
useState
<
LinkMetadata
|
undefined
>
();
const
[
linkMetadata
,
setLinkMetadata
]
=
useState
<
LinkMetadata
|
undefined
>
();
const
{
md
}
=
useResponsiveWidth
();
const
fetchUrlMetadata
=
async
()
=>
{
useEffect
(()
=>
{
(
async
()
=>
{
try
{
try
{
const
response
=
await
linkServiceClient
.
getLinkMetadata
({
link
:
url
},
{});
const
{
linkMetadata
}
=
await
linkServiceClient
.
getLinkMetadata
({
link
:
url
},
{});
setLinkMetadata
(
response
.
m
etadata
);
setLinkMetadata
(
linkM
etadata
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
"Error fetching URL metadata:"
,
error
);
console
.
error
(
"Error fetching URL metadata:"
,
error
);
return
null
;
}
}
};
})();
useEffect
(()
=>
{
fetchUrlMetadata
();
},
[
url
]);
},
[
url
]);
return
(
return
linkMetadata
?
(
<>
{
md
?
(
<
div
>
<
Tooltip
<
Tooltip
placement=
"top-end"
variant=
"outlined"
variant=
"solid"
sx=
{
{}
}
title=
{
title=
{
<
Box
<
div
className=
"w-full max-w-64 sm:max-w-96 p-1 flex flex-col"
>
sx=
{
{
<
a
href=
{
url
}
target=
"_blank"
rel=
"noopener noreferrer"
className=
"group w-full flex flex-row justify-start items-center gap-1"
>
display
:
"flex"
,
<
img
className=
"w-5 h-5 pointer-events-none"
src=
{
getFaviconWithGoogleS2
(
url
)
}
alt=
{
linkMetadata
?.
title
}
/>
flexDirection
:
"row"
,
<
h3
className=
"text-base truncate dark:opacity-90 group-hover:opacity-80"
>
{
linkMetadata
?.
title
}
</
h3
>
maxWidth
:
450
,
maxHeight
:
300
,
}
}
>
{
linkMetadata
?.
image
?
(
<
a
href=
{
url
}
target=
"_blank"
rel=
"noopener noreferrer"
className=
"flex w-full"
>
<
Card
variant=
"outlined"
orientation=
"vertical"
sx=
{
{
width
:
"100%"
}
}
>
<
AspectRatio
ratio=
{
"21/9"
}
objectFit=
"cover"
variant=
"plain"
>
<
img
src=
{
linkMetadata
?.
image
}
alt=
{
linkMetadata
?.
title
}
className=
"pointer-events-none"
/>
</
AspectRatio
>
<
div
className=
"flex-1 overflow-auto w-full"
>
<
div
className=
"flex flex-col justify-between "
>
<
div
>
<
h3
className=
"text-2xl font-semibold tracking-tight truncate"
>
{
linkMetadata
?.
title
}
</
h3
>
{
linkMetadata
?.
description
&&
<
p
className=
"text-sm truncate"
>
{
linkMetadata
?.
description
}
</
p
>
}
</
div
>
</
div
>
</
div
>
</
Card
>
</
a
>
</
a
>
)
:
(
{
linkMetadata
.
description
&&
(
<
Card
variant=
"soft"
orientation=
"vertical"
sx=
{
{
width
:
"100%"
}
}
>
<
p
className=
"mt-1 w-full text-sm leading-snug opacity-80 line-clamp-2"
>
{
linkMetadata
.
description
}
</
p
>
<
div
className=
"flex-1 overflow-auto w-full"
>
<
div
className=
"flex flex-col justify-between "
>
<
div
>
<
h3
className=
"text-2xl font-semibold tracking-tight"
>
{
linkMetadata
?.
title
}
</
h3
>
<
p
className=
"text-sm text-black/50 dark:text-white/50"
>
No Preview
</
p
>
</
div
>
</
div
>
</
div
>
</
Card
>
)
}
)
}
</
Box
>
</
div
>
}
}
arrow
>
>
<
MLink
href=
{
url
}
underline=
"none"
sx=
{
{
fontWeight
:
"lg"
}
}
>
<
MLink
href=
{
url
}
>
{
url
||
text
}
</
MLink
>
{
url
||
text
}
</
MLink
>
</
Tooltip
>
</
Tooltip
>
</
div
>
)
:
(
)
:
(
<
MLink
href=
{
url
}
underline=
"none"
sx=
{
{
fontWeight
:
"lg"
}
}
>
<
MLink
href=
{
url
}
>
{
url
||
text
}
</
MLink
>
{
url
||
text
}
</
MLink
>
)
}
</>
);
);
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment