Skip to content

Commit

Permalink
fix copybutton
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevichecc committed Aug 6, 2022
1 parent 683f42b commit 7e7745e
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
11 changes: 10 additions & 1 deletion src/lib/components/index_profile.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/post_card.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
7 changes: 7 additions & 0 deletions src/lib/components/post_container.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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} />
Expand Down
1 change: 1 addition & 0 deletions src/lib/config/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export const site: SiteConfig = {
status: '🖤',
bio: ' Code / Tech <br> Living a Random Life '
},
keywords: ['Tech', 'Code', 'Frontend Developer'],
themeColor: '#3D4451'
}
3 changes: 2 additions & 1 deletion src/lib/utils/copyCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

1 comment on commit 7e7745e

@vercel
Copy link

@vercel vercel bot commented on 7e7745e Aug 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.