diff --git a/LICENSE.md b/LICENSE.md index 81ee8d2..6a0b0d1 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -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. diff --git a/README.md b/README.md index cf5a6da..b6db4a5 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -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 diff --git a/WEBSITE_CONFIG.md b/WEBSITE_CONFIG.md index ca0f61c..f5ca17a 100644 --- a/WEBSITE_CONFIG.md +++ b/WEBSITE_CONFIG.md @@ -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 --- @@ -23,7 +26,9 @@ 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 `/`. @@ -31,6 +36,26 @@ Write standard Markdown here, including **bold text**, links, fenced code blocks 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. diff --git a/app/authors/[id]/page.tsx b/app/authors/[id]/page.tsx new file mode 100644 index 0000000..795d31f --- /dev/null +++ b/app/authors/[id]/page.tsx @@ -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 { + 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 ( + + + +

+ Posts by {author.name} +

+ {posts.length === 0 ? ( +

+ No posts available from this author. +

+ ) : ( + + )} +
+ ); +} diff --git a/app/authors/page.tsx b/app/authors/page.tsx new file mode 100644 index 0000000..0a06136 --- /dev/null +++ b/app/authors/page.tsx @@ -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 ( + + + {authors.length === 0 ? ( +

No authors yet.

+ ) : ( +
    + {authors.map((author) => ( +
  • + +
  • + ))} +
+ )} +
+ ); +} diff --git a/app/blog/[uid]/page.tsx b/app/blog/[uid]/page.tsx index 4dccfea..5d1f0f0 100644 --- a/app/blog/[uid]/page.tsx +++ b/app/blog/[uid]/page.tsx @@ -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; @@ -25,41 +37,66 @@ export async function generateMetadata({ params, }: PostPageProps): Promise { 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 ( - <> -
-

{data.title}

- -
-
-

WRITTEN BY

-

{data.authors.join(', ')}

-
-
-

PUBLISHED ON

- -
-
-
- - - - Return to blog - -
- + // data-wide widens the site's main column so the sidebar fits beside the text. +
+ + + + + + + + +
+ + + + + + + +
+
); -}; - -export default IndividualBlogPage; +} diff --git a/app/blog/page.tsx b/app/blog/page.tsx index 800ea53..85a2f2a 100644 --- a/app/blog/page.tsx +++ b/app/blog/page.tsx @@ -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 ( - <> -
-

Featured

- {posts.length === 0 ? ( -

No posts yet.

- ) : ( -
- {posts.map((item) => ( - - ))} -
- )} -
- + // 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 ( + +
+ + + Authors + +
+ {posts.length === 0 ? ( +

No posts yet.

+ ) : ( + [...postsByYear].map(([year, yearPosts]) => ( +
+

{year}

+ +
+ )) + )} +
+ ); +} diff --git a/app/error.tsx b/app/error.tsx index 88c4bf1..d5074fa 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -1,6 +1,6 @@ 'use client'; -import ServerError from '../components/ServerError'; +import ServerError from '@/components/common/ServerError'; export default function ErrorPage({ retry }: { retry: () => void }) { return ; diff --git a/app/events/page.tsx b/app/events/page.tsx deleted file mode 100644 index bfcea77..0000000 --- a/app/events/page.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import type { Metadata } from 'next'; -import UnderDev from '../../components/UnderDev'; - -export const metadata: Metadata = { title: 'Under development' }; - -const Events = () => { - return ; -}; - -export default Events; diff --git a/app/global-error.tsx b/app/global-error.tsx index 14212e1..9605d8c 100644 --- a/app/global-error.tsx +++ b/app/global-error.tsx @@ -1,14 +1,14 @@ 'use client'; -import ServerError from '../components/ServerError'; -import { themeScript } from '../lib/theme-script'; -import '../styles/globals.css'; +import ServerError from '@/components/common/ServerError'; +import ThemeScript from '@/components/common/ThemeScript'; +import '@/styles/globals.css'; export default function GlobalError({ retry }: { retry: () => void }) { return ( -