-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b943a0a
commit d12832f
Showing
67 changed files
with
14,250 additions
and
20,659 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
node_modules | ||
|
||
pages/index.tsx | ||
node_modules |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npx --no-install lint-staged | ||
npx --no-install lint-staged |
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 +1 @@ | ||
[My blog](https://harrycodes.com) :) | ||
My blog :) |
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,23 @@ | ||
import { useEffect } from 'react' | ||
import Router from 'next/router' | ||
|
||
/** | ||
* Client-side complement to next-remote-watch | ||
* Re-triggers getStaticProps when watched mdx files change | ||
* | ||
*/ | ||
export const ClientReload = () => { | ||
// Exclude socket.io from prod bundle | ||
useEffect(() => { | ||
import('socket.io-client').then((module) => { | ||
const socket = module.io() | ||
socket.on('reload', () => { | ||
Router.replace(Router.asPath, undefined, { | ||
scroll: false, | ||
}) | ||
}) | ||
}) | ||
}, []) | ||
|
||
return null | ||
} |
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,84 +1,84 @@ | ||
import { useRef, useState } from 'react' | ||
import React, { useRef, useState } from 'react' | ||
|
||
import siteMetadata from '@/data/siteMetadata' | ||
|
||
const NewsletterForm = ({ title = 'Subscribe to the newsletter' }) => { | ||
const inputEl = useRef(null) | ||
const [error, setError] = useState(false) | ||
const [message, setMessage] = useState('') | ||
const [subscribed, setSubscribed] = useState(false) | ||
const inputEl = useRef<HTMLInputElement>(null) | ||
const [error, setError] = useState(false) | ||
const [message, setMessage] = useState('') | ||
const [subscribed, setSubscribed] = useState(false) | ||
|
||
const subscribe = async (e) => { | ||
e.preventDefault() | ||
const subscribe = async (e: React.FormEvent<HTMLFormElement>) => { | ||
e.preventDefault() | ||
|
||
const res = await fetch(`/api/${siteMetadata.newsletter.provider}`, { | ||
body: JSON.stringify({ | ||
email: inputEl.current.value, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
method: 'POST', | ||
}) | ||
const res = await fetch(`/api/${siteMetadata.newsletter.provider}`, { | ||
body: JSON.stringify({ | ||
email: inputEl.current.value, | ||
}), | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
method: 'POST', | ||
}) | ||
|
||
const { error } = await res.json() | ||
if (error) { | ||
setError(true) | ||
setMessage('Your e-mail address is invalid or you are already subscribed!') | ||
return | ||
} | ||
|
||
inputEl.current.value = '' | ||
setError(false) | ||
setSubscribed(true) | ||
setMessage('Successfully! 🎉 You are now subscribed.') | ||
const { error } = await res.json() | ||
if (error) { | ||
setError(true) | ||
setMessage('Your e-mail address is invalid or you are already subscribed!') | ||
return | ||
} | ||
|
||
return ( | ||
inputEl.current.value = '' | ||
setError(false) | ||
setSubscribed(true) | ||
setMessage('Successfully! 🎉 You are now subscribed.') | ||
} | ||
|
||
return ( | ||
<div> | ||
<div className="pb-1 text-lg font-semibold text-gray-800 dark:text-gray-100">{title}</div> | ||
<form className="flex flex-col sm:flex-row" onSubmit={subscribe}> | ||
<div> | ||
<div className="pb-1 text-lg font-semibold text-gray-800 dark:text-gray-100">{title}</div> | ||
<form className="flex flex-col sm:flex-row" onSubmit={subscribe}> | ||
<div> | ||
<label className="sr-only" htmlFor="email-input"> | ||
Email address | ||
</label> | ||
<input | ||
autoComplete="email" | ||
className="w-72 rounded-md px-4 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-primary-600 dark:bg-black" | ||
id="email-input" | ||
name="email" | ||
placeholder={subscribed ? "You're subscribed ! 🎉" : 'Enter your email'} | ||
ref={inputEl} | ||
required | ||
type="email" | ||
disabled={subscribed} | ||
/> | ||
</div> | ||
<div className="mt-2 flex w-full rounded-md shadow-sm sm:mt-0 sm:ml-3"> | ||
<button | ||
className={`w-full rounded-md bg-primary-500 py-2 px-4 font-medium text-white sm:py-0 ${ | ||
subscribed ? 'cursor-default' : 'hover:bg-primary-700 dark:hover:bg-primary-400' | ||
} focus:outline-none focus:ring-2 focus:ring-primary-600 focus:ring-offset-2 dark:ring-offset-black`} | ||
type="submit" | ||
disabled={subscribed} | ||
> | ||
{subscribed ? 'Thank you!' : 'Sign up'} | ||
</button> | ||
</div> | ||
</form> | ||
{error && ( | ||
<div className="w-72 pt-2 text-sm text-red-500 dark:text-red-400 sm:w-96">{message}</div> | ||
)} | ||
<label className="sr-only" htmlFor="email-input"> | ||
Email address | ||
</label> | ||
<input | ||
autoComplete="email" | ||
className="w-72 rounded-md px-4 focus:border-transparent focus:outline-none focus:ring-2 focus:ring-primary-600 dark:bg-black" | ||
id="email-input" | ||
name="email" | ||
placeholder={subscribed ? "You're subscribed ! 🎉" : 'Enter your email'} | ||
ref={inputEl} | ||
required | ||
type="email" | ||
disabled={subscribed} | ||
/> | ||
</div> | ||
<div className="mt-2 flex w-full rounded-md shadow-sm sm:mt-0 sm:ml-3"> | ||
<button | ||
className={`w-full rounded-md bg-primary-500 py-2 px-4 font-medium text-white sm:py-0 ${ | ||
subscribed ? 'cursor-default' : 'hover:bg-primary-700 dark:hover:bg-primary-400' | ||
} focus:outline-none focus:ring-2 focus:ring-primary-600 focus:ring-offset-2 dark:ring-offset-black`} | ||
type="submit" | ||
disabled={subscribed} | ||
> | ||
{subscribed ? 'Thank you!' : 'Sign up'} | ||
</button> | ||
</div> | ||
) | ||
</form> | ||
{error && ( | ||
<div className="w-72 pt-2 text-sm text-red-500 dark:text-red-400 sm:w-96">{message}</div> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default NewsletterForm | ||
|
||
export const BlogNewsletterForm = ({ title }) => ( | ||
<div className="flex items-center justify-center"> | ||
<div className="bg-gray-100 p-6 dark:bg-gray-800 sm:px-14 sm:py-8"> | ||
<NewsletterForm title={title} /> | ||
</div> | ||
<div className="flex items-center justify-center"> | ||
<div className="bg-gray-100 p-6 dark:bg-gray-800 sm:px-14 sm:py-8"> | ||
<NewsletterForm title={title} /> | ||
</div> | ||
) | ||
</div> | ||
) |
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
Oops, something went wrong.