"Writing the code, shaping the blog - because I'm not just a coder, I'm a storyteller in the digital realm. Ready to embark on your coding journey?"
I am excited to introduce you to Dev Diary, a dynamic platform that showcases my skills and provides a space for other enthusiasts to share, learn, and connect.
Hello, fellow tech enthusiasts!
What Makes Dev Diary Stand Out?
Cutting-Edge Technology:
Dev Diary leverages the latest technologies, including ASP.NET, MVC, C#, and SQL, to provide a seamless and secure experience for creators and readers alike. Whether you are a seasoned developer or a beginner, our platform offers a range of content, from coding tutorials to industry news.
Interactive Community:
Immerse yourself in a community where interaction is the key. Explore various tech-related topics, engage with other users through comments, and show appreciation by liking your favorite blogs. Dev Diary is more than just a blogging site; it's a thriving community.
Constant Evolution:
In the ever-changing tech world, we understand the importance of staying ahead. Dev Diary continually evolves to bring you the latest trends, insights, and discussions. Expect regular updates as we keep pace with the dynamic tech landscape.
API Integration:
In Dev Diary, I've implemented an API controller that provides public access to the latest blog information. To configure this functionality, I utilized the ASP.NET API controller and set up documentation with Swagger to enhance the understanding and consumption of the API.
Firstly, I added the API configuration in the application's startup file:
// Add API configs
builder.Services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo
{
Title = "Dev Diary",
Version = "v1",
Description = "An API accessible to the public that retrieves the most recent blog posts",
Contact = new Microsoft.OpenApi.Models.OpenApiContact
{
Name = "Gelson Hernandez",
Email = "gelsonhz@outlook.com",
Url = new Uri("https://gelsonportfolio.netlify.app/")
}
});
string xmlFileName = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFileName));
});
This configuration allows clear and detailed documentation of our API, including developer information, versions, and descriptions.
Now, to consume this API in your portfolio, we've written a JavaScript code. This code utilizes the fetch function to retrieve the latest blog data:
function fetchBlogData() {
const baseUrl = "https://devdiary-production.up.railway.app";
fetch(`${baseUrl}/api/BlogPosts/3`)
.then((response) => response.json())
.then(function (data) {
// Sort blog posts by creation date in descending order
const sortedBlogPosts = data.sort(
(a, b) => new Date(b.created) - new Date(a.created)
);
// Get the first three blog posts
const latestBlogPosts = sortedBlogPosts.slice(0, 3);
// Call the function to display blog data in your portfolio
displayBlogData(latestBlogPosts, baseUrl);
});
}
This code initiates an API request to retrieve the three most recent blogs, sorts them by creation date, and then utilizes the displayBlogData function to showcase the information on your portfolio.
With this implementation, my portfolio will consistently display the latest updates from Dev Diary, keeping my visitors informed about my most recent contributions
Behind the Scenes:
Dev Diary was brought to life in just two weeks, a testament to our team's efficiency and passion. The user-friendly front-end design is built using HTML, JavaScript, and Bootstrap, complemented by a robust back-end powered by MVC and C#. Our database, hosted on PostgreSQL Server, ensures reliability and performance with seamless deployment on Railway.
I invite you to explore Dev Diary, discover its features, and become part of our growing community. As a developer, I take pride in sharing my expertise and providing a platform for tech enthusiasts like you.
Visit us at Dev Diary and embark on a journey of exploration, learning, and collaboration. I hope you find Dev Diary as exciting and inspiring as I do.
Happy coding! 🎉
0 Comments