-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add multi-authors support (#28)
* feat: add multi-authors support * i have dumb (forgot to remove dev things before commiting) * feat: add multi-author support to news page * fix: static video link
- Loading branch information
Showing
12 changed files
with
177 additions
and
69 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
27 changes: 27 additions & 0 deletions
27
src/components/NewsSection/NewsAuthor/NewsAuthor.module.css
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,27 @@ | ||
|
||
.author { | ||
display: flex; | ||
gap: 10px; | ||
align-items: center; | ||
} | ||
|
||
.author .avatar { | ||
height: 48px; | ||
aspect-ratio: 1; | ||
border-radius: 50%; | ||
overflow: hidden; | ||
} | ||
|
||
.author .authorInformation { | ||
color: #5A5A5A; | ||
} | ||
|
||
.author .authorInformation .authorName { | ||
font-size: 16px; | ||
font-weight: 600; | ||
} | ||
|
||
.author .authorInformation .authorRole { | ||
font-size: 12px; | ||
font-weight: 400; | ||
} |
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,27 @@ | ||
import styles from "./NewsAuthor.module.css"; | ||
import UnknownUserIcon from "@app/assets/Icons/UnknownUser.svg"; | ||
import { AuthorData } from "@app/hooks/useNewsAuthor"; | ||
import { newsBaseURL } from "@app/utils/consts"; | ||
import { Img } from "react-image"; | ||
|
||
interface Props { | ||
author: AuthorData | ||
} | ||
|
||
const NewsAuthor: React.FC<Props> = ({author}: Props) => { | ||
return <div className={styles.author}> | ||
<div className={styles.avatar}> | ||
<Img | ||
height={48} | ||
alt={`${author.displayName}'s avatar`} | ||
src={[`${newsBaseURL}/images/avatars/${author.avatar}`, UnknownUserIcon]} | ||
/> | ||
</div> | ||
<div className={styles.authorInformation}> | ||
<div className={styles.authorName}>{author.displayName}</div> | ||
<div className={styles.authorRole}>{author.role}</div> | ||
</div> | ||
</div>; | ||
}; | ||
|
||
export default NewsAuthor; |
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,11 +1,21 @@ | ||
import { newsBaseURL } from "@app/utils/consts"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
export interface Article { | ||
type: string, | ||
title: string, | ||
banner?: string, | ||
authors: string[], | ||
release?: string, | ||
video?: string | ||
} | ||
|
||
export const useNewsArticle = (md: string) => { | ||
return useQuery({ | ||
queryKey: ["NewsArticle", md], | ||
cacheTime: 60 * 60 * 1000, | ||
queryFn: async () => await fetch( | ||
`https://raw.githubusercontent.com/YARC-Official/News/master/articles/${md}.md`) | ||
`${newsBaseURL}/articles/${md}.md`) | ||
.then(res => res.text()) | ||
}); | ||
}; |
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,21 @@ | ||
import { newsBaseURL } from "@app/utils/consts"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
export interface AuthorData { | ||
displayName: string, | ||
avatar?: string, | ||
role?: string, | ||
} | ||
|
||
export const useNewsAuthorSettings = (authorId: string) => { | ||
return { | ||
queryKey: ["NewsAuthor", authorId], | ||
queryFn: async (): Promise<AuthorData> => await fetch( | ||
`${newsBaseURL}/authors/${authorId}.json`) | ||
.then(res => res.json()) | ||
}; | ||
}; | ||
|
||
export const useNewsAuthor = (authorId: string) => { | ||
return useQuery(useNewsAuthorSettings(authorId)); | ||
}; |
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.