-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from metrue/domain-binding
Read the github username from environment variable when deployment to own domain
- Loading branch information
Showing
5 changed files
with
72 additions
and
20 deletions.
There are no files selected for viewing
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,14 +1,36 @@ | ||
import { getServerSession } from "next-auth/next"; | ||
import { authOptions } from "@/lib/auth"; | ||
import ThoughtsList from "@/components/ThoughtsList"; | ||
import GitHubSignInButton from "@/components/GitHubSignInButton"; | ||
import ThoughtsList from "@/components/ThoughtsList"; | ||
import { getThoughtsPublic } from "@/lib/githubApi"; | ||
import { Octokit } from "@octokit/rest"; | ||
import PublicThoughtsList from "@/components/PublicThoughtsList"; | ||
|
||
export default async function ThoughtsPage() { | ||
const session = await getServerSession(authOptions); | ||
const username = process.env.GITHUB_USERNAME ?? ''; | ||
|
||
if (!session || !session.accessToken) { | ||
return <GitHubSignInButton />; | ||
if (username) { | ||
const octokit = new Octokit(); | ||
const blogPosts = await getThoughtsPublic( | ||
octokit, | ||
process.env.GITHUB_USERNAME ?? '', | ||
"tinymind-blog" | ||
); | ||
return ( | ||
<div className="max-w-4xl mx-auto px-4 py-8"> | ||
<div className="max-w-2xl mx-auto"> | ||
<PublicThoughtsList thoughts={blogPosts} /> | ||
</div> | ||
</div> | ||
); | ||
} else { | ||
return ( | ||
<GitHubSignInButton /> | ||
); | ||
} | ||
} | ||
|
||
return <ThoughtsList />; | ||
return <ThoughtsList username={username} />; | ||
} |
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