Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
MIT License
Copyright (c) 2022 Manipal OSF
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License

Copyright (c) 2022 Manipal OSF

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pnpm format

CI runs the production build with `pnpm build`. A deployed Node.js application starts with `pnpm start`. Configure hosting to use the repository root, with `pnpm install --frozen-lockfile` as the install command and `pnpm build` as the build command.

## Blog posts

See [website configuration](./WEBSITE_CONFIG.md) for the Markdown format, images, and publishing instructions. The blog initially displays “No posts yet.” Add your own content to `content/posts/`; existing hosted content is not copied automatically.

The `@next/mdx` component registry lives in `mdx-components.tsx` at the repository root, beside `app/`, as required by Next.js. Keep it there when adding MDX components. The filesystem blog continues to render Markdown using `MarkdownRenderer`.
Expand Down Expand Up @@ -89,7 +87,7 @@ Use a deployment that supports the Next.js Node.js runtime when adding Route Han

## Page transitions

Internal site links use `components/TransitionLink` and `next-transition-router` to finish the current page's exit animation before navigating, then reset scroll and animate the new page in. The shared header and footer stay mounted. Browser Back/Forward uses native navigation and scroll restoration without page transitions. Use the transition-aware Link with `scroll={false}` when adding site navigation; external links and Markdown anchors retain normal browser behavior.
Internal site links use `components/common/TransitionLink` and `next-transition-router` to finish the current page's exit animation before navigating, then reset scroll and animate the new page in. The shared header and footer stay mounted. Browser Back/Forward uses native navigation and scroll restoration without page transitions. Use the transition-aware Link with `scroll={false}` when adding site navigation; external links and Markdown anchors retain normal browser behavior.

## Contributing

Expand Down
29 changes: 27 additions & 2 deletions WEBSITE_CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ Create `content/posts/your-post.md`:
---
id: your-post
title: Your post title
description: One-sentence summary shown on the blog list and in link previews.
authors:
- Your Name
- your-author-id
publishDate: '2026-10-08'
status: draft
tags:
- open-source
coverImage: /images/your-post.jpg
---

Expand All @@ -23,14 +26,36 @@ Write standard Markdown here, including **bold text**, links, fenced code blocks
```

- `id` determines the URL (`/blog/your-post`), independently of the filename. IDs must be unique across drafts and published posts and contain only letters, numbers, underscores, or hyphens. Numeric IDs are supported for preserving existing URLs.
- `title` is a non-empty string; `authors` is a non-empty array of names.
- `title` is a non-empty string; `authors` is a non-empty array. Each entry is either an author ID from `content/authors/` (shown with an avatar and a link to their profile) or a plain name for contributors without a profile.
- `description` and `tags` are optional. Tags are displayed as badges.
- Reading time is calculated from the body at roughly 200 words per minute; it is not set in frontmatter.
- `publishDate` is a quoted, valid `YYYY-MM-DD` date. Published posts sort newest first. This date is display metadata, not a publishing schedule.
- `status` must be `draft` or `published`. Only published posts appear in the list or have public detail pages. There is no draft preview.
- `coverImage` is optional. Place the example image in `public/images/your-post.jpg`; omit this field to display the existing placeholder. Images must use local public paths beginning with a single `/`.
- The body supports Markdown rather than JSX or raw HTML. Start headings at `##`, since the page already renders the title as an `h1`.

The directory initially contains only `.gitkeep`, so the blog shows “No posts yet.” Invalid metadata and duplicate IDs produce errors identifying the offending post or ID.

## Add an author profile

Create `content/authors/your-author-id.md`. The filename (without `.md`) is the author ID used in post `authors` lists and in the profile URL (`/authors/your-author-id`):

```md
---
name: Your Name
pronouns: they/them
avatar: /authors/your-author-id.png
bio: A short line about yourself.
website: https://example.com
github: https://github.com/your-username
linkedin: https://www.linkedin.com/in/your-username
twitter: https://x.com/your-username
mail: you@example.com
---
```

Only `name` is required. `avatar` must be a local public path (place the image in `public/authors/`); without one, the author's initial is shown. Links must use `https://`. Each post page ends with the profiles of its registered authors, and `/authors` lists everyone.

## Publish

Change `status` to `published`, commit the Markdown and any images, and deploy. App Router Server Components and `generateStaticParams` generate blog pages during the production build; additions, edits, and removals require a rebuild and deployment. During development, the content loader reads files on each page request. Reload the page to see content changes; new published IDs work without restarting the dev server.
Expand Down
63 changes: 63 additions & 0 deletions app/authors/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import AuthorCard from '@/components/authors/AuthorCard';
import PostList from '@/components/blog/PostList';
import Breadcrumbs from '@/components/common/Breadcrumbs';
import Container from '@/components/common/Container';
import { getAllAuthors, getAuthor } from '@/lib/content/authors';
import { getPostsByAuthor } from '@/lib/content/posts';

// reference: https://pranavu.dev

export const dynamicParams = false;

export async function generateStaticParams() {
return (await getAllAuthors()).map((author) => ({ id: author.id }));
}

type AuthorPageProps = { params: Promise<{ id: string }> };

async function loadAuthor(params: AuthorPageProps['params']) {
const { id } = await params;
const author = await getAuthor(id);
if (!author) notFound();
return author;
}

export async function generateMetadata({
params,
}: AuthorPageProps): Promise<Metadata> {
const author = await loadAuthor(params);
return {
title: author.name,
description: author.bio ?? `Posts by ${author.name}.`,
};
}

export default async function AuthorPage({ params }: AuthorPageProps) {
const author = await loadAuthor(params);
const posts = await getPostsByAuthor(author.id);

return (
<Container className='flex flex-col gap-6'>
<Breadcrumbs
items={[
{ label: 'Blog', href: '/blog' },
{ label: 'Authors', href: '/authors' },
{ label: author.name },
]}
/>
<AuthorCard author={author} linkToProfile={false} />
<h2 className='text-foreground text-2xl font-medium'>
Posts by {author.name}
</h2>
{posts.length === 0 ? (
<p className='text-muted-foreground text-sm'>
No posts available from this author.
</p>
) : (
<PostList posts={posts} />
)}
</Container>
);
}
29 changes: 29 additions & 0 deletions app/authors/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { Metadata } from 'next';
import AuthorCard from '@/components/authors/AuthorCard';
import Breadcrumbs from '@/components/common/Breadcrumbs';
import Container from '@/components/common/Container';
import { getAllAuthors } from '@/lib/content/authors';

export const metadata: Metadata = { title: 'Authors' };

export default async function AuthorsPage() {
const authors = await getAllAuthors();
return (
<Container className='flex flex-col gap-6'>
<Breadcrumbs
items={[{ label: 'Blog', href: '/blog' }, { label: 'Authors' }]}
/>
{authors.length === 0 ? (
<p className='text-muted-foreground text-sm'>No authors yet.</p>
) : (
<ul className='flex flex-col gap-4'>
{authors.map((author) => (
<li key={author.id}>
<AuthorCard author={author} />
</li>
))}
</ul>
)}
</Container>
);
}
115 changes: 76 additions & 39 deletions app/blog/[uid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
import type { Metadata } from 'next';
import { notFound } from 'next/navigation';
import Link from '../../../components/TransitionLink';
import { ArrowLeft } from 'lucide-react';
import { getPost, getPublishedPosts } from '../../../lib/posts';
import CustomImage from '../../../components/CustomImage';
import MarkdownRenderer from '../../../components/MarkdownRenderer';
import AuthorProfiles from '@/components/authors/AuthorProfiles';
import CoverImage from '@/components/blog/CoverImage';
import MarkdownRenderer from '@/components/blog/MarkdownRenderer';
import PostHeader from '@/components/blog/PostHeader';
import PostNavigation from '@/components/blog/PostNavigation';
import {
TableOfContentsDropdown,
TableOfContentsSidebar,
} from '@/components/blog/TableOfContents';
import Breadcrumbs from '@/components/common/Breadcrumbs';
import Container from '@/components/common/Container';
import { resolveAuthors } from '@/lib/content/authors';
import {
getAdjacentPosts,
getPost,
getPublishedPosts,
} from '@/lib/content/posts';

export const dynamicParams = false;

Expand All @@ -25,41 +37,66 @@ export async function generateMetadata({
params,
}: PostPageProps): Promise<Metadata> {
const post = await loadPost(params);
return { title: `${post.title} | Manipal OSF` };
const authors = await resolveAuthors(post.authors);
const description = post.description ?? undefined;
return {
title: post.title,
description,
authors: authors.map((author) => ({
name: author.name,
url: author.isRegistered ? `/authors/${author.id}` : undefined,
})),
openGraph: {
type: 'article',
title: post.title,
description,
publishedTime: post.publishDate,
authors: authors.map((author) => author.name),
tags: post.tags,
},
};
}

const IndividualBlogPage = async ({ params }: PostPageProps) => {
const data = await loadPost(params);
export default async function PostPage({ params }: PostPageProps) {
const post = await loadPost(params);
const [authors, { newer, older }] = await Promise.all([
resolveAuthors(post.authors),
getAdjacentPosts(post.id),
]);

return (
<>
<article className='flex w-full flex-grow-[1] flex-col gap-10 px-3 dark:text-white md:px-10'>
<h1 className='text-5xl md:text-6xl'>{data.title}</h1>
<CustomImage data={data.coverImage} alt={data.title} />
<div className='flex justify-between gap-4'>
<div className='flex flex-col gap-1'>
<h2 className='text-base font-bold md:text-lg'>WRITTEN BY</h2>
<p className='text-lg md:text-xl'>{data.authors.join(', ')}</p>
</div>
<div className='flex flex-col items-end gap-1'>
<h2 className='text-base font-bold md:text-lg'>PUBLISHED ON</h2>
<time dateTime={data.publishDate} className='text-lg md:text-xl'>
{data.publishDate}
</time>
</div>
</div>
<hr className='border-gray-900 opacity-50 dark:border-gray-300' />
<MarkdownRenderer content={data.content} />
<Link
href='/blog'
scroll={false}
className='flex w-fit items-center justify-center gap-5 rounded-lg bg-black p-2 text-2xl text-white dark:bg-white dark:text-black md:text-3xl'
>
<ArrowLeft className='size-4' />
<span>Return to blog</span>
</Link>
</article>
</>
// data-wide widens the site's main column so the sidebar fits beside the text.
<article data-wide className='flex w-full flex-col gap-6'>
<Container>
<Breadcrumbs
items={[{ label: 'Blog', href: '/blog' }, { label: post.title }]}
/>
</Container>
<CoverImage
src={post.coverImage}
alt={post.title}
sizes='(min-width: 64rem) 64rem, 100vw'
preload
className='mx-auto aspect-[1200/630] w-full max-w-5xl rounded-xl'
/>
<Container className='flex flex-col gap-6'>
<PostHeader post={post} authors={authors} />
<PostNavigation newer={newer} older={older} />
</Container>
<div className='grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_48rem_minmax(0,1fr)]'>
<aside className='hidden xl:block'>
<TableOfContentsSidebar headings={post.headings} className='pr-8' />
</aside>
<Container className='flex flex-col gap-6'>
<TableOfContentsDropdown
headings={post.headings}
className='xl:hidden'
/>
<MarkdownRenderer content={post.content} />
<AuthorProfiles authors={authors} />
<PostNavigation newer={newer} older={older} />
</Container>
</div>
</article>
);
};

export default IndividualBlogPage;
}
56 changes: 35 additions & 21 deletions app/blog/page.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
import type { Metadata } from 'next';
import BlogCard from '../../components/BlogCard';
import { getPublishedPosts } from '../../lib/posts';
import PostList from '@/components/blog/PostList';
import Breadcrumbs from '@/components/common/Breadcrumbs';
import Container from '@/components/common/Container';
import Link from '@/components/common/TransitionLink';
import { getPublishedPosts } from '@/lib/content/posts';

export const metadata: Metadata = { title: 'Blog | Manipal OSF' };
export const metadata: Metadata = { title: 'Blog' };

const BlogPage = async () => {
export default async function BlogPage() {
const posts = await getPublishedPosts();
return (
<>
<section className='flex flex-col gap-6'>
<h1 className='text-foreground text-2xl font-medium'>Featured</h1>
{posts.length === 0 ? (
<p className='text-muted-foreground text-sm'>No posts yet.</p>
) : (
<div className='flex flex-col gap-4'>
{posts.map((item) => (
<BlogCard data={item} key={item.id} />
))}
</div>
)}
</section>
</>
// Posts are sorted newest first, so years come out in descending order.
const postsByYear = Map.groupBy(posts, (post) =>
post.publishDate.slice(0, 4)
);
};

export default BlogPage;
return (
<Container className='flex flex-col gap-8'>
<div className='flex flex-wrap items-center justify-between gap-4'>
<Breadcrumbs items={[{ label: 'Blog' }]} />
<Link
href='/authors'
scroll={false}
className='text-muted-foreground hover:text-foreground text-sm'
>
Authors
</Link>
</div>
{posts.length === 0 ? (
<p className='text-muted-foreground text-sm'>No posts yet.</p>
) : (
[...postsByYear].map(([year, yearPosts]) => (
<section key={year} className='flex flex-col gap-4'>
<h2 className='text-foreground font-medium'>{year}</h2>
<PostList posts={yearPosts} />
</section>
))
)}
</Container>
);
}
Loading
Loading