mirror of
https://github.com/Sevichecc/Urara-Blog.git
synced 2025-04-30 14:29:29 +08:00
fix copybutton
This commit is contained in:
parent
683f42b9c8
commit
7e7745ea05
5 changed files with 21 additions and 3 deletions
|
@ -28,9 +28,18 @@
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
data-tip="RSS"
|
data-tip="RSS"
|
||||||
aria-label="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" />
|
<span class="i-ic-twotone-rss-feed !w-8 !h-8 mr-1 fill-current inline-block hover:text-lime-500" />
|
||||||
</a>
|
</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}
|
{#if site.author.email}
|
||||||
<a
|
<a
|
||||||
class="text-sm transition tooltip tooltip-secondary hover:text-secondary"
|
class="text-sm transition tooltip tooltip-secondary hover:text-secondary"
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
<Reply in_reply_to={post.in_reply_to} class="mt-4 mx-4" />
|
<Reply in_reply_to={post.in_reply_to} class="mt-4 mx-4" />
|
||||||
{/if}
|
{/if}
|
||||||
{#if post.image && preview}
|
{#if post.image && preview}
|
||||||
<figure class={`!block ${post.type === 'photo' ? '' : 'p-4 md:p-0'}`}>
|
<figure class="!block">
|
||||||
<Image
|
<Image
|
||||||
class={post.type === 'article'
|
class={post.type === 'article'
|
||||||
? 'u-featured object-center h-full w-full absolute group-hover:scale-105 transition-transform duration-500 ease-in-out'
|
? 'u-featured object-center h-full w-full absolute group-hover:scale-105 transition-transform duration-500 ease-in-out'
|
||||||
|
|
|
@ -7,6 +7,13 @@
|
||||||
import Action from '$lib/components/post_action.svelte'
|
import Action from '$lib/components/post_action.svelte'
|
||||||
import Footer from '$lib/components/footer.svelte'
|
import Footer from '$lib/components/footer.svelte'
|
||||||
export let post: Urara.Post
|
export let post: Urara.Post
|
||||||
|
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
import { copyCode } from '$lib/utils/copyCode'
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
copyCode()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Head {post} />
|
<Head {post} />
|
||||||
|
|
|
@ -13,5 +13,6 @@ export const site: SiteConfig = {
|
||||||
status: '🖤',
|
status: '🖤',
|
||||||
bio: ' Code / Tech <br> Living a Random Life '
|
bio: ' Code / Tech <br> Living a Random Life '
|
||||||
},
|
},
|
||||||
|
keywords: ['Tech', 'Code', 'Frontend Developer'],
|
||||||
themeColor: '#3D4451'
|
themeColor: '#3D4451'
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,12 @@ export const copyCode = () => {
|
||||||
range.setStart(el, 2)
|
range.setStart(el, 2)
|
||||||
range.setEnd(el, end)
|
range.setEnd(el, end)
|
||||||
const selection = window.getSelection()
|
const selection = window.getSelection()
|
||||||
|
if (!selection) return
|
||||||
selection.removeAllRanges()
|
selection.removeAllRanges()
|
||||||
selection.addRange(range)
|
selection.addRange(range)
|
||||||
|
|
||||||
// copy to clipboard
|
// copy to clipboard
|
||||||
document.execCommand('copy', false, null)
|
document.execCommand('copy', false)
|
||||||
const clip = async () => navigator.clipboard.writeText(selection.toString())
|
const clip = async () => navigator.clipboard.writeText(selection.toString())
|
||||||
|
|
||||||
if (!clip) return
|
if (!clip) return
|
||||||
|
|
Loading…
Reference in a new issue