1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-02 13:52:46 +02:00

Pull changelog from backoffice

This commit is contained in:
Kamran Ahmed
2025-08-20 23:20:37 +01:00
parent 7933e222ee
commit 487a6a222b
20 changed files with 84 additions and 374 deletions

View File

@@ -1,45 +1,46 @@
---
import { DateTime } from 'luxon';
import type { ChangelogFileType } from '../../lib/changelog';
import ChangelogImages from '../ChangelogImages';
import type { ChangelogDocument } from '../../queries/changelog';
interface Props {
changelog: ChangelogFileType;
changelog: ChangelogDocument;
}
const { changelog } = Astro.props;
const { frontmatter } = changelog;
const formattedDate = DateTime.fromISO(frontmatter.date).toFormat(
const formattedDate = DateTime.fromISO(changelog.createdAt).toFormat(
'dd LLL, yyyy',
);
---
<div class='relative mb-6' id={changelog.id}>
<span
class='absolute -left-6 top-2 h-2 w-2 shrink-0 rounded-full bg-gray-300'
<div class='relative mb-6' id={changelog._id}>
<span class='absolute top-2 -left-6 h-2 w-2 shrink-0 rounded-full bg-gray-300'
></span>
<div class='mb-3 flex flex-col sm:flex-row items-start sm:items-center gap-0.5 sm:gap-2'>
<div
class='mb-3 flex flex-col items-start gap-0.5 sm:flex-row sm:items-center sm:gap-2'
>
<span class='shrink-0 text-xs tracking-wide text-gray-400'>
{formattedDate}
</span>
<span class='truncate text-base font-medium text-balance'>
{changelog.frontmatter.title}
{changelog.title}
</span>
</div>
<div class='rounded-xl border bg-white p-6'>
{frontmatter.images && (
<div class='mb-5 hidden sm:block -mx-6'>
<ChangelogImages images={frontmatter.images} client:load />
</div>
)}
{
changelog.images && (
<div class='-mx-6 mb-5 hidden sm:block'>
<ChangelogImages images={changelog.images} client:load />
</div>
)
}
<div
class='prose prose-sm prose-h2:mt-3 prose-h2:text-lg prose-h2:font-medium prose-p:mb-0 prose-blockquote:font-normal prose-blockquote:text-gray-500 prose-ul:my-0 prose-ul:rounded-lg prose-ul:bg-gray-100 prose-ul:px-4 prose-ul:py-4 prose-ul:pl-7 prose-img:mt-0 prose-img:rounded-lg [&>blockquote>p]:mt-0 [&>ul>li]:my-0 [&>ul>li]:mb-1 [&>ul]:mt-3'
>
<changelog.Content />
</div>
class='prose prose-sm prose-h2:mt-3 prose-h2:text-lg prose-h2:font-medium prose-p:mb-0 prose-blockquote:font-normal prose-blockquote:text-gray-500 prose-ul:my-0 prose-ul:rounded-lg prose-ul:bg-gray-100 prose-ul:px-4 prose-ul:py-4 prose-ul:pl-7 prose-img:mt-0 prose-img:rounded-lg [&>blockquote>p]:mt-0 [&>ul]:mt-3 [&>ul>li]:my-0 [&>ul>li]:mb-1'
set:html={changelog.description}
/>
</div>
</div>

View File

@@ -1,9 +1,9 @@
---
import { getAllChangelogs } from '../lib/changelog';
import { listChangelog } from '../queries/changelog';
import { DateTime } from 'luxon';
import AstroIcon from './AstroIcon.astro';
const allChangelogs = await getAllChangelogs();
const top10Changelogs = allChangelogs.slice(0, 10);
const changelogs = await listChangelog({ limit: 10 });
---
<div class='border-t bg-white py-6 text-left sm:py-16 sm:text-center'>
@@ -17,7 +17,7 @@ const top10Changelogs = allChangelogs.slice(0, 10);
Actively Maintained
</p>
<p
class='mb-2 mt-1 text-sm leading-relaxed text-gray-600 sm:my-2 sm:my-5 sm:text-lg'
class='mt-1 mb-2 text-sm leading-relaxed text-gray-600 sm:my-5 sm:text-lg'
>
We are always improving our content, adding new resources and adding
features to enhance your learning experience.
@@ -25,27 +25,27 @@ const top10Changelogs = allChangelogs.slice(0, 10);
<div class='relative mt-2 text-left sm:mt-8'>
<div
class='absolute inset-y-0 left-[120px] hidden w-px -translate-x-[0.5px] translate-x-[5.75px] bg-gray-300 sm:block'
class='absolute inset-y-0 left-[120px] hidden w-px translate-x-[5.75px] bg-gray-300 sm:block'
>
</div>
<ul class='relative flex flex-col gap-4 py-4'>
{
top10Changelogs.map((changelog) => {
changelogs.map((changelog) => {
const formattedDate = DateTime.fromISO(
changelog.frontmatter.date,
changelog.createdAt,
).toFormat('dd LLL, yyyy');
return (
<li class='relative'>
<a
href={`/changelog#${changelog.id}`}
href={`/changelog#${changelog._id}`}
class='flex flex-col items-start sm:flex-row sm:items-center'
>
<span class='shrink-0 pr-0 text-right text-sm tracking-wide text-gray-400 sm:w-[120px] sm:pr-4'>
{formattedDate}
</span>
<span class='hidden h-3 w-3 shrink-0 rounded-full bg-gray-300 sm:block' />
<span class='text-balance text-base font-medium text-gray-900 sm:pl-8'>
{changelog.frontmatter.title}
<span class='text-base font-medium text-balance text-gray-900 sm:pl-8'>
{changelog.title}
</span>
</a>
</li>
@@ -55,7 +55,7 @@ const top10Changelogs = allChangelogs.slice(0, 10);
</ul>
</div>
<div
class='mt-2 flex flex-col gap-2 sm:flex-row sm:mt-8 sm:items-center sm:justify-center'
class='mt-2 flex flex-col gap-2 sm:mt-8 sm:flex-row sm:items-center sm:justify-center'
>
<a
href='/changelog'
@@ -66,7 +66,7 @@ const top10Changelogs = allChangelogs.slice(0, 10);
<button
data-guest-required
data-popup='login-popup'
class='flex flex-row items-center gap-2 rounded-lg border border-black bg-white px-4 py-2 text-sm text-black transition-all hover:bg-black hover:text-white sm:rounded-full sm:pl-4 sm:pr-5 sm:text-base'
class='flex flex-row items-center gap-2 rounded-lg border border-black bg-white px-4 py-2 text-sm text-black transition-all hover:bg-black hover:text-white sm:rounded-full sm:pr-5 sm:pl-4 sm:text-base'
>
<AstroIcon icon='bell' class='h-5 w-5' />
Subscribe for Notifications

View File

@@ -1,13 +1,14 @@
import { ChevronLeft, ChevronRight } from 'lucide-react';
import React, { useState, useEffect, useCallback } from 'react';
import type { ChangelogImage } from '../queries/changelog';
interface ChangelogImagesProps {
images: { [key: string]: string };
images: ChangelogImage[];
}
const ChangelogImages: React.FC<ChangelogImagesProps> = ({ images }) => {
const [enlargedImage, setEnlargedImage] = useState<string | null>(null);
const imageArray = Object.entries(images);
const imageArray = images.map((image) => [image.title, image.url]);
const handleImageClick = (src: string) => {
setEnlargedImage(src);
@@ -63,10 +64,10 @@ const ChangelogImages: React.FC<ChangelogImagesProps> = ({ images }) => {
alt={title}
className="h-[120px] w-full object-cover object-left-top"
/>
<span className="absolute group-hover:opacity-0 inset-0 bg-linear-to-b from-transparent to-black/40" />
<span className="absolute inset-0 bg-linear-to-b from-transparent to-black/40 group-hover:opacity-0" />
<div className="absolute font-medium inset-x-0 top-full group-hover:inset-y-0 flex items-center justify-center px-2 text-center text-xs bg-black/50 text-white py-0.5 opacity-0 group-hover:opacity-100 cursor-pointer">
<span className='bg-black py-0.5 rounded-sm px-1'>{title}</span>
<div className="absolute inset-x-0 top-full flex cursor-pointer items-center justify-center bg-black/50 px-2 py-0.5 text-center text-xs font-medium text-white opacity-0 group-hover:inset-y-0 group-hover:opacity-100">
<span className="rounded-sm bg-black px-1 py-0.5">{title}</span>
</div>
</div>
))}
@@ -82,7 +83,7 @@ const ChangelogImages: React.FC<ChangelogImagesProps> = ({ images }) => {
className="max-h-[90%] max-w-[90%] rounded-xl object-contain"
/>
<button
className="absolute left-4 top-1/2 -translate-y-1/2 transform rounded-full bg-white/50 hover:bg-white/100 p-2"
className="absolute top-1/2 left-4 -translate-y-1/2 transform rounded-full bg-white/50 p-2 hover:bg-white/100"
onClick={(e) => {
e.stopPropagation();
handleNavigation('prev');
@@ -91,7 +92,7 @@ const ChangelogImages: React.FC<ChangelogImagesProps> = ({ images }) => {
<ChevronLeft size={24} />
</button>
<button
className="absolute right-4 top-1/2 -translate-y-1/2 transform rounded-full bg-white/50 hover:bg-white/100 p-2"
className="absolute top-1/2 right-4 -translate-y-1/2 transform rounded-full bg-white/50 p-2 hover:bg-white/100"
onClick={(e) => {
e.stopPropagation();
handleNavigation('next');

View File

@@ -1,18 +0,0 @@
---
title: 'AI Agents, Red Teaming Roadmaps and Community Courses'
description: 'New roadmaps for AI Agents and Red Teaming plus access to community-generated AI courses'
images:
'AI Agents': 'https://assets.roadmap.sh/guest/ai-agents-roadmap-min-poii3.png'
'Red Teaming': 'https://assets.roadmap.sh/guest/ai-red-teaming-omyvx.png'
'AI Community Courses': 'https://assets.roadmap.sh/guest/ai-community-courses.png'
seo:
title: 'AI Agents, Red Teaming Roadmaps and Community Courses'
description: ''
date: 2025-05-12
---
We added new AI roadmaps for AI Agents and Red Teaming and made our AI Tutor better with courses created by the community.
- We just released a new [AI Agents Roadmap](https://roadmap.sh/ai-agents) that covers how to build, design, and run smart autonomous systems.
- There's also a new [Red Teaming Roadmap](https://roadmap.sh/ai-red-teaming) for people who want to learn about testing AI systems for weaknesses and security flaws.
- Our [AI Tutor](https://roadmap.sh/ai) now lets you use courses made by other users. You can learn from their content or share your own learning plans.

View File

@@ -1,25 +0,0 @@
---
title: 'AI Engineer Roadmap, Leaderboards, Editor AI, and more'
description: 'New AI Engineer Roadmap, New Leaderboards, AI Integration in Editor, and more'
images:
"AI Engineer Roadmap": "https://assets.roadmap.sh/guest/ai-engineer-roadmap.png"
"Refer Others": "https://assets.roadmap.sh/guest/invite-users.png"
"Editor AI Integration": "https://assets.roadmap.sh/guest/editor-ai-integration.png"
"Project Status": "https://assets.roadmap.sh/guest/project-status.png"
"Leaderboards": "https://assets.roadmap.sh/guest/new-leaderboards.png"
seo:
title: 'AI Engineer Roadmap, Leaderboards, Editor AI, and more'
description: ''
date: 2024-10-04
---
We have a new AI Engineer roadmap, Contributor leaderboards, AI integration in the editor, and more.
- [AI Engineer Roadmap](https://roadmap.sh/ai-engineer) is now live
- You can now refer others to join roadmap.sh
- AI integration [in the editor](https://draw.roadmap.sh) to help you create and edit roadmaps faster
- New [Leaderboards](/leaderboard) for contributors and people who refer others
- [Projects pages](/frontend/projects) now show the status of each project
- Bug fixes and performance improvements
ML Engineer roadmap and team dashboards are coming up next. Stay tuned!

View File

@@ -1,20 +0,0 @@
---
title: 'AI Quiz Summaries, New Go Roadmap, and YouTube Videos'
description: 'Personalized AI summaries for quizzes, completely redrawn Go roadmap, and new YouTube videos for AI features'
images:
'AI Quiz Summary': 'https://assets.roadmap.sh/guest/quiz-summary-gnwel.png'
'New Go Roadmap': 'https://assets.roadmap.sh/guest/roadmapsh_golang-rqzoc.png'
'YouTube Videos': 'https://assets.roadmap.sh/guest/youtube-videos-4kygb.jpeg'
'Roadmap Editor': 'https://assets.roadmap.sh/guest/ai-inside-editor.png'
seo:
title: 'AI Quiz Summaries, New Go Roadmap, and YouTube Videos'
description: ''
date: 2025-07-23
---
We've added new AI-powered features and improved our content to help you learn more effectively.
- [AI quizzes](/ai/quiz) now provide personalized AI-generated summaries at the end, along with tailored course and guide suggestions to help you continue learning.
- The [Go roadmap](/golang) has been completely redrawn with better quality and a more language-focused approach, replacing the previous version that was too web development oriented.
- We now have [8 new YouTube videos](https://www.youtube.com/playlist?list=PLkZYeFmDuaN38LRfCSdAkzWVtTXMJt11A) covering all our AI features to help you make the most of them.
- [Roadmap editor](/account/roadmaps) now allows you to generate a base roadmap from a prompt.

View File

@@ -1,22 +0,0 @@
---
title: 'AI Roadmaps Improved, Schedule Learning Time'
description: 'AI Roadmaps are now deeper and we have added a new feature to schedule learning time'
images:
"AI Roadmaps Depth": "https://assets.roadmap.sh/guest/3-level-roadmaps-lotx1.png"
"Schedule Learning Time": "https://assets.roadmap.sh/guest/schedule-learning-time.png"
"Schedule Learning Time Modal": "https://assets.roadmap.sh/guest/schedule-learning-time-2.png"
seo:
title: 'AI Roadmaps Improved, Schedule Learning Time'
description: ''
date: 2024-11-18
---
We have improved our AI roadmaps, added a way to schedule learning time, and made some site wide bug fixes and improvements. Here are the details:
- [AI generated roadmaps](https://roadmap.sh/ai) are now 3 levels deep giving you more detailed information. We have also improved the quality of the generated roadmaps.
- Schedule learning time on your calendar for any roadmap. Just click on the "Schedule Learning Time" button and select the time slot you want to block.
- You can now dismiss the sticky roadmap progress indicator at the bottom of any roadmap.
- We have added some new Project Ideas to our [Frontend Roadmap](/frontend/projects).
- Bug fixes and performance improvements
We have a new Engineering Manager Roadmap coming this week. Stay tuned!

View File

@@ -1,18 +0,0 @@
---
title: 'AI Tutor, C++ and Java Roadmaps'
description: 'We just launched our first paid SQL course'
images:
'AI Tutor': 'https://assets.roadmap.sh/guest/ai-tutor-xwth3.png'
'Java Roadmap': 'https://assets.roadmap.sh/guest/new-java-roadmap-t7pkk.png'
'C++ Roadmap': 'https://assets.roadmap.sh/guest/new-cpp-roadmap.png'
seo:
title: 'AI Tutor, C++ and Java Roadmaps'
description: ''
date: 2025-04-03
---
We have revised the C++ and Java roadmaps and introduced an AI tutor to help you learn anything.
- We just launched an [AI Tutor](https://roadmap.sh/ai), just give it a topic, pick a difficulty level and it will generate a personalized study plan for you. There is a map view, quizzes an embedded chat to help you along the way.
- [C++ roadmap](https://roadmap.sh/cpp) has been revised with improved content
- We have also redrawn the [Java roadmap](https://roadmap.sh/java) from scratch, replacing the deprecated items, adding new content and improving the overall structure.

View File

@@ -1,23 +0,0 @@
---
title: 'Revamped roadmaps, AI Tutor, Guides, Roadmaps and more'
description: 'Revamped roadmaps, AI Tutor, AI Guides and AI Roadmaps'
images:
'Roadmap AI Tutor': 'https://assets.roadmap.sh/guest/floating-ai-tutor-n1o4n.png'
'AI Tutor on Roadmap': 'https://assets.roadmap.sh/guest/dedicated-roadmap-chat-page-qlbfw.png'
'AI Tutor': 'https://assets.roadmap.sh/guest/global-chat-evm4v.png'
'Topics AI Tutor': 'https://assets.roadmap.sh/guest/roadmap-ai-tutor-89if2.png'
'AI Guides and Roadmaps': 'https://assets.roadmap.sh/guest/ai-guides-roadmaps-lxmm3.jpeg'
seo:
title: 'Revamped roadmaps, AI Tutor, AI Guides and AI Roadmaps'
description: ''
date: 2025-06-27
---
We've revamped some of our older roadmaps and added new AI features to help you learn better.
- Roadmap pages now have a [floating AI Tutor](/frontend) that can help you learn anything while following the roadmap.
- There is a new [dedicated AI Tutor page](/frontend/ai) for each roadmap, where you can learn any topic of the roadmap, save history and more.
- With [global chat](/ai/chat), you can ask any question about your career, upload your resume, get guidance, tips, roadmap suggestions and more.
- Topic pages of roadmaps now have a new [AI Tutor](/frontend) that can help you learn the topic, get quizzed on the topic and more.
- Apart from courses, you can now [generate AI Guides and AI Roadmaps](/ai) for any topic.
- [MongoDB](/mongodb), [Kubernetes](/kubernetes), [Spring Boot](/spring-boot), [Linux](/linux), [React Native](/react-native) and [GraphQL](/graphql) roadmaps have been updated.

View File

@@ -1,21 +0,0 @@
---
title: 'Cloudflare and ASP.NET Roadmaps, New Dashboard'
description: 'We just launched our first paid SQL course'
images:
'New Dashboard': 'https://assets.roadmap.sh/guest/new-dashboard.png'
'Cloudflare Roadmap': 'https://assets.roadmap.sh/guest/cloudflare-roadmap.png'
'ASP.NET Roadmap Revised': 'https://assets.roadmap.sh/guest/aspnet-core-revision.png'
seo:
title: 'Cloudflare and ASP.NET Roadmaps, New Dashboard'
description: ''
date: 2025-02-21
---
We have launched a new Cloudflare roadmap, revised ASP.NET Core roadmap and introduced a new dashboard design.
- Brand new [Cloudflare roadmap](https://roadmap.sh/cloudflare) to help you learn Cloudflare
- [ASP.NET Core roadmap](https://roadmap.sh/aspnet-core) has been revised with new content
- Fresh new dashboard design with improved navigation and performance
- Bug fixes and performance improvements

View File

@@ -1,22 +0,0 @@
---
title: 'DevOps Project Ideas, Team Dashboard, Redis Content'
description: 'New Project Ideas for DevOps, Team Dashboard, Redis Content'
images:
"DevOps Project Ideas": "https://assets.roadmap.sh/guest/devops-project-ideas.png"
"Redis Resources": "https://assets.roadmap.sh/guest/redis-resources.png"
"Team Dashboard": "https://assets.roadmap.sh/guest/team-dashboard.png"
seo:
title: 'DevOps Project Ideas, Team Dashboard, Redis Content'
description: ''
date: 2024-10-16
---
We have added 21 new project ideas to our DevOps roadmap, added content to Redis roadmap and introduced a new team dashboard for teams
- Practice your skills with [21 newly added DevOps Project Ideas](https://roadmap.sh/devops)
- We have a new [Dashboard for teams](https://roadmap.sh/teams) to track their team activity.
- [Redis roadmap](https://roadmap.sh/redis) now comes with learning resources.
- Watch us [interview Bruno Simon](https://www.youtube.com/watch?v=IQK9T05BsOw) about his journey as a creative developer.
- Bug fixes and performance improvements
ML Engineer roadmap and team dashboards are coming up next. Stay tuned!

View File

@@ -1,27 +0,0 @@
---
title: 'New Dashboard, Leaderboards and Projects'
description: 'New leaderboard page showing the most active users'
images:
"Personal Dashboard": "https://assets.roadmap.sh/guest/personal-dashboard.png"
"Projects Page": "https://assets.roadmap.sh/guest/projects-page.png"
"Leaderboard": "https://assets.roadmap.sh/guest/leaderboard.png"
seo:
title: 'Leaderboard Page - roadmap.sh'
description: ''
date: 2024-09-17
---
Focus for this week was improving the user experience and adding new features to the platform. Here are the highlights:
- New dashboard for logged-in users
- New leaderboard page
- Projects page listing all projects
- Ability to stop a started project
- Frontend and backend content improvements
- Bug fixes
[Dashboard](/) would allow logged-in users to keep track of their bookmarks, learning progress, project and more. You can still visit the [old homepage](https://roadmap.sh/home) once you login.
We also launched a new [leaderboard page](/leaderboard) showing the most active users, users who completed most projects and more.
There is also a [new projects page](/projects) where you can see all the projects you have been working on. You can also now stop a started project.

View File

@@ -1,21 +0,0 @@
---
title: 'PHP and System Design Roadmaps, Get Featured'
description: 'New PHP Roadmap, System Design Roadmap Revamped, and more'
images:
"PHP Roadmap": "https://assets.roadmap.sh/guest/php-roadmap.png"
"Engineering Manager Roadmap": "https://assets.roadmap.sh/guest/engineering-manager-roadmap.png"
"System Design Roadmap": "https://assets.roadmap.sh/guest/system-design.png"
"Feature Custom Roadmaps": "https://assets.roadmap.sh/guest/apply-for-feature.png"
seo:
title: 'PHP and System Design Roadmaps, Get Featured'
description: ''
date: 2024-12-21
---
We have a new PHP roadmap, System Design roadmap has been revamped. You can also get your custom roadmaps featured.
- One of the most requested [PHP Roadmap](https://roadmap.sh/php) is now live
- We have a new [Engineering Manager](https://roadmap.sh/engineering-manager) roadmap
- We have revamped [System Design Roadmap](https://roadmap.sh/system-design)
- Get your custom roadmaps featured on the [community roadmaps](/community)
- Bug fixes and performance improvements

View File

@@ -1,25 +0,0 @@
---
title: 'Redis Roadmap, Dashboard Changes, Bookmarks'
description: 'New leaderboard page showing the most active users'
images:
"Redis Roadmap": "https://assets.roadmap.sh/guest/redis-roadmap.png"
"Bookmarks": "https://assets.roadmap.sh/guest/bookmark-roadmaps.png"
"Dashboard": "https://assets.roadmap.sh/guest/dashboard-profile.png"
"Cyber Security Content": "https://assets.roadmap.sh/guest/cyber-security-content.png"
seo:
title: 'Redis Roadmap, Dashboard, Bookmarks - roadmap.sh'
description: ''
date: 2024-09-23
---
We have a new roadmap, some improvements to dashboard, bookmarks and more.
- [Redis roadmap](https://roadmap.sh/redis) is now live
- Progress and Bookmarks on dashboard are merged into a single section which makes it easy if you have a lot of bookmarks.
- Profile section on [dashboard](/) makes it easy to create profile
- Roadmaps can now be [bookmarked from any page](/roadmaps) that shows roadmaps.
- User profile now shows the projects you are working on.
- [Cyber Security roadmap](/cyber-security) is now filled with new content and resources.
- Buf fixes and improvements to some team features.
Next up, we are working on a new AI Engineer roadmap and teams dashboards.

View File

@@ -1,19 +0,0 @@
---
title: "Our first paid course about SQL is live"
description: 'We just launched our first paid SQL course'
images:
"SQL Course": "https://assets.roadmap.sh/guest/course-environment-87jg8.png"
"Course Creator Platform": "https://assets.roadmap.sh/guest/course-creator-platform.png"
seo:
title: 'SQL Course is Live'
description: ''
date: 2025-02-04
---
After months of work, I am excited to announce our [brand-new SQL course](/courses/sql) designed to help you master SQL with a hands-on, practical approach!
For the past few months, we have been working on building a course platform that would not only help us deliver high-quality educational content but also sustain the development of roadmap.sh. This SQL course is our first step in that direction.
The course has been designed with a focus on practical learning. Each topic is accompanied by hands-on exercises, real-world examples, and an integrated coding environment where you can practice what you learn. The AI integration provides personalized learning assistance, helping you grasp concepts better and faster.
Check out the course at [roadmap.sh/courses/sql](https://roadmap.sh/courses/sql)

View File

@@ -1,70 +0,0 @@
import type { MarkdownFileType } from './file';
export interface ChangelogFrontmatter {
title: string;
description: string;
images: Record<string, string>;
seo: {
title: string;
description: string;
};
date: string;
}
export type ChangelogFileType = MarkdownFileType<ChangelogFrontmatter> & {
id: string;
};
/**
* Generates id from the given changelog file
* @param filePath Markdown file path
*
* @returns unique changelog identifier
*/
function changelogPathToId(filePath: string): string {
const fileName = filePath.split('/').pop() || '';
return fileName.replace('.md', '');
}
/**
* Gets all the changelogs sorted by the publishing date
* @returns Promisifed guide files
*/
export async function getAllChangelogs(): Promise<ChangelogFileType[]> {
// @ts-ignore
const changelogs = import.meta.glob<ChangelogFileType>(
'/src/data/changelogs/*.md',
{
eager: true,
},
);
const changelogFiles = Object.values(changelogs) as ChangelogFileType[];
const enrichedChangelogs: ChangelogFileType[] = changelogFiles.map(
(changelogFile) => ({
...changelogFile,
id: changelogPathToId(changelogFile.file),
}),
);
return enrichedChangelogs.sort(
(a, b) =>
new Date(b.frontmatter.date).valueOf() -
new Date(a.frontmatter.date).valueOf(),
);
}
/**
* Gets the changelog by the given id
* @param id Changelog identifier
* @returns Promisified changelog file
*/
export async function getChangelogById(
id: string,
): Promise<ChangelogFileType | undefined> {
const allChangelogs = await getAllChangelogs();
return allChangelogs.find((changelog) => changelog.id === id);
}

View File

@@ -77,7 +77,10 @@ export async function httpCall<ResponseType = AppResponse>(
// Logout user if token is invalid
if (data?.status === 401) {
removeAuthToken();
window.location.href = '/login';
if (typeof window !== 'undefined') {
window.location.href = '/login';
}
return null as unknown as ApiReturn<ResponseType>;
}

View File

@@ -120,7 +120,7 @@ export async function getRoadmapsByTag(
const roadmapFiles: RoadmapFileType[] = Object.values(roadmapFilesMap);
const filteredRoadmaps = roadmapFiles
.filter((roadmapFile) => roadmapFile.frontmatter.tags.includes(tag))
.filter((roadmapFile) => roadmapFile.frontmatter.tags?.includes(tag))
.map((roadmapFile) => ({
...roadmapFile,
id: roadmapPathToId(roadmapFile.file),

View File

@@ -1,11 +1,10 @@
---
import SimplePageHeader from '../components/SimplePageHeader.astro';
import BaseLayout from '../layouts/BaseLayout.astro';
import { getAllChangelogs } from '../lib/changelog';
import ChangelogItem from '../components/Changelog/ChangelogItem.astro';
import ChangelogLaunch from '../components/Changelog/ChangelogLaunch.astro';
import BaseLayout from '../layouts/BaseLayout.astro';
import { listChangelog } from '../queries/changelog';
const allChangelogs = await getAllChangelogs();
const allChangelogs = await listChangelog();
---
<BaseLayout

37
src/queries/changelog.ts Normal file
View File

@@ -0,0 +1,37 @@
import { FetchError, httpGet } from '../lib/query-http';
export interface ChangelogImage {
title: string;
url: string;
}
export interface ChangelogDocument {
_id: string;
slug: string;
title: string;
description: string;
images?: ChangelogImage[];
createdAt: string;
updatedAt: string;
}
type ListChangelogQuery = {
limit?: number;
};
export async function listChangelog(query: ListChangelogQuery = {}) {
try {
const changelogs = await httpGet<ChangelogDocument[]>(
`/v1-list-changelog`,
query,
);
return changelogs;
} catch (error) {
if (FetchError.isFetchError(error) && error.status === 404) {
return [];
}
throw error;
}
}