fix copybutton

This commit is contained in:
Sevichecc 2022-08-06 22:49:10 +08:00
parent 683f42b9c8
commit 7e7745ea05
5 changed files with 21 additions and 3 deletions

View file

@ -28,9 +28,18 @@
rel="noopener noreferrer"
data-tip="RSS"
aria-label="RSS"
href="https://seviche.cc/atom.xml">
href="/atom.xml">
<span class="i-ic-twotone-rss-feed !w-8 !h-8 mr-1 fill-current inline-block hover:text-lime-500" />
</a>
<a
class="text-sm transition tooltip tooltip-secondary hover:text-secondary"
target="_blank"
rel="noopener noreferrer"
data-tip="Bookmark"
aria-label="Bookmark"
href="https://airtable.com/shrpftxf6JgRomP2X">
<span class="ic:baseline-bookmarks !w-8 !h-8 mr-1 fill-current inline-block hover:text-lime-500" />
</a>
{#if site.author.email}
<a
class="text-sm transition tooltip tooltip-secondary hover:text-secondary"

View file

@ -55,7 +55,7 @@
<Reply in_reply_to={post.in_reply_to} class="mt-4 mx-4" />
{/if}
{#if post.image && preview}
<figure class={`!block ${post.type === 'photo' ? '' : 'p-4 md:p-0'}`}>
<figure class="!block">
<Image
class={post.type === 'article'
? 'u-featured object-center h-full w-full absolute group-hover:scale-105 transition-transform duration-500 ease-in-out'

View file

@ -7,6 +7,13 @@
import Action from '$lib/components/post_action.svelte'
import Footer from '$lib/components/footer.svelte'
export let post: Urara.Post
import { onMount } from 'svelte'
import { copyCode } from '$lib/utils/copyCode'
onMount(() => {
copyCode()
})
</script>
<Head {post} />

View file

@ -13,5 +13,6 @@ export const site: SiteConfig = {
status: '🖤',
bio: ' Code / Tech <br> Living a Random Life '
},
keywords: ['Tech', 'Code', 'Frontend Developer'],
themeColor: '#3D4451'
}

View file

@ -16,11 +16,12 @@ export const copyCode = () => {
range.setStart(el, 2)
range.setEnd(el, end)
const selection = window.getSelection()
if (!selection) return
selection.removeAllRanges()
selection.addRange(range)
// copy to clipboard
document.execCommand('copy', false, null)
document.execCommand('copy', false)
const clip = async () => navigator.clipboard.writeText(selection.toString())
if (!clip) return