Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📗 add test post #16

Merged
merged 11 commits into from
Apr 7, 2024
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
12 changes: 11 additions & 1 deletion apps/katt.dev/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};
const nextConfig = {
images: {
remotePatterns: [
{
protocol: "https",
hostname: "github.com",
port: "",
},
],
},
};

export default nextConfig;
2 changes: 2 additions & 0 deletions apps/katt.dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
"next": "14.1.4",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-tweet": "^3.2.0",
"schema-dts": "^1.1.2",
"twoslash-cdn": "^0.2.5"
},
"devDependencies": {
"@next/eslint-plugin-next": "^14.1.1",
"@repo/eslint-config": "workspace:*",
"@repo/typescript-config": "workspace:*",
"@tailwindcss/typography": "^0.5.12",
"@types/node": "^20.12.4",
"@types/react": "^18.2.74",
"@types/react-dom": "^18.2.24",
Expand Down
24 changes: 17 additions & 7 deletions apps/katt.dev/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,26 @@
@tailwind components;
@tailwind utilities;

/* dark mode can wait */
/*
:root {
--color-fg: 20, 20, 20;
--color-bg: 244, 244, 244;
}
body {
background-color: rgb(var(--color-bg));
color: rgb(var(--color-fg));
}

@media (prefers-color-scheme: dark) {
:root {
--foreground-rgb: 255, 255, 255;
--background-start-rgb: 0, 0, 0;
--background-end-rgb: 0, 0, 0;
--color-fg: 244, 244, 244;
--color-bg: 20, 20, 20;
}
}
*/
}

/* transform all except .notprose with 300ms */
*:not(.not-prose) {
transition: all 300ms ease-out;
}

@layer utilities {
.text-balance {
Expand Down
64 changes: 32 additions & 32 deletions apps/katt.dev/src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
import { JsonLd } from '@/ui/JsonLd';
import { Analytics } from '@vercel/analytics/next';
import type { Metadata } from 'next';
import { Inter } from 'next/font/google';
import './globals.css';
import { JsonLd } from "@/ui/JsonLd";
import { Analytics } from "@vercel/analytics/next";
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "./globals.css";

const inter = Inter({ subsets: ['latin'] });
const inter = Inter({ subsets: ["latin"] });

export default function RootLayout({
children,
}: Readonly<{
}: {
children: React.ReactNode;
}>) {
}) {
return (
<html lang="en">
<body className={`${inter.className} h-full min-h-screen flex flex-col`}>
{children}

<JsonLd
data={{
'@context': 'https://schema.org',
'@type': 'Organization',
name: 'KATTCORP',
legalName: 'KATTCORP AB',
url: 'http://kattcorp.com',
foundingDate: '2016-10-26',
"@context": "https://schema.org",
"@type": "Organization",
name: "KATTCORP",
legalName: "KATTCORP AB",
url: "http://kattcorp.com",
foundingDate: "2016-10-26",
founders: [
{
'@type': 'Person',
name: 'Alexander Johansson',
"@type": "Person",
name: "Alexander Johansson",
},
],
address: {
'@type': 'PostalAddress',
addressCountry: 'Sweden',
"@type": "PostalAddress",
addressCountry: "Sweden",
},
contactPoint: {
'@type': 'ContactPoint',
contactType: 'sales',
email: '[email protected]',
url: 'https://twitter.com/alexdotjs',
"@type": "ContactPoint",
contactType: "sales",
email: "[email protected]",
url: "https://twitter.com/alexdotjs",
},
sameAs: [
'https://github.com/KATT',
'https://www.linkedin.com/in/johanssonalexander/',
'https://www.linkedin.com/company/19376256/',
'https://twitter.com/alexdotjs',
'https://katt.dev',
'https://kattcorp.com',
'https://kattcorp.co.uk',
"https://github.com/KATT",
"https://www.linkedin.com/in/johanssonalexander/",
"https://www.linkedin.com/company/19376256/",
"https://twitter.com/alexdotjs",
"https://katt.dev",
"https://kattcorp.com",
"https://kattcorp.co.uk",
],
}}
/>
Expand All @@ -58,11 +58,11 @@ export default function RootLayout({
}

export const metadata: Metadata = {
title: 'KATTCORP',
title: "KATTCORP",
description:
"KATTCORP is a software development company based in Sweden. We're a small team of developers who love to build things.",
metadataBase: new URL('https://katt.dev'),
metadataBase: new URL("https://katt.dev"),
alternates: {
canonical: '/',
canonical: "/",
},
};
56 changes: 56 additions & 0 deletions apps/katt.dev/src/app/post/2024-hello-world/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { JsonLd } from "@/ui/JsonLd";
import { Tweet } from "react-tweet";
import { PostAuthor } from "../ui/PostAuthor";

const postDate = "2024-04-06";

const headline = "Hello world";
const author: React.ComponentProps<typeof PostAuthor> = {
name: 'Alex "KATT" Johansson',
title: "Creator of tRPC",
avatarSrc: "https://github.com/KATT.png",
href: "https://twitter.com/alexdotjs",
};

export default function Page() {
return (
<>
<article className="prose dark:prose-invert">
<h1>{headline}</h1>
<div>
<time dateTime={postDate}>
{Intl.DateTimeFormat("en-US", {
year: "numeric",
month: "long",
day: "numeric",
}).format(new Date(postDate))}
</time>
</div>

<p>Hi, here's a tweet:</p>

<div className="not-prose">
<Tweet id="1594623014267658242" />
</div>

<div className="not-prose">
<PostAuthor {...author} />
</div>
</article>
<JsonLd
data={{
"@context": "https://schema.org",
"@type": "BlogPosting",
headline,
datePublished: postDate,
dateModified: postDate,
author: {
"@type": "Person",
name: author.name,
url: author.href,
},
}}
/>
</>
);
}
3 changes: 3 additions & 0 deletions apps/katt.dev/src/app/post/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Layout(props: { children: React.ReactNode }) {
return <div className="p-6">{props.children}</div>;
}
30 changes: 30 additions & 0 deletions apps/katt.dev/src/app/post/ui/PostAuthor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Image from "next/image";
import { ReactNode } from "react";

export function PostAuthor(props: {
name: string;
title: ReactNode;
avatarSrc: string;
href: string;
}) {
return (
<div className="relative mt-8 flex items-center gap-x-4">
<Image
src={props.avatarSrc}
alt={props.name}
width={40}
height={40}
className="h-10 w-10 rounded-full"
/>
<div className="text-sm leading-6">
<p className="font-semibold text-muted">
<a href={props.href}>
<span className="absolute inset-0"></span>
{props.name}
</a>
</p>
<p className="text-fg">{props.title}</p>
</div>
</div>
);
}
4 changes: 4 additions & 0 deletions apps/katt.dev/src/app/shiki/_snippet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Title

- some
- paragraphs
9 changes: 6 additions & 3 deletions apps/katt.dev/src/app/shiki/_snippet.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
console.log();
import { z } from "zod";
const foozzz = "bar";

const hello = 'world';
// ^?
// ..
// ..
const parsed = z.string().parse("foo");
// ^?
28 changes: 21 additions & 7 deletions apps/katt.dev/src/app/shiki/page.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
import { Code } from "@/ui/Code";
import { Suspense } from "react";
export default async function Page() {
return (
<ul className="space-y-6">
<Suspense>
<main className="prose dark:prose-invert p-8">
<h1>Shikiii code</h1>
<h2>Default stuff</h2>
<ul className="space-y-6">
<Code code={`console.log()`} lang="ts" />
</Suspense>
<Suspense>
<Code file={`/src/app/shiki/_snippet.ts`} lang="ts" />
</Suspense>
</ul>
</ul>

<h2>Classic</h2>
<ul className="space-y-6">
<Code code={`console.log()`} lang="ts" renderer="classic" />
<Code
file={`/src/app/shiki/_snippet.ts`}
lang="ts"
renderer="classic"
/>
</ul>

<h2>Markdown</h2>
<ul className="space-y-6">
<Code file={`/src/app/shiki/_snippet.md`} lang="markdown" />
</ul>
</main>
);
}
11 changes: 11 additions & 0 deletions apps/katt.dev/src/ui/Code.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@media (prefers-color-scheme: dark) {
.shiki,
.shiki span {
color: var(--shiki-dark) !important;
background-color: var(--shiki-dark-bg) !important;
/* Optional, if you also want font styles */
font-style: var(--shiki-dark-font-style) !important;
font-weight: var(--shiki-dark-font-weight) !important;
text-decoration: var(--shiki-dark-text-decoration) !important;
}
}
18 changes: 14 additions & 4 deletions apps/katt.dev/src/ui/Code.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import fs from "fs/promises";

import "@shikijs/twoslash/style-classic.css";
import "@shikijs/twoslash/style-rich.css";
import "./Code.css";
import { Suspense } from "react";

async function Render(props: ShikiSchemaInput) {
const html = await getShikiHtml(props);
return (
<div dangerouslySetInnerHTML={{ __html: html }} className="not-prose" />
);
}
export async function Code(
props: Omit<ShikiSchemaInput, "code"> &
(
Expand All @@ -18,9 +26,11 @@ export async function Code(
)
) {
const code =
props.code ??
(await fs.readFile(`${process.cwd()}/${props.file}`, "utf-8"));
props.code ?? (await fs.readFile(`${process.cwd()}${props.file}`, "utf-8"));

const html = await getShikiHtml({ ...props, code });
return <div dangerouslySetInnerHTML={{ __html: html }} />;
return (
<Suspense fallback={<pre>{props.code}</pre>}>
<Render {...props} code={code} />
</Suspense>
);
}
14 changes: 8 additions & 6 deletions apps/katt.dev/src/ui/LinkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ export function LinkList(props: {
}[];
}) {
return (
<ul className="flex list-none space-x-4">
<ul className="flex list-none space-x-4 text-fg">
{props.items.map((link) => (
<li
key={link.href}
className="flex flex-1 lowercase text-underline-500 underline"
>
<a href={link.href}>{link.title}</a>
<li key={link.href} className="flex flex-1">
<a
href={link.href}
className="hover:text-muted lowercase text-underline-500 underline"
>
{link.title}
</a>
</li>
))}
</ul>
Expand Down
Loading
Loading