-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
16 changed files
with
101 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
yarn lint-staged | ||
yarn 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,26 +1,26 @@ | ||
import React from 'react'; | ||
|
||
type Props = { | ||
contents: string, | ||
contents: string; | ||
}; | ||
|
||
function CodeBox({ contents }: Props) { | ||
|
||
const handleClick = () => { | ||
navigator.clipboard.writeText(contents); | ||
// TODO: 다른 UI로 대체 | ||
alert('Copied!') | ||
alert('Copied!'); | ||
}; | ||
|
||
return ( | ||
<div className="mockup-code bg-base-300 text-base-content cursor-pointer before:hidden my-4" onClick={handleClick}> | ||
<div | ||
className="mockup-code bg-base-300 text-base-content cursor-pointer before:hidden my-4" | ||
onClick={handleClick} | ||
> | ||
<pre> | ||
<code> | ||
{contents} | ||
</code> | ||
<code>{contents}</code> | ||
</pre> | ||
</div> | ||
); | ||
} | ||
|
||
export default CodeBox; | ||
export default CodeBox; |
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 |
---|---|---|
|
@@ -37,5 +37,4 @@ function Footer() { | |
); | ||
} | ||
|
||
|
||
export default Footer; | ||
export default Footer; |
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
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,8 +1,8 @@ | ||
import '../styles/globals.css' | ||
import type { AppProps } from 'next/app' | ||
import '../styles/globals.css'; | ||
import type { AppProps } from 'next/app'; | ||
|
||
function MyApp({ Component, pageProps }: AppProps) { | ||
return <Component {...pageProps} /> | ||
return <Component {...pageProps} />; | ||
} | ||
|
||
export default MyApp | ||
export default MyApp; |
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 |
---|---|---|
|
@@ -29,4 +29,4 @@ function Document() { | |
); | ||
} | ||
|
||
export default Document; | ||
export default Document; |
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,24 +1,22 @@ | ||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction | ||
import type { NextApiRequest, NextApiResponse } from 'next' | ||
import type { NextApiRequest, NextApiResponse } from 'next'; | ||
|
||
import { getMoonPhases } from '../../../server/utils/moon'; | ||
import { createMoon } from '../../../server/utils/svg'; | ||
|
||
|
||
export default async function handler( | ||
req: NextApiRequest, | ||
res: NextApiResponse | ||
res: NextApiResponse, | ||
) { | ||
const { date, size = '100' } = req.query; | ||
|
||
const { k, isWaxing } = await getMoonPhases(date ? new Date(date as string) : undefined); | ||
const { k, isWaxing } = await getMoonPhases( | ||
date ? new Date(date as string) : undefined, | ||
); | ||
const moonSvg = createMoon(k, isWaxing, size as string); | ||
|
||
res.setHeader('Content-Type', 'image/svg+xml'); | ||
res.setHeader( | ||
"Cache-Control", | ||
"s-maxage=3600, max-age=3600" | ||
); | ||
res.setHeader('Cache-Control', 's-maxage=3600, max-age=3600'); | ||
|
||
res.status(200).end(moonSvg); | ||
} |
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,12 +1,12 @@ | ||
import {createTimeOfInterest} from 'astronomy-bundle/time'; | ||
import {createMoon} from 'astronomy-bundle/moon'; | ||
import { createTimeOfInterest } from 'astronomy-bundle/time'; | ||
import { createMoon } from 'astronomy-bundle/moon'; | ||
|
||
export const getMoonPhases = async (date: Date = new Date()) => { | ||
const toi = createTimeOfInterest.fromDate(date); | ||
const moon = createMoon(toi); | ||
|
||
const k = await moon.getIlluminatedFraction(); | ||
const isWaxing = await moon.isWaxing(); | ||
|
||
return { k, isWaxing }; | ||
} | ||
}; |
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,13 +1,10 @@ | ||
type QueryParameters = { [key: string]: any }; | ||
export const objectToQueryString = (queryParameters: QueryParameters) => { | ||
return queryParameters | ||
? Object.entries(queryParameters).reduce( | ||
(queryString, [key, value]) => { | ||
const symbol = queryString.length === 0 ? '?' : '&'; | ||
queryString += value ? `${symbol}${key}=${value}` : ''; | ||
return queryString; | ||
}, | ||
'' | ||
) | ||
? Object.entries(queryParameters).reduce((queryString, [key, value]) => { | ||
const symbol = queryString.length === 0 ? '?' : '&'; | ||
queryString += value ? `${symbol}${key}=${value}` : ''; | ||
return queryString; | ||
}, '') | ||
: ''; | ||
}; | ||
}; |
a2044f5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: