Skip to content

Commit

Permalink
feat: explora-text-pannel
Browse files Browse the repository at this point in the history
  • Loading branch information
Apple authored and Apple committed Oct 2, 2024
1 parent 9881097 commit ab39ced
Show file tree
Hide file tree
Showing 27 changed files with 893 additions and 128 deletions.
5 changes: 3 additions & 2 deletions app/blogs/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { notFound } from 'next/navigation'
import { CustomMDX } from '@/components/mdx'
import { formatDate, getBlogPosts } from '@/blogs/utils'
import { getBlogPosts } from '@/blogs/utils'
import { formatDate } from '@/lib/utils'
import { baseUrl } from '@/sitemap'
import Footer from '@/components/footer'
import Link from 'next/link'
Expand Down Expand Up @@ -59,7 +60,7 @@ export default function Blog({ params }) {
}

return (
<section className='bg-white mx-auto text-left py-6 px-6 sm:px-8 md:px-10 lg:px-12 lg:w-[70%] md:w-[80%] sm:w-[90%] w-[100%]'>
<section className='mx-auto text-left py-6 px-6 sm:px-8 md:px-10 lg:px-12 lg:w-[70%] md:w-[80%] sm:w-[90%] w-[100%]'>
<div className='py-6 text-blue-500'>
<Link href={'/blogs'}>blogs</Link>
</div>
Expand Down
1 change: 0 additions & 1 deletion app/blogs/posts/compiling-c-cpp-to-webassembly-guide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ image: "/public/sumo-home.png"
summary: "Learn how to compile C/C++ code into WebAssembly with our comprehensive guide. Discover tools like Emscripten and LLVM for faster web applications."
---

# Compiling Low-Level Languages like C/C++ into WebAssembly: A Comprehensive Guide
<YouTube id = "L4Gqfte89gc" />
WebAssembly (WASM) has emerged as a powerful tool that extends the capabilities of web browsers beyond what JavaScript can offer. It enables the execution of code written in low-level languages such as C, C++, and Rust, directly in the browser, bringing performance close to native speed. This blog post explores compiling low-level languages into WebAssembly, focusing on tools such as Emscripten and LLVM.

Expand Down
1 change: 0 additions & 1 deletion app/blogs/posts/essential-steps-start-openai-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ publishedAt: '2024-06-20'
image: "/public/sumo-home.png"
summary: "​Start your OpenAI API journey with these 5 essential steps. From account setup and pricing to code integration, get started with ease and confidence."
---
# 5 Essential Steps to Start with OpenAI API

OpenAI APIs offer powerful capabilities to create intelligent applications, but diving into their features can be overwhelming for a beginner. This guide will walk you through five fundamental steps you need to get started with OpenAI API, helping you understand the essential aspects from account creation to code integration.

Expand Down
6 changes: 3 additions & 3 deletions app/components/@ui/blog-post/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from "next/link";
import Image from "next/image";
import { formatDate } from "@/blogs/utils";
import { formatDate } from "@/lib/utils";
import { canela_th, canela_regu } from "@/lib/fonts";

interface TBlogPost {
Expand All @@ -13,7 +13,7 @@ interface TBlogPost {
const BlogPost = ({ slug, title, publishedAt, summary }: TBlogPost) => {
return (
<Link
className={`${canela_th.className} flex gap-4 px-5 py-4 text-grey hover:text-tealBright lg:py-6 flex-wrap sm:px-6 md:px-8 lg:px-10 hover:scale-105 hover:shadow-shadowSm border-titledCream border-[1px] transition-shadow duration-500 ease-in-out bg-white rounded-md`}
className={`${canela_th.className} flex gap-4 px-5 py-4 text-grey hover:text-tealBright lg:py-6 flex-wrap sm:px-6 md:px-8 lg:px-10 hover:scale-105 hover:shadow-shadowSm border-titledCream border-[1px] duration-300 transition ease-in-out bg-white rounded-md`}
href={`/blogs/${slug}`}
>
<div className="w-full flex items-center flex-wrap my-2 relative">
Expand All @@ -24,7 +24,7 @@ const BlogPost = ({ slug, title, publishedAt, summary }: TBlogPost) => {
{title}
</div>
<div className="text-sm text-grey">
{formatDate(publishedAt, false)}
{formatDate(publishedAt)}
</div>
<div className="text-left mt-3 pr-16 max-sm:pr-0">
{summary}
Expand Down
2 changes: 1 addition & 1 deletion app/components/@ui/page/hero/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type HeroHeaderProps = {
const HeroHeader: React.FC<HeroHeaderProps> = ({ text, postText = null }) => {
return (
<header
className={`${canela.className} text-left sm:px-4 md:px-8 lg:px-14 text-grey leading-tight lg:text-7xl md:text-6xl text-5xl w-[100%] mx-auto py-6 md:py-6 lg:py-8`}
className={`${canela.className} mt-8 md:mt-16 text-left text-grey leading-tight md:text-6xl text-4xl sm:text-5xl w-full px-4 sm:px-8 lg:px-16`}
>
{text} {postText && <b className="text-tealBright">{postText}</b>}
</header>
Expand Down
21 changes: 21 additions & 0 deletions app/components/@ui/sidebar-icon/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client';

const SidebarIcon = ({ onClick }) => {
return (
<div
className="w-[30px] h-[30px] flex rounded-md border border-grey cursor-pointer"
onClick={onClick} // Attach the click event directly here
>
{/* left */}
<div className="w-[60%] flex flex-col gap-[6px] justify-center items-center bg-slate-100 border-r border-grey rounded-l-md ml-[1px] h-[100%]">
<div className="w-[60%] h-[1px] bg-slate-600"></div>
<div className="w-[60%] h-[1px] bg-slate-600"></div>
<div className="w-[60%] h-[1px] bg-slate-600"></div>
</div>
{/* right */}
<div className="w-[40%] rounded-r-sm rounded-br-sm h-[100%]"></div>
</div>
);
};

export default SidebarIcon;
6 changes: 3 additions & 3 deletions app/components/article/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ const Article = ( { children, heroHeaderText, postText }: TMetaData ) => {
return (
<>
<Header />
<div className="min-w-full px-2 text-center">
<article className={'prose-lg lg:text-xl text-[16px] max-w-5xl mx-auto px-4'}>
<div className="min-w-full text-center">
<article className={'prose-lg lg:text-xl text-[16px] max-w-5xl px-4 xs:px-16 mx-auto'}>
<HeroHeader text={ heroHeaderText } postText={postText}/>
{/* Here goes rest of content */}
<div className="text-left px-2 sm:px-4 md:px-8 lg:px-14 pt:10 md:pt-12 lg:pt-16">
<div className="text-left pt-4">
{ children }
</div>
</article>
Expand Down
100 changes: 100 additions & 0 deletions app/components/explora-sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
'use client';

import { useState, useEffect } from 'react';
import Link from 'next/link';
import SidebarIcon from '@/components/@ui/sidebar-icon'; // Import the SidebarIcon
import { canela_regu, canela_th } from '@/lib/fonts';

export default function Sidebar({ exploration, chapterSlug }) {
const [isOpen, setIsOpen] = useState(false);
const [isMobile, setIsMobile] = useState(false);

const toggleSidebar = () => {
setIsOpen(!isOpen);
};

// Detect if the screen size is small (for mobile behavior)
useEffect(() => {
const handleResize = () => {
const isMobileView = window.innerWidth <= 768; // Mobile threshold at 768px or below
setIsMobile(isMobileView);
// Set isOpen to true if it's a desktop view
if (!isMobileView) {
setIsOpen(true); // Open sidebar by default on larger screens
} else {
setIsOpen(false); // Close sidebar on mobile by default
}
};

handleResize(); // Initial check on mount
window.addEventListener('resize', handleResize); // Update on resize

return () => {
window.removeEventListener('resize', handleResize); // Cleanup on unmount
};
}, []);

return (
<>
{/* SidebarIcon: Render it in top-left for desktop and bottom-left for mobile */}

<aside
className={`${
isMobile
? `fixed top-0 left-0 h-full z-40 bg-white px-4 transition-transform duration-300 ${
isOpen ? 'translate-x-0' : '-translate-x-full'
}` // Slide in from left on small screens
: `sticky top-0 h-screen p-4 transition-transform duration-300 ${
isOpen ? 'w-1/5' : 'w-auto overflow-hidden'
}` // Standard sidebar behavior for large screens
}`}
>
<div
className={`z-50 p-3 rounded-md bg-white cursor-pointer transition-all duration-300 fixed bottom-16 ${isMobile ? 'left-16' : 'left-4'}`}
>
<SidebarIcon onClick={toggleSidebar} />
</div>

{(isMobile && isOpen) || (!isMobile && isOpen) ? (
<>
<div className="py-4 text-left">
<Link
href={"/explora"}
className={`relative flex items-center text-tealBright ${canela_th.className} text-2xl hover:text-black hover:pl-6 transition-all duration-200 after:content-[''] after:absolute after:left-0 after:transform after:-translate-x-full after:opacity-0 hover:after:opacity-100 hover:after:translate-x-0 after:transition-all after:duration-200 after:w-4 after:h-4 after:bg-no-repeat after:bg-left after:bg-contain after:bg-[url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20fill%3D%27none%27%20viewBox%3D%270%200%2024%2024%27%20stroke%3D%27teal%27%20class%3D%27w-4%20h-4%27%3E%3Cpath%20stroke-linecap%3D%27round%27%20stroke-linejoin%3D%27round%27%20stroke-width%3D%272%27%20d%3D%27M19%2012H5m7-7l-7%207%207%207%27/%3E%3C/svg%3E")]`}
>
Explorations
</Link>
</div>
<div>
<ul className={`${canela_regu.className} text-black flex flex-col gap-2`}>
<li className={`${!chapterSlug ? 'text-tealBright' : ''} mb-2 text-left hover:text-tealBright`}>
<Link href={`/explora/${exploration.exploration}`}>Overview</Link>
</li>
{exploration.chapters.map((chapter) => (
<li
key={chapter.slug}
className={`mb-2 text-left ${
chapter.slug === chapterSlug ? 'text-tealBright' : ''
} hover:text-tealBright`}
>
<Link href={`/explora/${exploration.exploration}/${chapter.slug}`}>
{chapter.metadata.title || `Chapter ${chapter.slug}`}
</Link>
</li>
))}
</ul>
</div>
</>
) : null}
</aside>

{/* Overlay for small screens when sidebar is open */}
{isMobile && isOpen && (
<div
className="fixed top-0 left-0 w-full h-full bg-black opacity-50 z-30"
onClick={toggleSidebar} // Close sidebar when clicking outside
/>
)}
</>
);
}
38 changes: 31 additions & 7 deletions app/components/header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,37 @@ const Header = () => {

</div>
{isMenuClicked && (
<div className="fixed hidden max-md:flex inset-0 bg-white z-50 flex-col justify-center items-center overflow-y-hidden">
<div className={`cursor-pointer absolute top-3 w-[90%] py-2 text-right`} onClick={toggleMenuButton}>x <b>close</b></div>
<Link className={`px-3 text-center text-grey py-2`} href={'/'} onClick={toggleMenuButton}> Home </Link>
<Link className={`px-3 text-center text-grey py-2`} href={'/blogs'} onClick={toggleMenuButton}> Blogs </Link>
<Link className={`px-3 text-center text-grey py-2`} href={'/contact'} onClick={toggleMenuButton}> Contact </Link>
<Link className={`px-3 text-center text-grey py-2`} href={'https://youtube.com/@howdevyou'} target="_blank" onClick={toggleMenuButton}> Youtube </Link>
</div>
<div className="fixed hidden max-md:flex inset-0 bg-white z-50 flex-col items-center overflow-y-hidden">
<div className={`cursor-pointer top-3 py-2 w-full text-right px-4`} onClick={toggleMenuButton}>x <b>close</b></div>
<ul className="w-[100%] border-solid border-[0.1rem] border-t-0 border-b-0">
<li className="border-t border-b-0 border-[0.1rem] py-1 flex leading-1">
<Link className="px-3 w-full text-left text-grey py-2" href="/" onClick={toggleMenuButton}>
Home
</Link>
</li>
<li className="border-t border-b-0 border-[0.1rem] flex leading-1">
<Link className="px-3 w-full text-left text-grey py-2" href="/explora" onClick={toggleMenuButton}>
Explorations
</Link>
</li>
<li className="border-t border-b-0 border-[0.1rem] flex leading-1">
<Link className="px-3 w-full text-left text-grey py-2" href="/blogs" onClick={toggleMenuButton}>
Blogs
</Link>
</li>
<li className="border-t border-b-0 border-[0.1rem] flex leading-1">
<Link className="px-3 w-full text-left text-grey py-2" href="/contact" onClick={toggleMenuButton}>
Contact
</Link>
</li>
<li className="border-t border-b border-[0.1rem] flex leading-1">
<Link className="px-3 w-full text-left text-grey py-2" href="https://youtube.com/@howdevyou" target="_blank" onClick={toggleMenuButton}>
Youtube
</Link>
</li>
</ul>

</div>
)}
</header>
);
Expand Down
82 changes: 72 additions & 10 deletions app/components/mdx.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Link from 'next/link'
import Image from 'next/image'
import { MDXRemote } from 'next-mdx-remote/rsc'
import { highlight } from 'sugar-high'
import rehypeHighlight from 'rehype-highlight'
import langHttp from 'highlight.js/lib/languages/javascript'
import langNginx from 'highlight.js/lib/languages/nginx'
import "highlight.js/styles/github-dark.css"
import React from 'react'
import { canela, canela_m, canela_regu, canela_sub } from '@/lib/fonts'

const options = {
mdxOptions: {
Expand All @@ -15,6 +15,10 @@ const options = {
}
}

function Para(props) {
return <p className={`${canela_regu.className} text-grey text-xl leading-[38px]`} {...props} />;
}

function Table({ data }) {
let headers = data.headers.map((header, index) => (
<th key={index}>{header}</th>
Expand Down Expand Up @@ -50,6 +54,45 @@ function YouTube ({ id }) {
);
};

function SomeT({ text, href }: { text: string, href: string }) {
return (
<span className="relative group inline-block">
{/* The hoverable element that reveals the link */}
<span className={`relative ${canela_regu.className} text-xl text-tealBright`}>
{text}
</span>

{/* The actual link, hidden by default and revealed on hover */}
<span
className="absolute text-grey font-bold invisible group-hover:visible py-2 px-4 bg-white left-1/2 transform -translate-x-1/2 -translate-y-[120%] mt-2 shadow-shadowMd"
style={{ whiteSpace: "nowrap" }}
>
<a
href={href}
className="block text-grey text-lg"
target='_blank'
style={{
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
maxWidth: "260px", // Adjust this as per the required width
}}
>
{href}
</a>
{/* Triangle pointer below the popup */}
<span
className="absolute left-1/2 transform -translate-x-1/2 bottom-[-6px] w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px] border-t-white"
/>
</span>
</span>
);
}





function CustomLink(props) {
let href = props.href

Expand Down Expand Up @@ -88,12 +131,13 @@ function slugify(str) {
.replace(/\-\-+/g, '-') // Replace multiple - with single -
}

function createHeading(level) {
function createHeading(level, font_fam) {
const Heading = ({ children }) => {
let slug = slugify(children)
return React.createElement(
`h${level}`,
{ id: slug },
{ id: slug, className: `${font_fam} text-black ${level === 3 ? "text-3xl" : "text-" + (6 - level) + "xl"}`,
},
[
React.createElement('a', {
href: `#${slug}`,
Expand All @@ -110,17 +154,35 @@ function createHeading(level) {
return Heading
}

function CustomUL(props) {
return <ul className="list-disc pl-6 mb-4 text-lg" {...props} />;
}

function CustomLI(props) {
return <li className={`${canela_regu.className} leading-relaxed text-grey`} {...props} />;
}

function StrongText({ children }) {
return <strong className="font-semibold text-tealBright">{children}</strong>;
}


let components = {
h1: createHeading(1),
h2: createHeading(2),
h3: createHeading(3),
h4: createHeading(4),
h5: createHeading(5),
h6: createHeading(6),
h1: createHeading(1, canela.className),
h2: createHeading(2, canela.className),
h3: createHeading(3, canela.className),
h4: createHeading(4, canela.className),
h5: createHeading(5, canela.className),
h6: createHeading(6, canela.className),
p: Para,
strong: StrongText,
Image: RoundedImage,
a: CustomLink,
ul: CustomUL,
li: CustomLI,
Table,
YouTube
YouTube,
SomeT
}

export function CustomMDX(props) {
Expand Down
3 changes: 2 additions & 1 deletion app/components/posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export function BlogPosts() {
return 1
})
.map((post) => (
<BlogPost
<BlogPost
key={post.metadata.title}
slug={post.slug}
title={post.metadata.title}
publishedAt={post.metadata.publishedAt}
Expand Down
Loading

0 comments on commit ab39ced

Please sign in to comment.