mirror of
https://github.com/NohamR/lanyard-profile-readme.git
synced 2026-05-26 04:17:19 +00:00
🌟 Code Cleanup
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import type { AppProps } from 'next/app'
|
||||
|
||||
function MyApp({ Component, pageProps }: AppProps) {
|
||||
export default function LandyardReadMe({ Component, pageProps }: AppProps) {
|
||||
return <Component {...pageProps} />
|
||||
}
|
||||
export default MyApp
|
||||
|
||||
@@ -2,14 +2,14 @@ import Document from 'next/document'
|
||||
import { ServerStyleSheet } from 'styled-components'
|
||||
|
||||
export default class MyDocument extends Document {
|
||||
static async getInitialProps(ctx) {
|
||||
const sheet = new ServerStyleSheet()
|
||||
const originalRenderPage = ctx.renderPage
|
||||
static async getInitialProps(ctx: any) {
|
||||
const sheet = new ServerStyleSheet(),
|
||||
originalRenderPage = ctx.renderPage
|
||||
|
||||
try {
|
||||
ctx.renderPage = () =>
|
||||
originalRenderPage({
|
||||
enhanceApp: (App) => (props) =>
|
||||
enhanceApp: (App: any) => (props: any) =>
|
||||
sheet.collectStyles(<App {...props} />),
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ type Data = {
|
||||
}
|
||||
|
||||
type Parameters = {
|
||||
animated?: string;
|
||||
animated?: string;
|
||||
}
|
||||
|
||||
export default async function handler(
|
||||
@@ -17,24 +17,21 @@ export default async function handler(
|
||||
res: NextApiResponse<Data>
|
||||
) {
|
||||
|
||||
let params: Parameters = req.query;
|
||||
let userid = req.query.id[0];
|
||||
res.setHeader("Content-Type", "image/svg+xml; charset=utf-8");
|
||||
res.setHeader("content-security-policy", "default-src 'none'; img-src *; style-src 'unsafe-inline'");
|
||||
let params: Parameters = req.query,
|
||||
userid = req.query.id[0],
|
||||
lanyardData: any;
|
||||
|
||||
let lanyardData: any;
|
||||
|
||||
await axios.get(`https://api.lanyard.rest/v1/users/${userid}`)
|
||||
.then((response) => {
|
||||
return lanyardData = response;
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log(err);
|
||||
res.send({ error: `Something went wrong! If everything looks correct and this still occurs, please contact @cnraddd on Twitter.` })
|
||||
});
|
||||
res.setHeader("Content-Type", "image/svg+xml; charset=utf-8");
|
||||
res.setHeader("content-security-policy", "default-src 'none'; img-src * data:; style-src 'unsafe-inline'");
|
||||
|
||||
let svg = await renderCard(lanyardData.data, params);
|
||||
res.status(200).send(svg);
|
||||
try {
|
||||
lanyardData = (await axios.get(`https://api.lanyard.rest/v1/users/${userid}`)).data;
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
res.send({ error: `Something went wrong! If everything looks correct and this still occurs, please contact @cnraddd on Twitter.` })
|
||||
}
|
||||
|
||||
console.log(req.query);
|
||||
let svg = await renderCard(lanyardData.data, params);
|
||||
res.status(200).send(svg as any);
|
||||
}
|
||||
@@ -3,15 +3,13 @@ import styled from 'styled-components';
|
||||
import { useState } from 'react';
|
||||
|
||||
export default function Home() {
|
||||
|
||||
let [userId, setUserId] = useState(':id')
|
||||
const [userId, setUserId] = useState(':id')
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,200;1,300;1,400&display=swap" rel="stylesheet" />
|
||||
|
||||
<title>Lanyard for GitHub Profile</title>
|
||||
</Head>
|
||||
|
||||
@@ -19,28 +17,16 @@ export default function Home() {
|
||||
<Header>
|
||||
🏷️ lanyard-profile-readme
|
||||
</Header>
|
||||
|
||||
<Container>
|
||||
|
||||
<p style={{fontSize: "1rem", fontWeight: "bold", marginTop: "1rem"}}>Make sure you're in the <a style={{color: "#fff"}} rel="noreferrer" href="https://discord.com/invite/WScAm7vNGF">Discord</a> for this to work.</p>
|
||||
|
||||
<Input maxLength={18} type="text" placeholder="Paste your Discord user ID here" onChange={((e) => setUserId(e.target.value))}>
|
||||
|
||||
</Input>
|
||||
|
||||
<span style={{fontSize: "1rem", marginTop: "1rem"}}>Copy the following and paste it into your README.md</span>
|
||||
|
||||
<p style={{ fontSize: "1rem", fontWeight: "bold", marginTop: "1rem" }}>Make sure you're in the <a style={{ color: "#fff" }} rel="noreferrer" href="https://discord.com/invite/WScAm7vNGF">Discord</a> for this to work.</p>
|
||||
<Input maxLength={18} type="text" placeholder="Paste your Discord user ID here" onChange={((e) => setUserId(e.target.value))} />
|
||||
<span style={{ fontSize: "1rem", marginTop: "1rem" }}>Copy the following and paste it into your README.md</span>
|
||||
<Link>
|
||||
[](https://discord.com/users/{userId})
|
||||
</Link>
|
||||
|
||||
<span style={{fontSize: "1rem", fontStyle: "italic", marginTop: "1rem"}}>For further customization, check out the <a rel="noreferrer" target="_blank" href="https://github.com/cnrad/lanyard-profile-readme" style={{color: "#fff", fontWeight: "bold"}}>repo</a>!</span>
|
||||
|
||||
<Example src={`https://lanyard-profile-readme.vercel.app/api/${userId}`} alt="[Please provide a valid user ID!]" style={{color: "#ff8787"}}/>
|
||||
|
||||
|
||||
<span style={{ fontSize: "1rem", fontStyle: "italic", marginTop: "1rem" }}>For further customization, check out the <a rel="noreferrer" target="_blank" href="https://github.com/cnrad/lanyard-profile-readme" style={{ color: "#fff", fontWeight: "bold" }}>repo</a>!</span>
|
||||
<Example src={`https://lanyard-profile-readme.vercel.app/api/${userId}`} alt="[Please provide a valid user ID!]" style={{ color: "#ff8787" }} />
|
||||
</Container>
|
||||
|
||||
</Background>
|
||||
</>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user