-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update 'To The Top' button to become visible when scrolling
- Loading branch information
1 parent
cfb274b
commit ed051db
Showing
5 changed files
with
85 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
const useScrollPosition = () => { | ||
const [scrollPosition, setScrollPosition] = useState(0); | ||
|
||
useEffect(() => { | ||
const updatePosition = () => { | ||
setScrollPosition(window.pageYOffset); | ||
}; | ||
window.addEventListener("scroll", updatePosition); | ||
updatePosition(); | ||
return () => window.removeEventListener("scroll", updatePosition); | ||
}, []); | ||
|
||
return scrollPosition; | ||
}; | ||
|
||
export default useScrollPosition; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,45 @@ | ||
--- | ||
import '@assets/styles/global.scss'; | ||
import Footer from '@components/Footer/Footer'; | ||
import OverlayButtons from '@components/OverlayButtons/OverlayButtons'; | ||
const { title, description, url } = Astro.props; | ||
const openGraphImage = "https://killedby.tech/images/og.png"; | ||
const disableTracking = import.meta.env.DEV; | ||
import "@assets/styles/global.scss"; | ||
import Footer from "@components/Footer/Footer"; | ||
import OverlayButtons from "@components/OverlayButtons/OverlayButtons"; | ||
const { title, description, url } = Astro.props; | ||
const openGraphImage = "https://killedby.tech/images/og.png"; | ||
const disableTracking = import.meta.env.DEV; | ||
--- | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width"> | ||
<meta name="description" content={ description }> | ||
<meta property="og:url" content={ url }> | ||
<meta property="og:type" content="website"> | ||
<meta property="og:title" content={ title }> | ||
<meta property="og:description" content={ description }> | ||
<meta property="og:image" content={ openGraphImage }> | ||
<meta name="twitter:card" content="summary_large_image"> | ||
<meta property="twitter:domain" content="killedby.tech"> | ||
<meta property="twitter:url" content={ url }> | ||
<meta name="twitter:title" content={ title }> | ||
<meta name="twitter:description" content={ description }> | ||
<meta name="twitter:image" content={ openGraphImage }> | ||
<link rel="icon" href="/images/favicon.svg" type="image/svg+xml"> | ||
<title>{ title }</title> | ||
</head> | ||
<body> | ||
<main> | ||
<slot /> | ||
</main> | ||
<Footer /> | ||
<OverlayButtons /> | ||
{disableTracking ? null : <script src="https://cdn.usefathom.com/script.js" data-site="SNZPDDNM" defer></script>} | ||
</body> | ||
</html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width" /> | ||
<meta name="description" content={description} /> | ||
<meta property="og:url" content={url} /> | ||
<meta property="og:type" content="website" /> | ||
<meta property="og:title" content={title} /> | ||
<meta property="og:description" content={description} /> | ||
<meta property="og:image" content={openGraphImage} /> | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
<meta property="twitter:domain" content="killedby.tech" /> | ||
<meta property="twitter:url" content={url} /> | ||
<meta name="twitter:title" content={title} /> | ||
<meta name="twitter:description" content={description} /> | ||
<meta name="twitter:image" content={openGraphImage} /> | ||
<link rel="icon" href="/images/favicon.svg" type="image/svg+xml" /> | ||
<title>{title}</title> | ||
</head> | ||
<body> | ||
<main> | ||
<slot /> | ||
</main> | ||
<Footer /> | ||
<OverlayButtons client:idle /> | ||
{ | ||
disableTracking ? null : ( | ||
<script | ||
src="https://cdn.usefathom.com/script.js" | ||
data-site="SNZPDDNM" | ||
defer | ||
/> | ||
) | ||
} | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters