Giter Club home page Giter Club logo

portfolio's Introduction

Portfolio

Portfolio Deploy with Vercel

Built with next.js, shadcn/ui, and magic ui, deployed on Vercel.

Features

  • Setup only takes a few minutes by editing the single config file
  • Built using Next.js 14, React, Typescript, Shadcn/UI, TailwindCSS, Framer Motion, Magic UI
  • Includes a blog
  • Responsive for different devices
  • Optimized for Next.js and Vercel

Getting Started Locally

  1. Clone this repository to your local machine:

    git clone https://github.com/dillionverma/portfolio
  2. Move to the cloned directory

    cd portfolio
  3. Install dependencies:

    pnpm install
  4. Start the local Server:

    pnpm dev
  5. Open the Config file and make changes

License

Licensed under the MIT license.

portfolio's People

Contributors

dillionverma avatar enocht14 avatar natehouk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

portfolio's Issues

Application Crash if blog doesn't exist

Hey,
While I was testing out the portfolio, I noticed something.
If you go to https://portfolio-magicui.vercel.app/blog/hello-world the app will work as expected. But if you go to https://portfolio-magicui.vercel.app/blog/hello-world1 the app will show an Application error
Screenshot 2024-08-02 022241

This happens because of this line in src/app/blog/[slug]/page.tsx:

let post = await getPost(params.slug);

if (!post) {
    notFound();
}

To be more specific. The error will appear because of the return of getPost(), which is this code:

export async function getPost(slug: string) {
  const filePath = path.join("content", `${slug}.mdx`);
  let source = fs.readFileSync(filePath, "utf-8");
  const { content: rawContent, data: metadata } = matter(source);
  const content = await markdownToHTML(rawContent);
  return {
    source: content,
    metadata,
    slug,
  };
}

If there is no hello-world1.mdx in the content folder, the function will crash and invoke the server side error.

Solution / Fix

To fix this problem, I changed the function into this:

export async function getPost(slug: string) {
  try {
    const filePath = path.join("content", `${slug}.mdx`);
    let source = fs.readFileSync(filePath, "utf-8");
    const { content: rawContent, data: metadata } = matter(source);
    const content = await markdownToHTML(rawContent);
    return {
      source: content,
      metadata,
      slug,
    };
  } catch (error) {
    return {
      source: null,
      metadata: null,
      slug: null,
    };
  }
}

Now go to src/app/blog/[slug]/page.tsx and change this line

if (!post) {
    notFound();
}

To this

if (!post.slug) {
    notFound();
}

Your src/app/blog/[slug]/page.tsx should now look like this:

let post = await getPost(params.slug);

if (!post.slug) {
  notFound();
}

The generateMetaData should look like this

export async function generateMetadata({
  params,
}: {
  params: {
    slug: string;
  };
}): Promise<Metadata | undefined> {
  let post = await getPost(params.slug);

  if(post.source) {
    let {
      title,
      publishedAt: publishedTime,
      summary: description,
      image,
    } = post.metadata;
    let ogImage = image ? `${DATA.url}${image}` : `${DATA.url}/og?title=${title}`;
  
    return {
      title,
      description,
      openGraph: {
        title,
        description,
        type: "article",
        publishedTime,
        url: `${DATA.url}/blog/${post.slug}`,
        images: [
          {
            url: ogImage,
          },
        ],
      },
      twitter: {
        card: "summary_large_image",
        title,
        description,
        images: [ogImage],
      },
    };
  }
}

If you now go to a blog that doesn't exist, you will see the Error 404 - Page not Found Page and no error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.