cleanup: remove post link sources
This commit is contained in:
1 parent
8191093b46
commit
8644f3fff2
2 files changed
+23
-141
No files matched your search
@@ -8,7 +8,6 @@
|
|||||||
Link as LinkIcon,
|
Link as LinkIcon,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import { optimizeImageURL } from '../helpers'
|
import { optimizeImageURL } from '../helpers'
|
||||||
import PostLinkSources from './PostLinkSources.svelte'
|
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import type { View } from '$lib/settings.svelte'
|
import type { View } from '$lib/settings.svelte'
|
||||||
|
|
||||||
@@ -111,68 +110,29 @@
|
|||||||
</a>
|
</a>
|
||||||
{/if}
|
{/if}
|
||||||
</Material>
|
</Material>
|
||||||
<div
|
|
||||||
class="bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800
|
|
||||||
rounded-full flex p-1 relative -top-7 min-[384px]:mx-3 mt-8 min-[384px]:mt-0 mx-auto -mb-7 w-max max-w-full overflow-auto"
|
|
||||||
>
|
|
||||||
<PostLinkSources {url}>
|
|
||||||
{#snippet target()}
|
|
||||||
<Button
|
|
||||||
color="tertiary"
|
|
||||||
size="sm"
|
|
||||||
class="w-max text-slate-600 dark:text-zinc-400 block
|
|
||||||
text-xs flex-shrink-0"
|
|
||||||
rounding="pill"
|
|
||||||
>
|
|
||||||
<Icon src={LinkIcon} size="16" micro class="flex-shrink-0" />
|
|
||||||
{$t('post.actions.link.actions')}
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
|
||||||
</PostLinkSources>
|
|
||||||
</div>
|
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex space-x-1">
|
<Button
|
||||||
<PostLinkSources {url}>
|
href={url}
|
||||||
{#snippet target()}
|
target="_blank"
|
||||||
<Button
|
class="text-slate-900 dark:text-zinc-300 items-center
|
||||||
color="ghost"
|
|
||||||
size="xs"
|
|
||||||
rounding="pill"
|
|
||||||
class="p-0.5 px-1 w-max mt-auto text-slate-600 dark:text-zinc-400 block
|
|
||||||
text-xs"
|
|
||||||
>
|
|
||||||
<div class="mr-0.5" style="width: 8px;">
|
|
||||||
<Icon src={LinkIcon} size="16" micro />
|
|
||||||
</div>
|
|
||||||
<div class="mr-1" style="width: 8px;">
|
|
||||||
<Icon src={ChevronDown} size="16" micro />
|
|
||||||
</div>
|
|
||||||
</Button>
|
|
||||||
{/snippet}
|
|
||||||
</PostLinkSources>
|
|
||||||
<Button
|
|
||||||
href={url}
|
|
||||||
target="_blank"
|
|
||||||
class="text-slate-900 dark:text-zinc-300 items-center
|
|
||||||
text-xs overflow-hidden max-w-full block flex-shrink"
|
text-xs overflow-hidden max-w-full block flex-shrink"
|
||||||
size="xs"
|
size="xs"
|
||||||
color="ghost"
|
color="ghost"
|
||||||
rounding="pill"
|
rounding="pill"
|
||||||
>
|
>
|
||||||
{#if richURL}
|
{#if richURL}
|
||||||
<div class="flex max-w-full overflow-hidden font-medium">
|
<div class="flex max-w-full overflow-hidden font-medium">
|
||||||
{richURL.hostname}
|
{richURL.hostname}
|
||||||
{#if richURL.pathname != '/'}
|
{#if richURL.pathname != '/'}
|
||||||
<span
|
<span
|
||||||
class="text-slate-500 dark:text-zinc-500 whitespace-nowrap font-normal"
|
class="text-slate-500 dark:text-zinc-500 whitespace-nowrap font-normal"
|
||||||
>
|
>
|
||||||
{richURL.pathname}
|
{richURL.pathname}
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
{url}
|
{url}
|
||||||
{/if}
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
<script lang="ts" module>
|
|
||||||
const sources: {
|
|
||||||
getLink: (url: string) => string
|
|
||||||
name: string
|
|
||||||
type: MediaType
|
|
||||||
}[] = [
|
|
||||||
{
|
|
||||||
getLink: (url: string) =>
|
|
||||||
`https://archive.ph/${encodeURIComponent(url.split('?')[0])}`,
|
|
||||||
name: 'Archive Today',
|
|
||||||
type: 'embed',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
getLink: (url: string) =>
|
|
||||||
`https://ghostarchive.org/search?term=${encodeURIComponent(url.split('?')[0])}`,
|
|
||||||
name: 'Ghost Archive',
|
|
||||||
type: 'embed',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
getLink: (url: string) =>
|
|
||||||
`https://12ft.io/proxy?q=${encodeURIComponent(url.split('?')[0])}`,
|
|
||||||
name: '12ft.io',
|
|
||||||
type: 'embed',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
getLink: (url: string) =>
|
|
||||||
`https://ground.news/find?url=${encodeURIComponent(url.split('?')[0])}`,
|
|
||||||
name: 'Ground News',
|
|
||||||
type: 'embed',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
getLink: (url: string) =>
|
|
||||||
`https://spinscore.io/?url=${encodeURIComponent(url.split('?')[0])}`,
|
|
||||||
name: 'spinscore.io',
|
|
||||||
type: 'embed',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
|
||||||
import { t } from '$lib/translations'
|
|
||||||
import { Menu, MenuButton, MenuDivider, toast } from 'mono-svelte'
|
|
||||||
import type { MediaType } from '../helpers'
|
|
||||||
import { Icon, Share } from 'svelte-hero-icons'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
url: string
|
|
||||||
type?: MediaType
|
|
||||||
target?: import('svelte').Snippet
|
|
||||||
[key: string]: any
|
|
||||||
}
|
|
||||||
|
|
||||||
let { url, type = 'embed', target, ...rest }: Props = $props()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<Menu {target} {...rest}>
|
|
||||||
<MenuDivider>{$t('post.actions.link.title')}</MenuDivider>
|
|
||||||
{#each sources as source}
|
|
||||||
{#if source.type == type}
|
|
||||||
<MenuButton target="_blank" href={source.getLink(url)}>
|
|
||||||
{source.name}
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
<MenuDivider>{$t('post.actions.link.actions')}</MenuDivider>
|
|
||||||
<MenuButton
|
|
||||||
onclick={() => {
|
|
||||||
navigator?.share?.({ url: url }) ?? navigator?.clipboard?.writeText?.(url)
|
|
||||||
|
|
||||||
toast({ content: $t('toast.copied') })
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{#snippet prefix()}
|
|
||||||
<Icon src={Share} size="16" micro />
|
|
||||||
{/snippet}
|
|
||||||
{$t('post.actions.more.share')}
|
|
||||||
</MenuButton>
|
|
||||||
</Menu>
|
|
||||||
Reference in new issue
Block a user