Files
myeasycms-v2/apps/web/app/(marketing)/changelog/[slug]/page.tsx
Giancarlo Buomprisco 116d41a284 Changelog (#399)
* feat: add changelog feature and update site navigation

- Introduced a new Changelog page with pagination and detailed entry views.
- Added components for displaying changelog entries, pagination, and entry details.
- Updated site navigation to include a link to the new Changelog page.
- Enhanced localization for changelog-related texts in marketing.json.

* refactor: enhance Changelog page layout and entry display

- Increased the number of changelog entries displayed per page from 2 to 20 for better visibility.
- Improved the layout of the Changelog page by adjusting the container styles and removing unnecessary divs.
- Updated the ChangelogEntry component to enhance the visual presentation of entries, including a new date badge with an icon.
- Refined the CSS styles for Markdoc headings to improve typography and spacing.

* refactor: enhance Changelog page functionality and layout

- Increased the number of changelog entries displayed per page from 20 to 50 for improved user experience.
- Updated ChangelogEntry component to make the highlight prop optional and refined the layout for better visual clarity.
- Adjusted styles in ChangelogHeader and ChangelogPagination components for a more cohesive design.
- Removed unnecessary order fields from changelog markdown files to streamline content management.

* feat: enhance Changelog entry navigation and data loading

- Refactored ChangelogEntry page to load previous and next entries for improved navigation.
- Introduced ChangelogNavigation component to facilitate navigation between changelog entries.
- Updated ChangelogDetail component to display navigation links and entry details.
- Enhanced data fetching logic to retrieve all changelog entries alongside the current entry.
- Added localization keys for navigation text in marketing.json.

* Update package dependencies and enhance documentation layout

- Upgraded various packages including @turbo/gen and turbo to version 2.6.0, and react-hook-form to version 7.66.0.
- Updated lucide-react to version 0.552.0 across multiple packages.
- Refactored documentation layout components for improved styling and structure.
- Removed deprecated loading components and adjusted navigation elements for better user experience.
- Added placeholder notes in changelog entries for clarity.
2025-11-01 11:59:52 +07:00

111 lines
2.4 KiB
TypeScript

import { cache } from 'react';
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import { createCmsClient } from '@kit/cms';
import { withI18n } from '~/lib/i18n/with-i18n';
import { ChangelogDetail } from '../_components/changelog-detail';
interface ChangelogEntryPageProps {
params: Promise<{ slug: string }>;
}
const getChangelogData = cache(changelogEntryLoader);
async function changelogEntryLoader(slug: string) {
const client = await createCmsClient();
const [entry, allEntries] = await Promise.all([
client.getContentItemBySlug({ slug, collection: 'changelog' }),
client.getContentItems({
collection: 'changelog',
sortBy: 'publishedAt',
sortDirection: 'desc',
content: false,
}),
]);
if (!entry) {
return null;
}
// Find previous and next entries in the timeline
const currentIndex = allEntries.items.findIndex((item) => item.slug === slug);
const previousEntry =
currentIndex > 0 ? allEntries.items[currentIndex - 1] : null;
const nextEntry =
currentIndex < allEntries.items.length - 1
? allEntries.items[currentIndex + 1]
: null;
return {
entry,
previousEntry,
nextEntry,
};
}
export async function generateMetadata({
params,
}: ChangelogEntryPageProps): Promise<Metadata> {
const slug = (await params).slug;
const data = await getChangelogData(slug);
if (!data) {
notFound();
}
const { title, publishedAt, description, image } = data.entry;
return Promise.resolve({
title,
description,
openGraph: {
title,
description,
type: 'article',
publishedTime: publishedAt,
url: data.entry.url,
images: image
? [
{
url: image,
},
]
: [],
},
twitter: {
card: 'summary_large_image',
title,
description,
images: image ? [image] : [],
},
});
}
async function ChangelogEntryPage({ params }: ChangelogEntryPageProps) {
const slug = (await params).slug;
const data = await getChangelogData(slug);
if (!data) {
notFound();
}
return (
<div className="container sm:max-w-none sm:p-0">
<ChangelogDetail
entry={data.entry}
content={data.entry.content}
previousEntry={data.previousEntry ?? null}
nextEntry={data.nextEntry ?? null}
/>
</div>
);
}
export default withI18n(ChangelogEntryPage);