Skip to content

Commit

Permalink
refactor: modularize code
Browse files Browse the repository at this point in the history
  • Loading branch information
suvnshr committed Dec 21, 2024
1 parent 824bf45 commit 9ff7f73
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
8 changes: 3 additions & 5 deletions data/profileData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FaGithub, FaLinkedin, FaMedium, FaTwitter } from "react-icons/fa";
import { FaGithub, FaLinkedin, FaMedium } from "react-icons/fa";

const profileData = {
name: "Suvansh Rana",
Expand Down Expand Up @@ -38,11 +38,9 @@ const profileData = {
icon: <FaMedium size="28px" />,
link: "https://medium.com/@suvnshr",
},
// {
// icon: <FaTwitter size="28px" />,
// link: "https://twitter.com/@suvnshr",
// },
],
mediumFeedURL:
"https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@suvnshr",
};

export default profileData;
6 changes: 3 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const debug = process.env.NODE_ENV !== "production";

const githubUsername = "suvnshr";
const githubUsername = "suvnshr";

module.exports = {
assetPrefix: !debug ? `https://${githubUsername}.github.io/` : '',
}
assetPrefix: !debug ? `https://${githubUsername}.github.io/` : "",
};
11 changes: 3 additions & 8 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import ProfileSection from "../sections/ProfileSection";
import ProjectSection from "../sections/ProjectSection";

import Head from "next/head";
import { fetchMediumFeed } from "../utils/fetchMediumFeed";

export async function getStaticProps() {
const res = await fetch(
"https://api.rss2json.com/v1/api.json?rss_url=https://medium.com/feed/@suvnshr"
);

const blogsData = await res.json();
const blogsData = await fetchMediumFeed();

return {
props: {
Expand All @@ -27,9 +24,7 @@ export async function getStaticProps() {
function App({ blogsData }) {
return (
<>
<Head>

</Head>
<Head />

<div className="App">
<div id="about">
Expand Down
1 change: 1 addition & 0 deletions utils/extractImagePaths.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Extracts image paths from a string
export function extractImagePaths(inputString) {
const regex =
/(?:https?:\/\/.*\.(?:jpg|jpeg|png|gif|bmp|svg))|(?:\/[^\s]*\.(?:jpg|jpeg|png|gif|bmp|svg))/gi;
Expand Down
8 changes: 8 additions & 0 deletions utils/fetchMediumFeed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import profileData from "../data/profileData";

// Fetch Medium feed
export async function fetchMediumFeed() {
const res = await fetch(profileData.mediumFeedURL);

return await res.json();
}

0 comments on commit 9ff7f73

Please sign in to comment.