Merge pull request #396 from Xyphyn/svelte-markdown
feat: switch to svelte-markdown
This commit is contained in:
30 files changed
+641
-323
No files matched your search
@@ -79,9 +79,9 @@ export const mediaType = (url?: string, view: View = 'cozy'): MediaType => {
|
||||
|
||||
return 'none'
|
||||
}
|
||||
export const iframeType = (post: Post): IframeType => {
|
||||
if (isVideo(post.url)) return 'video'
|
||||
if (isYoutubeLink(post.url)) return 'youtube'
|
||||
export const iframeType = (url: string): IframeType => {
|
||||
if (isVideo(url)) return 'video'
|
||||
if (isYoutubeLink(url)) return 'youtube'
|
||||
return 'none'
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
export let thumbnail: string | undefined = undefined
|
||||
export let url: string
|
||||
export let opened = !$userSettings.embeds.clickToView
|
||||
export let autoplay: boolean = $userSettings.embeds.clickToView
|
||||
|
||||
const urlToEmbed = (inputUrl: string) => {
|
||||
if (type == 'video') {
|
||||
@@ -52,11 +53,10 @@
|
||||
|
||||
const videoID = youtubeVideoID(inputUrl)
|
||||
|
||||
if ($userSettings.embeds.clickToView)
|
||||
url.searchParams.set('autoplay', '1')
|
||||
if (autoplay) url.searchParams.set('autoplay', '1')
|
||||
|
||||
return `https://${youtubeDomain(
|
||||
$userSettings.embeds.youtube,
|
||||
$userSettings.embeds.youtube
|
||||
)}/embed/${videoID}?${url.searchParams.toString()}`
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
}
|
||||
|
||||
const typeData = (
|
||||
type: IframeType,
|
||||
type: IframeType
|
||||
): {
|
||||
icon: IconSource
|
||||
text: string
|
||||
@@ -102,11 +102,7 @@
|
||||
{#if opened}
|
||||
{#if type == 'video'}
|
||||
<!-- svelte-ignore a11y-media-has-caption -->
|
||||
<video
|
||||
autoplay={$userSettings.embeds.clickToView}
|
||||
controls
|
||||
class="rounded-xl aspect-video"
|
||||
>
|
||||
<video {autoplay} controls class="rounded-xl aspect-video">
|
||||
<source src={url} />
|
||||
</video>
|
||||
{:else}
|
||||
@@ -116,7 +112,7 @@
|
||||
frameborder="0"
|
||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
||||
allowfullscreen
|
||||
class="aspect-video rounded-xl dark:bg-zinc-900"
|
||||
class="aspect-video rounded-xl dark:bg-zinc-900 {$$props.class ?? ''}"
|
||||
/>
|
||||
{/if}
|
||||
{:else}
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
{:else if (type == 'iframe' || type == 'video') && (view == 'cozy' || view == 'card') && post.url}
|
||||
<PostIframe
|
||||
thumbnail={post.thumbnail_url}
|
||||
type={iframeType(post)}
|
||||
type={iframeType(post.url)}
|
||||
url={post.url}
|
||||
{opened}
|
||||
/>
|
||||
|
||||
Reference in new issue
Block a user