Summer 2023: The Projects Page
During the summer of 2023, I focused on improving the functionality and aesthetics of my Projects page. The primary goal was to create an intuitive interface that showcases my GitHub repositories with an attractive layout and additional functionality.
Key Features of the Projects Page
- Dynamic Repository Fetching:
- The page fetches repositories from my GitHub account using the GitHub API.
- Each repository displays its name, an image (if available), and a brief description.
- Repository Box Layout:
- Repositories are displayed in a card-like layout.
- Each card shows an image (if available), the repository name, and additional details on hover.
- Interactive Elements:
- Clicking on a repository card opens the GitHub repository in a new tab.
- A download button is available to download the repository source code directly.
Fetching Repositories:
const fetchRepositories = async () => { try { const response = await fetch('https://api.github.com/users/Emilprivate/repos', { headers: { Authorization: `token ${process.env.NEXT_PUBLIC_GITHUB_REPOS}` }, }); const data = await response.json(); // Process repository data } catch (error) { console.error(error); } };
Rendering Repository Cards:
const renderRepository = (repo) => { return ( <div key={repo.id} className="projects-repo" onClick={() => openRepository(repo.html_url)}> <img src={repo.imageUrl || defaultImage} alt="Repository Image" className="projects-repoImage" /> <h2 className="projects-repoName">{repo.name}</h2> </div> ); };
Summer 2024: The Hobby Page
In the summer of 2024, I extended the functionality of the Hobby page. The goal was to create a dedicated section for my various hobbies, with a more dynamic and interactive interface. Currently, there is only a single repository, as I am focusing on one hobby at the moment. The following description outlines the chosen style for navigation and interaction with the initial repository. As I add more hobby projects, I will carefully consider the visualization approach for each one.
Key Features of the Hobby Page
- Repository Selection Menu:
- A menu to select different hobby repositories, initially displaying a list of repositories with their descriptions.
- Automatically fetches and displays the repository contents upon selection.
- Dynamic Content Display:
- Displays the contents of the selected repository in a menu list.
- Automatically shows
README.md
if available, when a repository or directory is selected. - Provides navigation with a back button to move up the directory structure.
- Markdown Rendering:
- Renders markdown files within the application using
ReactMarkdown
,remarkGfm
, andrehypeHighlight
.
Fetching Repository Contents:
const fetchRepoContents = async (repoName, path = '') => { const response = await fetch(`https://api.github.com/repos/Emilprivate/${repoName}/contents/${path}`, { headers: { Authorization: `token ${process.env.NEXT_PUBLIC_GITHUB_REPOS}` }, }); const data = await response.json(); if (response.ok) return data.filter(item => !item.name.startsWith('.')); throw new Error(`Error fetching repository contents: ${response.statusText}`); };
Automatically Displaying README.md:
const handleRepoSelect = (repoName) => { setSelectedRepo(repoName); fetchRepoContents(repoName).then(data => { setRepoContents(data); const readmeFile = data.find(item => item.name.toLowerCase() === 'readme.md'); if (readmeFile) handleClick(readmeFile); }).catch(console.error); };
Rendering Markdown Content:
<ReactMarkdown remarkPlugins={[remarkGfm]} rehypePlugins={[rehypeHighlight]}> {selectedContent} </ReactMarkdown>
Summary
In the summer of 2023, the Projects page was enhanced with dynamic repository fetching, interactive elements, and an improved layout. In the summer of 2024, the Hobby page was extended with a repository selection menu, dynamic content display, and markdown rendering capabilities. These enhancements provide a more interactive and user-friendly experience for showcasing my projects and hobbies.
I hope you enjoyed reading about these updates! Feel free to explore the new features on my web application.