add projects
This commit is contained in:
parent
473f6c2d8d
commit
f0860e4223
6 changed files with 3556 additions and 14 deletions
|
@ -1,15 +1,35 @@
|
||||||
import Button from "./Button";
|
import Button from "./Button";
|
||||||
import styles from "styles/Button.module.sass";
|
import styles from "styles/Button.module.sass";
|
||||||
import { SocialButton } from "utils/types";
|
import { ProjectButton, SocialButton } from "utils/types";
|
||||||
import { CSSProperties } from "react";
|
import { CSSProperties } from "react";
|
||||||
|
|
||||||
const ButtonGrid = ({
|
const ButtonGrid = ({
|
||||||
Buttons,
|
Buttons,
|
||||||
style,
|
style,
|
||||||
}: {
|
}: {
|
||||||
Buttons: SocialButton[];
|
Buttons: SocialButton[] | ProjectButton[];
|
||||||
style?: CSSProperties;
|
style?: CSSProperties;
|
||||||
}) => {
|
}) => {
|
||||||
|
|
||||||
|
if (Buttons[0].project) {
|
||||||
|
return (
|
||||||
|
<div className={styles.grid} style={style}>
|
||||||
|
{Buttons.map((button, index) => {
|
||||||
|
return (
|
||||||
|
<Button
|
||||||
|
id={button.id}
|
||||||
|
key={`${button.platform}-${index}`}
|
||||||
|
icon={button.icon}
|
||||||
|
platform={button.project}
|
||||||
|
username={button.platform}
|
||||||
|
url={button.url}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.grid} style={style}>
|
<div className={styles.grid} style={style}>
|
||||||
{Buttons.map((button, index) => {
|
{Buttons.map((button, index) => {
|
||||||
|
|
3491
package-lock.json
generated
Normal file
3491
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -20,6 +20,7 @@
|
||||||
"remark": "^14.0.2",
|
"remark": "^14.0.2",
|
||||||
"remark-html": "^15.0.1",
|
"remark-html": "^15.0.1",
|
||||||
"sass": "^1.53.0",
|
"sass": "^1.53.0",
|
||||||
|
"swr": "^1.3.0",
|
||||||
"use-lanyard": "^1.1.0"
|
"use-lanyard": "^1.1.0"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
|
|
@ -2,27 +2,30 @@ import ButtonGrid from "components/ButtonGrid";
|
||||||
import Lanyard from "components/Lanyard";
|
import Lanyard from "components/Lanyard";
|
||||||
import Navbar from "components/Navbar";
|
import Navbar from "components/Navbar";
|
||||||
import getProfiles from "utils/shared/profiles";
|
import getProfiles from "utils/shared/profiles";
|
||||||
import { getAllPostIDs, getPostData,getSortedPosts } from "utils/shared/posts";
|
import getProjects from "utils/shared/projects";
|
||||||
|
import { getAllPostIDs, getPostData, getSortedPosts } from "utils/shared/posts";
|
||||||
import { SocialButton } from "utils/types";
|
import { SocialButton } from "utils/types";
|
||||||
import styles from "styles/Index.module.sass";
|
import styles from "styles/Index.module.sass";
|
||||||
import Link from "components/Link";
|
// import Link from "components/Link";
|
||||||
import Post from "components/Post";
|
// import Post from "components/Post";
|
||||||
import PostGrid from "components/PostGrid";
|
// import PostGrid from "components/PostGrid";
|
||||||
|
import useSwr from 'swr';
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
const profiles = await getProfiles();
|
const profiles = await getProfiles();
|
||||||
const posts = await getSortedPosts();
|
const posts = await getSortedPosts();
|
||||||
|
const projects = await getProjects("showcase-lio")
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
profiles,
|
profiles,
|
||||||
posts
|
posts,
|
||||||
|
projects
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const IndexPage = (props: { profiles: SocialButton[]; posts: Array<any> }) => {
|
const IndexPage = (props: { profiles: SocialButton[]; posts: Array<any>; projects: SocialButton[] }) => {
|
||||||
// console.log(props.posts);
|
const showposts = false
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={styles.center}>
|
<div className={styles.center}>
|
||||||
|
@ -32,13 +35,14 @@ const IndexPage = (props: { profiles: SocialButton[]; posts: Array<any> }) => {
|
||||||
<ButtonGrid Buttons={props.profiles} />
|
<ButtonGrid Buttons={props.profiles} />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<p>Posts</p>
|
<p>Projects</p>
|
||||||
<PostGrid posts={props.posts}/>
|
<ButtonGrid Buttons={props.projects} />
|
||||||
</div>
|
</div>
|
||||||
|
{/* {showposts && (<div><p>Posts</p><PostGrid posts={props.posts} /></div>)} */}
|
||||||
</div>
|
</div>
|
||||||
<Lanyard />
|
<Lanyard />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default IndexPage;
|
export default IndexPage
|
16
utils/shared/projects.ts
Normal file
16
utils/shared/projects.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { ProjectButton } from "utils/types";
|
||||||
|
|
||||||
|
export default async function getProjects(k): Promise<ProjectButton[]> {
|
||||||
|
const res = await fetch(`https://git.lio.cat/api/v1/repos/search?q=${k}&topic=true`)
|
||||||
|
const data = await res.json()
|
||||||
|
|
||||||
|
return data.data.map(data => {
|
||||||
|
return {
|
||||||
|
icon: "git-branch",
|
||||||
|
platform: (data.description === "" || data.description.length > 30) ? "git.lio.cat" : data.description,
|
||||||
|
project: data.full_name,
|
||||||
|
url: `https://git.lio.cat/${data.full_name}`,
|
||||||
|
updated: data.updated_at
|
||||||
|
}
|
||||||
|
}).sort((lhs, rhs) => { return lhs.updated < rhs.updated ? 1 : lhs.updated > rhs.updated ? -1 : 0; })
|
||||||
|
}
|
|
@ -1,11 +1,21 @@
|
||||||
export type SocialButton = {
|
export type SocialButton = {
|
||||||
id: number;
|
id?: number;
|
||||||
icon: Icon;
|
icon: Icon;
|
||||||
platform: string;
|
platform: string;
|
||||||
username: string;
|
username: string;
|
||||||
|
project?: null;
|
||||||
url?: string;
|
url?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type ProjectButton = {
|
||||||
|
id?: number;
|
||||||
|
icon: Icon;
|
||||||
|
project: string;
|
||||||
|
platform: string;
|
||||||
|
url?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
export type Icon =
|
export type Icon =
|
||||||
| "x"
|
| "x"
|
||||||
| "smile"
|
| "smile"
|
||||||
|
|
Loading…
Add table
Reference in a new issue