mirror of
https://github.com/OwethuManagedServices/oms-website-nextjs.git
synced 2025-12-17 15:48:09 +00:00
41 lines
1.5 KiB
TypeScript
41 lines
1.5 KiB
TypeScript
import React from "react";
|
|
import { auth } from "@/auth";
|
|
import { redirect } from "next/navigation";
|
|
import CreatePostForm from "@/components/CreatePostForm";
|
|
import type { Metadata } from "next";
|
|
|
|
// Metadata for the page, preventing search engine indexing
|
|
export const metadata: Metadata = {
|
|
title: "Create New TechTalk Post | OMS",
|
|
description: "Create a new blog post for OMS TechTalk.",
|
|
robots: { index: false, follow: false }, // Don't index the creation page
|
|
};
|
|
|
|
// Page component to render the creation form
|
|
export default async function CreateTechTalkPage() {
|
|
const session = await auth();
|
|
|
|
// Protect the route: Redirect if not logged in
|
|
if (!session?.user) {
|
|
// Redirect to sign-in page, passing the current page as callbackUrl
|
|
// This ensures the user returns here after successful login
|
|
const callbackUrl = encodeURIComponent("/tech-talk/create");
|
|
redirect(`/api/auth/signin?callbackUrl=${callbackUrl}`);
|
|
}
|
|
|
|
// Render the page content if the user is authenticated
|
|
return (
|
|
<div className="bg-background text-foreground">
|
|
<div className="container mx-auto px-4 py-16 sm:py-20 lg:py-24">
|
|
<div className="max-w-3xl mx-auto bg-card p-6 sm:p-8 rounded-lg border border-border shadow-md">
|
|
<h1 className="text-3xl md:text-4xl font-bold mb-8 text-center text-primary">
|
|
Create New TechTalk Post
|
|
</h1>
|
|
{/* Render the form component */}
|
|
<CreatePostForm />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|