Skip to content

Commit

Permalink
馃挬 Add placeholder for development
Browse files Browse the repository at this point in the history
  • Loading branch information
barbarbar338 committed Dec 15, 2023
1 parent f1bb8bb commit 7f89495
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 9 deletions.
128 changes: 120 additions & 8 deletions libs/graphql.ts
Expand Up @@ -117,7 +117,26 @@ export const getPostData = async (no: number): Promise<IPostData> => {
number: data.repository.discussion.number,
};

return post;
const postPlaceholder: IPostData = {
author: {
avatarUrl:
"https://jqetijvmergeabbsbhjm.supabase.co/storage/v1/object/public/uploads/branding/icon.png",
login: "barbarbar338",
},
bodyHTML: "<h1>Hello, world!</h1>",
createdAt: new Date().toLocaleDateString(),
labels: [
{
color: "black",
id: "123",
name: "Example",
},
],
number: 1,
title: "Example",
};

return CONFIG.DEV ? postPlaceholder : post;
};

export interface ISponsor {
Expand Down Expand Up @@ -164,7 +183,16 @@ export const getSponsors = async (): Promise<ISponsor[]> => {
isOneTime: node.isOneTimePayment,
}));

return sponsors;
const sponsorPlaceholder: ISponsor = {
avatarUrl:
"https://jqetijvmergeabbsbhjm.supabase.co/storage/v1/object/public/uploads/branding/icon.png",
isOneTime: false,
login: "barbarbar338",
tier: "$10",
name: "Bar谋艧 DEM陌RC陌",
};

return CONFIG.DEV ? [sponsorPlaceholder] : sponsors;
};

export const getPinnedRepos = async (): Promise<IStarredRepo[]> => {
Expand Down Expand Up @@ -201,7 +229,18 @@ export const getPinnedRepos = async (): Promise<IStarredRepo[]> => {
} as IStarredRepo;
});

return repos;
const repoPlaceholder: IStarredRepo = {
description: "Example",
name: "Example",
primaryLanguage: {
color: "black",
name: "Example",
},
stargazerCount: 999,
url: "https://338.rocks",
};

return CONFIG.DEV ? [repoPlaceholder] : repos;
};

export const getMostStarredRepos = async (): Promise<IStarredRepo[]> => {
Expand Down Expand Up @@ -241,7 +280,18 @@ export const getMostStarredRepos = async (): Promise<IStarredRepo[]> => {
} as IStarredRepo;
});

return repos;
const repoPlaceholder: IStarredRepo = {
description: "Example",
name: "Example",
primaryLanguage: {
color: "black",
name: "Example",
},
stargazerCount: 999,
url: "https://338.rocks",
};

return CONFIG.DEV ? [repoPlaceholder] : repos;
};

export const getCategories = async (): Promise<ILabel[]> => {
Expand Down Expand Up @@ -271,7 +321,13 @@ export const getCategories = async (): Promise<ILabel[]> => {
} as ILabel;
});

return labels;
const labelPlaceholder: ILabel = {
color: "black",
id: "123",
name: "Example",
};

return CONFIG.DEV ? [labelPlaceholder] : labels;
};

export const getPosts = async (): Promise<IPost[]> => {
Expand Down Expand Up @@ -328,7 +384,27 @@ export const getPosts = async (): Promise<IPost[]> => {
} as IPost;
});

return posts;
const postPlaceholder: IPost = {
author: {
avatarUrl:
"https://jqetijvmergeabbsbhjm.supabase.co/storage/v1/object/public/uploads/branding/icon.png",
login: "barbarbar338",
},
body: "<h1>Hello, world!</h1>",
createdAt: new Date().toLocaleDateString(),
id: "123",
labels: [
{
color: "black",
id: "123",
name: "Example",
},
],
number: 1,
title: "Example",
};

return CONFIG.DEV ? [postPlaceholder] : posts;
};

export const getPinnedPosts = async (): Promise<IPost[]> => {
Expand Down Expand Up @@ -391,7 +467,27 @@ export const getPinnedPosts = async (): Promise<IPost[]> => {
},
);

return posts;
const postPlaceholder: IPost = {
author: {
avatarUrl:
"https://jqetijvmergeabbsbhjm.supabase.co/storage/v1/object/public/uploads/branding/icon.png",
login: "barbarbar338",
},
body: "<h1>Hello, world!</h1>",
createdAt: new Date().toLocaleDateString(),
id: "123",
labels: [
{
color: "black",
id: "123",
name: "Example",
},
],
number: 1,
title: "Example",
};

return CONFIG.DEV ? [postPlaceholder] : posts;
};

export const getCommits = async (): Promise<ICommitsData> => {
Expand Down Expand Up @@ -450,5 +546,21 @@ export const getCommits = async (): Promise<ICommitsData> => {
Object.keys(commitsData.commits)[0]
][0].committedDate;

return commitsData;
const commitsDataPlaceholder: ICommitsData = {
latest: new Date().toLocaleDateString(),
commits: {
[new Date().toLocaleDateString()]: [
{
author: {
name: "barbarbar338",
},
committedDate: new Date().toLocaleDateString(),
commitUrl: "https://338.rocks",
message: "Example"
},
],
},
};

return CONFIG.DEV ? commitsDataPlaceholder : commitsData;
};
2 changes: 1 addition & 1 deletion next.config.js
Expand Up @@ -11,7 +11,7 @@ const nextConfig = {
defaultLocale: "en",
},
images: {
domains: ["avatars.githubusercontent.com", "api.338.rocks"],
domains: ["avatars.githubusercontent.com", "api.338.rocks", "jqetijvmergeabbsbhjm.supabase.co"],
},
async redirects() {
return [
Expand Down

0 comments on commit 7f89495

Please sign in to comment.