Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
abuaboud committed Oct 2, 2023
2 parents ac6d517 + 177842f commit 59c55da
Show file tree
Hide file tree
Showing 12 changed files with 196 additions and 106 deletions.
146 changes: 82 additions & 64 deletions app/blog/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { NavigationProps } from "../../../components/navigationProps";
import { formatDate } from "@/utils/date-helper";
import { createClient } from "@supabase/supabase-js";
import { ApLink } from "../../../components/MyLink";
import { redirect } from "next/navigation";


export interface Blog {
title: string;
Expand All @@ -32,7 +34,8 @@ async function readBlogData(blogName: string, userPassword: string | undefined |
.select('*')
.eq('slug', blogName)
if (error) {
throw error

throw new Error(error.message)
}
if (!data || data.length === 0) {
throw new Error('Blog not found')
Expand Down Expand Up @@ -74,75 +77,90 @@ export async function generateMetadata({
}: NavigationProps): Promise<Metadata> {
const blogName = params.id;
const password = searchParams.password;
const { title, description, thumbnail, author } = await readBlogData(blogName, password);

return {
title: title + ' - Activepieces',
description: description,
openGraph: {
try {
const { title, description, thumbnail, author } = await readBlogData(blogName, password);
return {
title: title + ' - Activepieces',
description: description,
siteName: "Activepieces",
images: [
{
url: thumbnail,
width: 1200,
height: 630,
alt: "Activepieces Blog",
},
],
url: `www.activepieces.com/blog/${blogName}`,
},
authors: {
url: `www.activepieces.com/blog/${blogName}`,
name: author,
},
icons: "/favicon.ico",
};
openGraph: {
title: title + ' - Activepieces',
description: description,
siteName: "Activepieces",
images: [
{
url: thumbnail,
width: 1200,
height: 630,
alt: "Activepieces Blog",
},
],
url: `www.activepieces.com/blog/${blogName}`,
},
authors: {
url: `www.activepieces.com/blog/${blogName}`,
name: author,
},
icons: "/favicon.ico",
};
}
catch (ex) {
console.error(ex);
return {};

}



}

export default async function BlogPost({ params, searchParams }: NavigationProps) {
const blogName = params.id;
const password = searchParams.password;

const { publishedOn, content, title, thumbnail, author } = await readBlogData(blogName, password);
return (
<main className="bg-white w-full">
<section className="container mx-auto px-3 py-[80px] md:px-0 mx-auto ">
<nav className="text-lg mb-[35px]">
<ApLink href="/blog" className="no-underline">
{/* Apply your custom styles for the link */}
<span className="text-primary no-underline hover:underline cursor-pointer">
Blogs
</span>
</ApLink>{" "}
</nav>
<header className="mb-[35px] mx-auto text-left">
<h1 className="text-h1-sm lg:text-h1-lg font-bold mb-[35px]">
{title}
</h1>
<div className="text-black text-lg font-normal leading-snug tracking-wide mb-[35px]">
{author} | Published on {publishedOn}
try {
const { publishedOn, content, title, thumbnail, author } = await readBlogData(blogName, password);
return (
<main className="bg-white w-full">
<section className="container mx-auto px-3 py-[80px] md:px-0 mx-auto ">
<nav className="text-lg mb-[35px]">
<ApLink href="/blog" className="no-underline">
{/* Apply your custom styles for the link */}
<span className="text-primary no-underline hover:underline cursor-pointer">
Blogs
</span>
</ApLink>{" "}
</nav>
<header className="mb-[35px] mx-auto text-left">
<h1 className="text-h1-sm lg:text-h1-lg font-bold mb-[35px]">
{title}
</h1>
<div className="text-black text-lg font-normal leading-snug tracking-wide mb-[35px]">
{author} | Published on {publishedOn}
</div>
<div>
<Image
className="rounded-lg w-full h-full object-cover"
src={thumbnail}
alt="Blog thumbnail"
sizes="(max-width: 479px) 74vw, (max-width: 767px) 77vw, (max-width: 991px) 78vw, (max-width: 1279px) 87vw, (max-width: 1439px) 88vw, 1248px"
width={1248}
height={702}
/>
</div>
</header>
<div
className={
"prose max-w-none prose-a:text-primary prose-img:rounded-lg prose-img:w-full prose-img:h-full prose-img:object-cover prose-h1:text-h1-sm prose-h1:lg:text-h1-sm prose-h2:text-h2-sm prose-h2:lg:text-h2-sm prose-h3:text-h3-sm prose-h3:lg:text-h3-sm prose-h4:text-h4-sm prose-h4:lg:text-h4-sm prose-h5:text-h5-sm prose-h5:lg:text-h5-sm prose-h6:text-h6-sm prose-h6:lg:text-h6-sm prose-p:text-h6-sm prose-p:lg:text-h6-lg prose-li:text-h6-sm prose-li:lg:text-h6-lg prose-ol:text-h6-sm prose-ol:lg:text-h6-lg prose-ul:text-h6-sm prose-ul:lg:text-h6-lg"
}
>
<ReactMarkdown>{content}</ReactMarkdown>
</div>
<div>
<Image
className="rounded-lg w-full h-full object-cover"
src={thumbnail}
alt="Blog thumbnail"
sizes="(max-width: 479px) 74vw, (max-width: 767px) 77vw, (max-width: 991px) 78vw, (max-width: 1279px) 87vw, (max-width: 1439px) 88vw, 1248px"
width={1248}
height={702}
/>
</div>
</header>
<div
className={
"prose max-w-none prose-a:text-primary prose-img:rounded-lg prose-img:w-full prose-img:h-full prose-img:object-cover prose-h1:text-h1-sm prose-h1:lg:text-h1-sm prose-h2:text-h2-sm prose-h2:lg:text-h2-sm prose-h3:text-h3-sm prose-h3:lg:text-h3-sm prose-h4:text-h4-sm prose-h4:lg:text-h4-sm prose-h5:text-h5-sm prose-h5:lg:text-h5-sm prose-h6:text-h6-sm prose-h6:lg:text-h6-sm prose-p:text-h6-sm prose-p:lg:text-h6-lg prose-li:text-h6-sm prose-li:lg:text-h6-lg prose-ol:text-h6-sm prose-ol:lg:text-h6-lg prose-ul:text-h6-sm prose-ul:lg:text-h6-lg"
}
>
<ReactMarkdown>{content}</ReactMarkdown>
</div>
</section>
</main>
);
</section>
</main>
);
}
catch (ex) {
console.error((ex));
redirect("/404");
}

}
10 changes: 9 additions & 1 deletion app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Metadata } from "next";
import { AutomateWithActivepieces } from "../../components/animated-curtains/AutomateWithActivepieces";
import { BlogPost, getBlogs } from "@/utils/blogs-helper";
import { ApLink } from "../../components/MyLink";
import { redirect } from "next/navigation";


export async function generateMetadata(): Promise<Metadata> {
Expand Down Expand Up @@ -56,8 +57,15 @@ function BlogCard({ post }: { post: BlogPost }) {

export default async function BlogIndex() {
// Fetch data
let posts: BlogPost[] = [];
try {
posts = await getBlogs();
}
catch (ex) {
console.error(ex);
redirect("/404");
}

const posts = await getBlogs();

return (
<><main className="bg-white ">
Expand Down
4 changes: 4 additions & 0 deletions app/features/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { VisibilitySection } from "../../components/features-page/VisibilitySect
import { FeaturesSection } from "../../components/features-page/FeaturesSection";
import { FeaturesCarousel } from "../../components/features-page/FeaturesCarousel";
import { ApLink } from "../../components/MyLink";
import { redirect } from "next/navigation";


export async function generateMetadata(): Promise<Metadata> {
Expand All @@ -37,6 +38,9 @@ export async function generateMetadata(): Promise<Metadata> {

export default async function FindAppsPage() {
const pieces = (await GetPieces())
if (!pieces) {
redirect("/404");
}
return <>
<main className="bg-[#000000] pt-[80px] border border-solid border-[#000000]">
<section className="container mx-auto px-4 lg:px-0">
Expand Down
4 changes: 4 additions & 0 deletions app/find-apps/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NavigationProps } from "../../../components/navigationProps";
import { GetPieces } from "../../../utils/piece-helper";
import { allPiecesSort, corePieces } from "../../../components/utils";
import { ApLink } from "../../../components/MyLink";
import { redirect } from "next/navigation";
const alphabet = "abcdefghijklmnopqrstuvwxyz".toUpperCase().split("");

export function generateMetadata(
Expand Down Expand Up @@ -33,6 +34,9 @@ export function generateMetadata(

export default async function FindAppsPage({ params }: NavigationProps) {
const pieces = (await GetPieces());
if (!pieces) {
redirect("/404")
}
const allPieces = [...pieces, ...corePieces].sort(allPiecesSort);
const filteredPieces = allPieces
.filter((piece) => params.id ? (typeof piece === "string" ? piece.startsWith(params?.id.toLowerCase()) : piece.displayName.toLowerCase().startsWith(params?.id.toLowerCase())) : true);
Expand Down
4 changes: 4 additions & 0 deletions app/find-apps/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Metadata } from "next";
import { GetPieces } from "../../utils/piece-helper";
import { allPiecesSort, corePieces } from "../../components/utils";
import { ApLink } from "../../components/MyLink";
import { redirect } from "next/navigation";
const alphabet = "abcdefghijklmnopqrstuvwxyz".toUpperCase().split("");
export const metadata: Metadata = {
title: 'All apps - Connect your apps with Activepieces',
Expand All @@ -24,6 +25,9 @@ export const metadata: Metadata = {

export default async function FindAppsPage() {
const pieces = (await GetPieces());
if (!pieces) {
redirect("/404");
}
const allPieces = [...pieces, ...corePieces].sort(allPiecesSort);

return (
Expand Down
8 changes: 7 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { ComparisionSection } from '../components/landing-page/ComparisonSection
import { PiecesDictionarySection } from '../components/landing-page/PiecesDictionarySection';
import { DetailedPiece, GetPiece, GetPieces } from '../utils/piece-helper';
import { aiTemplates, generateTemplateFromDependencies, leadsTemplatesDeps, productivityTemplatesDeps } from '../components/flowTemplateGenerator';
import { redirect } from 'next/navigation';



export async function generateMetadata(): Promise<Metadata> {
Expand Down Expand Up @@ -44,8 +46,12 @@ export async function generateMetadata(): Promise<Metadata> {
export default async function Home() {
const pieces = await GetPieces();
const detailedPieces: DetailedPiece[] = [];
if (!pieces) { redirect("/404"); }
for (const p of pieces) {
detailedPieces.push(await GetPiece(p.name));
const piece = await GetPiece(p.name);
if (piece) {
detailedPieces.push(piece);
}
}
const leadsTemplates = leadsTemplatesDeps.map((t) => generateTemplateFromDependencies(t.description, detailedPieces, t.trigger, t.action));
const productivityTemplates = productivityTemplatesDeps.map((t) => generateTemplateFromDependencies(t.description, detailedPieces, t.trigger, t.action));
Expand Down
65 changes: 43 additions & 22 deletions app/pieces/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,59 @@ import { Metadata } from "next";
import { NavigationProps } from "../../../components/navigationProps";
import { AutomateWithActivepieces } from "../../../components/animated-curtains/AutomateWithActivepieces";
import { ApLink } from "../../../components/MyLink";
import { redirect } from 'next/navigation'



export async function generateMetadata(
{ params }: NavigationProps,
): Promise<Metadata> {
const pieceName = params.id;
const pieceData = await GetPiece(`@activepieces/piece-${pieceName}`);
const title = `${pieceData.displayName} Integrations - Connect your apps with Activepieces`
const description = `Connect ${pieceData.displayName} to hundreds of apps to automate your business. Activepieces is trusted by thousands of users who automate their everyday tasks.`
return {
title: title,
description: description,
openGraph: {
title: title,
description: description,
siteName: "Activepieces",
images: [
{
url: "https://www.activepieces.com/meta1.png",
width: 1200,
height: 630,
alt: "Activepieces",
}
],
url: "https://www.activepieces.com/pieces/" + pieceName,
},
icons: "/favicon.ico",
try {
const pieceName = params.id;
const pieceData = await GetPiece(`@activepieces/piece-${pieceName}`);
if (pieceData) {
const title = `${pieceData.displayName} Integrations - Connect your apps with Activepieces`
const description = `Connect ${pieceData.displayName} to hundreds of apps to automate your business. Activepieces is trusted by thousands of users who automate their everyday tasks.`
return {
title: title,
description: description,
openGraph: {
title: title,
description: description,
siteName: "Activepieces",
images: [
{
url: "https://www.activepieces.com/meta1.png",
width: 1200,
height: 630,
alt: "Activepieces",
}
],
url: "https://www.activepieces.com/pieces/" + pieceName,
},
icons: "/favicon.ico",
}
}
return {}
}
catch (ex) {
console.error((ex));
return {

}
}



}

export default async function PiecePage({ params }: NavigationProps) {
const pieceName = params.id;

const pieceData = await GetPiece(`@activepieces/piece-${pieceName}`);
if (!pieceData) {
redirect('/404')
}
const actions: ActionBase[][] = [[], []];
Object.values(pieceData.actions).forEach((action, i) => {
if (i % 2 === 0) {
Expand Down
5 changes: 5 additions & 0 deletions app/pieces/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import { Metadata } from "next";
import { GetPieces } from "../../utils/piece-helper";
import PiecesList from "../../components/pieces/List";
import { redirect } from "next/navigation";



export async function generateMetadata(): Promise<Metadata> {
Expand Down Expand Up @@ -31,6 +33,9 @@ export async function generateMetadata(): Promise<Metadata> {

export default async function PiecesPage() {
const pieces = await GetPieces();
if (!pieces) {
redirect("/404")
}
return (
<div className="flex justify-center justify-items-center content-center flex-col bg-white overflow-hidden">
<div className="bg-[url('/banner.svg')] py-4 md:py-0 bg-no-repeat sm:bg-[0%_0%] md:bg-[-360px] bg-black lg:bg-cover xl:bg-center text-white">
Expand Down
Loading

0 comments on commit 59c55da

Please sign in to comment.