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,5 +1,5 @@
|
|||||||
import type { AppProps } from 'next/app'
|
import type { AppProps } from 'next/app'
|
||||||
|
|
||||||
export default function LandyardReadMe({ Component, pageProps }: AppProps) {
|
export default function LanyardReadMe({ Component, pageProps }: AppProps) {
|
||||||
return <Component {...pageProps} />
|
return <Component {...pageProps} />
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,32 +116,28 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
transform: translate(0, -50%);
|
transform: translate(0, -50%);
|
||||||
height: 25px;
|
height: 25px;
|
||||||
">
|
">
|
||||||
|
|
||||||
<h1 style="
|
<h1 style="
|
||||||
font-size: 1.15rem;
|
font-size: 1.15rem;
|
||||||
margin: 0 5px 0 0;
|
margin: 0 5px 0 0;
|
||||||
">
|
">
|
||||||
${body.data.discord_user.username}${discrim !== 'hide' ?
|
${body.data.discord_user.username}${discrim !== 'hide' ? `
|
||||||
`<span style="color: ${theme === 'dark' ? '#ccc' : '#666'}; font-weight: lighter;">#${body.data.discord_user.discriminator}</span>`
|
<span style="color: ${theme === 'dark' ? '#ccc' : '#666'}; font-weight: lighter;">#${body.data.discord_user.discriminator}</span>` : ''}
|
||||||
: ''}
|
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
${flags.map((v) => {
|
${flags.map((v) => {
|
||||||
return (
|
return (`
|
||||||
`<img src="data:image/png;base64,${Badges[v]}" style="
|
<img src="data:image/png;base64,${Badges[v]}" style="
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
transform: translate(0%, -50%);
|
transform: translate(0%, -50%);
|
||||||
margin: 0 0 0 4px;
|
margin: 0 0 0 4px;
|
||||||
" />`
|
" />`
|
||||||
)
|
)
|
||||||
}).join('')
|
}).join('')
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${userStatus.length > 0 && hideStatus !== "true" ? `
|
${userStatus.length > 0 && hideStatus !== "true" ? `
|
||||||
<h1 style="
|
<h1 style="
|
||||||
font-size: 0.9rem;
|
font-size: 0.9rem;
|
||||||
@@ -152,31 +148,27 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
">
|
">
|
||||||
${body.data.activities[0].emoji && body.data.activities[0].emoji.id ?
|
${body.data.activities[0].emoji && body.data.activities[0].emoji.id ? `
|
||||||
`<img src="data:image/png;base64,${await encodeBase64(`https://cdn.discordapp.com/emojis/${body.data.activities[0].emoji.id}.${statusExtension}`)}" style="
|
<img src="data:image/png;base64,${await encodeBase64(`https://cdn.discordapp.com/emojis/${body.data.activities[0].emoji.id}.${statusExtension}`)}" style="
|
||||||
width: 15px;
|
width: 15px;
|
||||||
height: 15px;
|
height: 15px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
transform: translate(0%, -50%);
|
transform: translate(0%, -50%);
|
||||||
margin: 0 2px 0 0;
|
margin: 0 2px 0 0;
|
||||||
" />`
|
" />`
|
||||||
: ``}
|
: ``}
|
||||||
|
|
||||||
${body.data.activities[0].emoji && !body.data.activities[0].emoji.id ?
|
${body.data.activities[0].emoji && !body.data.activities[0].emoji.id ?
|
||||||
body.data.activities[0].emoji.name + ' ' + userStatus
|
body.data.activities[0].emoji.name + ' ' + userStatus
|
||||||
:
|
:
|
||||||
userStatus
|
userStatus
|
||||||
}
|
}
|
||||||
|
</h1>` : ``}
|
||||||
</h1>`
|
|
||||||
: ``}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
${activity ?
|
${activity ? `
|
||||||
|
|
||||||
`
|
|
||||||
<div style="
|
<div style="
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
@@ -190,16 +182,14 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
width: auto;
|
width: auto;
|
||||||
height: auto;
|
height: auto;
|
||||||
">
|
">
|
||||||
${activity.assets && activity.assets.large_image ?
|
${activity.assets && activity.assets.large_image ? `
|
||||||
`
|
|
||||||
<img src="data:image/png;base64,${await encodeBase64(`https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.large_image}.webp`)}" style="
|
<img src="data:image/png;base64,${await encodeBase64(`https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.large_image}.webp`)}" style="
|
||||||
width: 80px;
|
width: 80px;
|
||||||
height: 80px;
|
height: 80px;
|
||||||
border: solid 0.5px #222;
|
border: solid 0.5px #222;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
"/>
|
"/>
|
||||||
`
|
` : `
|
||||||
: `
|
|
||||||
<img src="data:image/png;base64,${await encodeBase64(`https://lanyard-profile-readme.vercel.app/assets/unknown.png`)}" style="
|
<img src="data:image/png;base64,${await encodeBase64(`https://lanyard-profile-readme.vercel.app/assets/unknown.png`)}" style="
|
||||||
width: 70px;
|
width: 70px;
|
||||||
height: 70px;
|
height: 70px;
|
||||||
@@ -207,17 +197,14 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
filter: invert(100);
|
filter: invert(100);
|
||||||
"/>
|
"/>
|
||||||
`}
|
`}
|
||||||
|
${activity.assets && activity.assets.small_image ? `
|
||||||
${activity.assets && activity.assets.small_image ?
|
<img src="data:image/png;base64,${await encodeBase64(`https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.small_image}.webp`)}" style="
|
||||||
`<img src="data:image/png;base64,${await encodeBase64(`https://cdn.discordapp.com/app-assets/${activity.application_id}/${activity.assets.small_image}.webp`)}" style="
|
|
||||||
width: 30px;
|
width: 30px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
margin-left: -26px;
|
margin-left: -26px;
|
||||||
margin-bottom: -8px;
|
margin-bottom: -8px;
|
||||||
"/>`
|
"/>`: ``}
|
||||||
: ``}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div style="
|
<div style="
|
||||||
color: #999;
|
color: #999;
|
||||||
@@ -235,89 +222,80 @@ const renderCard = async (body: LanyardTypes.Root, params: Parameters): Promise<
|
|||||||
height: 15px;
|
height: 15px;
|
||||||
margin: 7px 0;
|
margin: 7px 0;
|
||||||
">${activity.name}</p>
|
">${activity.name}</p>
|
||||||
${activity.details ?
|
${activity.details ? `
|
||||||
`<p style="
|
<p style="
|
||||||
color: ${theme === 'dark' ? '#ccc' : '#777'};
|
color: ${theme === 'dark' ? '#ccc' : '#777'};
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
height: 15px;
|
height: 15px;
|
||||||
margin: 7px 0;
|
margin: 7px 0;
|
||||||
">${activity.details}</p>`
|
">${activity.details}</p>` : ``}
|
||||||
: ``}
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
`
|
`: ``}
|
||||||
|
|
||||||
: ``}
|
${body.data.listening_to_spotify === true && body.data.activities[Object.keys(body.data.activities).length - 1].type === 2 ? `
|
||||||
|
<div style="
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
height: 120px;
|
||||||
|
margin-left: 15px;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
padding-top: 18px;
|
||||||
|
">
|
||||||
|
<img src="data:image/png;base64,${await encodeBase64(body.data.spotify.album_art_url)}" style="
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
border: solid 0.5px #222;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin-right: 15px;
|
||||||
|
"/>
|
||||||
|
|
||||||
${body.data.listening_to_spotify === true && body.data.activities[Object.keys(body.data.activities).length - 1].type === 2 ?
|
<div style="
|
||||||
|
color: #999;
|
||||||
`
|
margin-top: -3px;
|
||||||
<div style="
|
line-height: 1;
|
||||||
display: flex;
|
width: 279px;
|
||||||
flex-direction: row;
|
">
|
||||||
height: 120px;
|
<p style="font-size: 0.75rem; color: ${theme === 'dark' ? '#1CB853' : '#0d943d'}; margin-bottom: 15px;">LISTENING NOW...</p>
|
||||||
margin-left: 15px;
|
<p style="
|
||||||
font-size: 0.8rem;
|
height: 15px;
|
||||||
padding-top: 18px;
|
color: ${theme === 'dark' ? '#fff' : '#000'};
|
||||||
">
|
font-weight: bold;
|
||||||
<img src="data:image/png;base64,${await encodeBase64(body.data.spotify.album_art_url)}" style="
|
overflow: hidden;
|
||||||
width: 80px;
|
white-space: nowrap;
|
||||||
height: 80px;
|
text-overflow: ellipsis;
|
||||||
border: solid 0.5px #222;
|
margin: 7px 0;
|
||||||
border-radius: 10px;
|
">${body.data.spotify.song.replace(/\&/g, "and")}</p>
|
||||||
margin-right: 15px;
|
<p style="
|
||||||
"/>
|
margin: 7px 0;
|
||||||
|
height: 15px;
|
||||||
<div style="
|
overflow: hidden;
|
||||||
color: #999;
|
white-space: nowrap;
|
||||||
margin-top: -3px;
|
text-overflow: ellipsis;
|
||||||
line-height: 1;
|
color: ${theme === 'dark' ? '#ccc' : '#777'};
|
||||||
width: 279px;
|
">By ${body.data.spotify.artist.replace(/\;/g, ",").replace(/\&/g, "and")}</p>
|
||||||
">
|
</div>
|
||||||
<p style="font-size: 0.75rem; color: ${theme === 'dark' ? '#1CB853' : '#0d943d'}; margin-bottom: 15px;">LISTENING NOW...</p>
|
</div>
|
||||||
<p style="
|
` : ``}
|
||||||
height: 15px;
|
${!activity && body.data.listening_to_spotify === false ?
|
||||||
color: ${theme === 'dark' ? '#fff' : '#000'};
|
|
||||||
font-weight: bold;
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
margin: 7px 0;
|
|
||||||
">${body.data.spotify.song.replace(/\&/g, "and")}</p>
|
|
||||||
<p style="
|
|
||||||
margin: 7px 0;
|
|
||||||
height: 15px;
|
|
||||||
overflow: hidden;
|
|
||||||
white-space: nowrap;
|
|
||||||
text-overflow: ellipsis;
|
|
||||||
color: ${theme === 'dark' ? '#ccc' : '#777'};
|
|
||||||
">By ${body.data.spotify.artist.replace(/\;/g, ",").replace(/\&/g, "and")}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
|
|
||||||
: ``}
|
|
||||||
|
|
||||||
${!activity && body.data.listening_to_spotify === false ?
|
|
||||||
`<div style="
|
`<div style="
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
">
|
">
|
||||||
<p style="
|
<p style="
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
font-size: 0.8rem;
|
font-size: 0.8rem;
|
||||||
color: ${theme === 'dark' ? '#aaa' : '#444'};
|
color: ${theme === 'dark' ? '#aaa' : '#444'};
|
||||||
height: auto;
|
height: auto;
|
||||||
">
|
">
|
||||||
I'm not currently doing anything!
|
I'm not currently doing anything!
|
||||||
</p>
|
</p>
|
||||||
</div>`
|
</div>`
|
||||||
: ``}
|
: ``}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,3 +1,13 @@
|
|||||||
import imageToBase64 from "image-to-base64";
|
import imageToBase64 from "image-to-base64";
|
||||||
|
|
||||||
export const encodeBase64 = async (url: string): Promise<string> => await imageToBase64(url);
|
export const encodeBase64 = async (url: string): Promise<string> => {
|
||||||
|
let response = "";
|
||||||
|
|
||||||
|
try {
|
||||||
|
response = await imageToBase64(url);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user