@@ -923,6 +923,25 @@ export default class InvioPlugin extends Plugin {
923
923
await this . syncRun ( 'manual' , [ file . path ] )
924
924
} ) ;
925
925
} )
926
+ . addItem ( ( item ) => {
927
+ item
928
+ . setTitle ( `${ Menu_Tab } ${ t ( 'menu_get_link' ) } ` )
929
+ . setIcon ( "document" )
930
+ . onClick ( async ( ) => {
931
+ const filePath = file . path ;
932
+ const link = await this . getRemoteLink ( filePath ) ;
933
+ if ( link ) {
934
+ await navigator . clipboard . writeText ( link ) ;
935
+ new Notice (
936
+ this . t ( "syncrun_copy_link_msg" )
937
+ ) ;
938
+ } else {
939
+ new Notice (
940
+ this . t ( "syncrun_copy_link_null_msg" )
941
+ ) ;
942
+ }
943
+ } ) ;
944
+ } )
926
945
}
927
946
} )
928
947
) ;
@@ -1173,12 +1192,37 @@ export default class InvioPlugin extends Plugin {
1173
1192
const slug = this . settings . hostConfig ?. hostPair . slug ;
1174
1193
domain = `https://${ slug } .${ ServerDomain } ` ;
1175
1194
} else {
1195
+ if ( ! this . settings . s3 . s3BucketName ) return '' ;
1176
1196
domain = `https://${ this . settings . s3 . s3BucketName } .${ this . settings . s3 . s3Endpoint } ` ;
1177
1197
}
1178
1198
}
1179
1199
return domain ;
1180
1200
}
1181
1201
1202
+ async getRemoteLink ( pathName : string ) {
1203
+ const domain = this . getRemoteDomain ( ) ;
1204
+ if ( ! domain ) {
1205
+ new Notice (
1206
+ this . t ( "syncrun_no_domain_err" )
1207
+ ) ;
1208
+ return ;
1209
+ }
1210
+ // TODO: Get remote link, but need remote domain first
1211
+ const client = new RemoteClient (
1212
+ this . settings . serviceType ,
1213
+ this . settings . s3 ,
1214
+ this . settings . hostConfig ,
1215
+ this . settings . useHost ,
1216
+ this . settings . localWatchDir ,
1217
+ this . app . vault . getName ( ) ,
1218
+ ) ;
1219
+ const publishedKey = client . getUseHostSlugPath ( pathName )
1220
+ // Check remote link
1221
+ const remoteContents = await client . listFromRemote ( publishedKey ?. split ( '/' ) . slice ( 0 , - 1 ) . join ( '/' ) , RemoteSrcPrefix ) ;
1222
+ const existed = remoteContents . find ( item => item . key === ( RemoteSrcPrefix + publishedKey ) . replace ( '//' , '/' ) )
1223
+ return existed ? ( domain + `/${ publishedKey . replace ( / \. m d $ / , '.html' ) } ` ) : null
1224
+ }
1225
+
1182
1226
async enableHostService ( ) {
1183
1227
if ( ! this . settings . localWatchDir ) {
1184
1228
new Notice ( this . t ( 'syncrun_no_watchdir_err' ) ) ;
0 commit comments