From 7e7745ea05047b663593bbb854dc8cacc0f87348 Mon Sep 17 00:00:00 2001 From: Sevichecc <91365763+Sevichecc@users.noreply.github.com> Date: Sat, 6 Aug 2022 22:49:10 +0800 Subject: [PATCH] fix copybutton --- src/lib/components/index_profile.svelte | 11 ++++++++++- src/lib/components/post_card.svelte | 2 +- src/lib/components/post_container.svelte | 7 +++++++ src/lib/config/site.ts | 1 + src/lib/utils/copyCode.ts | 3 ++- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/lib/components/index_profile.svelte b/src/lib/components/index_profile.svelte index 03b2b435..7aff0fc5 100644 --- a/src/lib/components/index_profile.svelte +++ b/src/lib/components/index_profile.svelte @@ -28,9 +28,18 @@ rel="noopener noreferrer" data-tip="RSS" aria-label="RSS" - href="https://seviche.cc/atom.xml"> + href="/atom.xml"> + + + {#if site.author.email} {/if} {#if post.image && preview} -
+
{ + copyCode() + }) diff --git a/src/lib/config/site.ts b/src/lib/config/site.ts index 9c36dbb3..eb9fbc8f 100644 --- a/src/lib/config/site.ts +++ b/src/lib/config/site.ts @@ -13,5 +13,6 @@ export const site: SiteConfig = { status: '🖤', bio: ' Code / Tech
Living a Random Life ' }, + keywords: ['Tech', 'Code', 'Frontend Developer'], themeColor: '#3D4451' } diff --git a/src/lib/utils/copyCode.ts b/src/lib/utils/copyCode.ts index dbc6354e..c96509e9 100644 --- a/src/lib/utils/copyCode.ts +++ b/src/lib/utils/copyCode.ts @@ -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