How to add a new post on DevTweet?

oyepriyansh

To add a post on DevTweet, follow these steps:

  1. Forking the Repository click on that fork button to fork the repository. Fork the repository

  2. Clone the repository

git clone https://github.com/<YOUR-USERNAME>/DevTweet.git
  1. Navigate to the repository folder
cd DevTweet
  1. Add a reference(remote) to the original repository.
git remote add upstream https://github.com/oyepriyansh/DevTweet.git
  1. Now go ahead and create a new branch and move to the branch
git checkout -b newpost
  1. Install dependencies and run in local
pnpm i
pnpm dev

[!NOTE] If you don’t have pnpm installed in your system then run this command npm i -g pnpm

  7. Make your changes

Creating a post

Go to src/content/posts directory.

Create a markdown file, for example hello.md.

Now copy the template code from below, and put into your markdown file and replace the placeholder with actual values.

---
layout: ../../layouts/PostLayout.astro
title: The title of the post
excerpt: A short description of the post
author: your-author-username
createdAt: Month Day, Year
---

**Post content goes here.**

Adding an Author

Go to src/util/authors.ts file. just extend the array by adding your author username. Make sure it is in lowercase.

// Before:
export const AUTHORS = ["oyepriyansh",
  "william"];

// After:
export const AUTHORS = ["oyepriyansh",
  "william",
  "your-author-username"];

Author Image

You can add an image for yourself by uploading an image to the /public/authors directory. Please make sure to rename the image exact same as your author username in the src/util/authors.ts file.

Note: Capitalization does not matter for the image file, but still make it all lowercase.

  1. After done you can now push this changes, for doing that follow the following command in order

Note: replace the <commit message> with a good commit message, for example if you are adding a new post; the commit message will be feat: new post by your-name`.

  1. After this go to your forked GitHub repository. Now you will see a popup saying Compare & pull request, click on it and create a pull request.
    Compare & pull request
    Make sure to add a good PR title, example: feat: new post by your-name.

That’s it! You have successfully contributed to DevTweet. Once the pull request is accepted and merged, your post will be live on DevTweet.

Happy coding!