From b1fb47a84f1af6e7becfa63a184da1ba8f425602 Mon Sep 17 00:00:00 2001 From: kWAY <55437151+kWAYTV@users.noreply.github.com> Date: Fri, 6 Dec 2024 13:51:16 +0100 Subject: [PATCH] refactor: centralize GitHub username and update profile URLs - Introduced a new constant for the GitHub username in metadata. - Updated GitHub profile and repository URLs to dynamically use the new username constant. - Refactored the fetchGithubRepos function to utilize the centralized username for API calls. --- src/actions/github.ts | 3 ++- src/lib/metadata.ts | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/actions/github.ts b/src/actions/github.ts index 6ea9f8c..2789e79 100644 --- a/src/actions/github.ts +++ b/src/actions/github.ts @@ -4,6 +4,7 @@ import { Octokit } from '@octokit/rest'; import { env } from '@/env'; import type { Repository } from '@/interfaces/github'; +import { githubUsername } from '@/lib/metadata'; export async function fetchGithubRepos() { try { @@ -12,7 +13,7 @@ export async function fetchGithubRepos() { }); const response = await octokit.repos.listForUser({ - username: 'kWAYTV', + username: githubUsername, sort: 'updated', per_page: 100 }); diff --git a/src/lib/metadata.ts b/src/lib/metadata.ts index 68e455a..c4eade1 100644 --- a/src/lib/metadata.ts +++ b/src/lib/metadata.ts @@ -27,5 +27,6 @@ export const baseUrl = ? new URL('http://localhost:3000') : new URL(`https://${process.env.VERCEL_URL!}`); -export const githubProfileUrl = 'https://github.com/kWAYTV'; -export const githubRepoUrl = 'https://github.com/kWAYTV/portfolio'; +export const githubUsername = 'kWAYTV'; +export const githubProfileUrl = `https://github.com/${githubUsername}`; +export const githubRepoUrl = `https://github.com/${githubUsername}/portfolio`;