Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
fix: build and update blog
mxkaskee2c96e937e12
diff --git a/apps/web/contentlayer.config.ts b/apps/web/contentlayer.config.tsindex 6b4924f97..1658bc06b 100644--- a/apps/web/contentlayer.config.ts+++ b/apps/web/contentlayer.config.ts@@ -1,30 +1,16 @@import { makeSource } from "contentlayer/source-files";-import rehypeAutolinkHeadings from "rehype-autolink-headings";-import rehypePrettyCode from "rehype-pretty-code";import rehypeSlug from "rehype-slug";import remarkGfm from "remark-gfm";-import { Post } from "./src/lib/contentlayer/documents/Post";-import { rehypePrettyCodeOptions } from "./src/lib/contentlayer/rehype-pretty-code";+import { Post } from "./src/contentlayer/documents/post";+import autolinkHeadings from "./src/contentlayer/plugins/autolink-headings";+import prettyCode from "./src/contentlayer/plugins/pretty-code";export default makeSource({- // Location of source files for all defined documentTypescontentDirPath: "src/content/",documentTypes: [Post],mdx: {- remarkPlugins: [[remarkGfm]],- rehypePlugins: [- [rehypeSlug],- [rehypePrettyCode, rehypePrettyCodeOptions],- [- rehypeAutolinkHeadings,- {- behavior: "wrap",- properties: {- className: `before:content-['#'] before:absolute before:-ml-[1em] before:text-white-100/0 hover:before:text-white-100/50 pl-[1em] -ml-[1em]`,- },- },- ],- ],+ remarkPlugins: [remarkGfm],+ rehypePlugins: [rehypeSlug, prettyCode, autolinkHeadings],},});diff --git a/apps/web/package.json b/apps/web/package.jsonindex 9cfdc3686..bb0a83fac 100644--- a/apps/web/package.json+++ b/apps/web/package.json@@ -4,7 +4,7 @@"private": true,"scripts": {"dev": "next dev",- "build": "contentlayer build && next build",+ "build": "next build","start": "next start","lint": "next lint"},@@ -76,6 +76,7 @@"remark-gfm": "^3.0.1","tailwindcss": "3.3.2","tsconfig": "workspace:*",- "typescript": "5.1.3"+ "typescript": "5.1.3",+ "unified": "^10.1.2"}}diff --git a/apps/web/src/app/blog/[slug]/page.tsx b/apps/web/src/app/blog/[slug]/page.tsxindex 9165ff93e..0cb6ff4d4 100644--- a/apps/web/src/app/blog/[slug]/page.tsx+++ b/apps/web/src/app/blog/[slug]/page.tsx@@ -3,9 +3,10 @@ import Link from "next/link";import { notFound } from "next/navigation";import { allPosts } from "contentlayer/generated";-import { BackButton } from "@/components/layout/back-button";-import { Footer } from "@/components/layout/footer";-import { Mdx } from "@/components/mdx";+import { Mdx } from "@/components/content/mdx";+import { formatDate } from "@/lib/utils";++export const dynamic = "force-static";export async function generateStaticParams() {return allPosts.map((post) => ({@@ -17,7 +18,7 @@ export async function generateMetadata({params,}: {params: { slug: string };-}): Promise<Metadata | undefined> {+}): Promise<Metadata | void> {const post = allPosts.find((post) => post.slug === params.slug);if (!post) {return;@@ -56,35 +57,23 @@ export default function PostPage({ params }: { params: { slug: string } }) {if (!post) {notFound();}- return (- <>- <article className="relative my-5 grid grid-cols-[1fr,min(90%,100%),1fr] gap-y-8 sm:grid-cols-[1fr,min(90%,100%),1fr] sm:pt-8 md:grid md:grid-cols-[1fr,min(80%,100%),1fr] lg:grid-cols-[1fr,min(70%,100%),1fr] xl:grid-cols-[1fr,minmax(auto,240px),min(50%,100%),minmax(auto,240px),1fr] xl:gap-x-5 xl:px-0 [&>*]:col-start-2 xl:[&>*]:col-start-3">- <div>- <BackButton />- </div>- <section className="mt-1">- <div className="mt-2 w-full sm:pointer-events-none xl:!col-end-5">- <h1 className="text-3xl font-bold sm:text-4xl">{post.title}</h1>- </div>- <div className="mt-2 flex flex-col items-center justify-between sm:flex-row">- <div>- <Link href={post.authorLink}>{post.author}</Link>- <span className="text-muted-foreground">- {" / "}- {post.publishedAtFormatted}- </span>- </div>- <div className="text-muted-foreground text-sm sm:pointer-events-none lg:text-base">- ~{post.readingTime}- </div>- </div>- </section>-- {/* load Post content stored in .mdx format */}+ // TODO: add author.avatar and author.url+ return (+ <article className="grid gap-8">+ <div className="mx-auto grid max-w-prose gap-3">+ <h1 className="font-cal text-3xl">{post.title}</h1>+ <p className="text-muted-foreground text-sm font-light">+ {post.author.name}+ <span className="text-muted-foreground/70 mx-1">•</span>+ {formatDate(new Date(post.publishedAt))}+ <span className="text-muted-foreground/70 mx-1">•</span>+ {post.readingTime}+ </p>+ </div>+ <div className="mx-auto max-w-prose"><Mdx code={post.body.code} />- </article>- <Footer />- </>+ </div>+ </article>);}diff --git a/apps/web/src/app/blog/layout.tsx b/apps/web/src/app/blog/layout.tsxnew file mode 100644index 000000000..1f9cc5d18--- /dev/null+++ b/apps/web/src/app/blog/layout.tsx@@ -0,0 +1,23 @@+import * as React from "react";++import { Shell } from "@/components/dashboard/shell";+import { BackButton } from "@/components/layout/back-button";+import { Footer } from "@/components/layout/footer";++export default function BlogLayout({+ children,+}: {+ children: React.ReactNode;+}) {+ return (+ <main className="container mx-auto flex min-h-screen w-full flex-col items-center justify-center space-y-6 p-4 md:p-8">+ <div className="z-10 flex w-full flex-1 flex-col items-start justify-center">+ <div className="mx-auto w-full max-w-prose">+ <BackButton />+ </div>+ <Shell className="mx-auto w-full max-w-prose">{children}</Shell>+ </div>+ <Footer />+ </main>+ );+}diff --git a/apps/web/src/app/blog/page.tsx b/apps/web/src/app/blog/page.tsxindex 3d0be025d..ab73282d0 100644--- a/apps/web/src/app/blog/page.tsx+++ b/apps/web/src/app/blog/page.tsx@@ -1,46 +1,34 @@import Link from "next/link";import { allPosts } from "contentlayer/generated";-import { BackButton } from "@/components/layout/back-button";-import { Footer } from "@/components/layout/footer";-import { getDisplayPosts } from "@/lib/contentlayer/utils";+import { formatDate } from "@/lib/utils";export default async function Post() {- const posts = await getDisplayPosts(allPosts);+ const posts = allPosts.sort(+ (a, b) =>+ new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime(),+ );return (- <main className="mx-5 mb-7 flex flex-col items-start pt-24 sm:mx-20 md:mx-32 md:pt-28 lg:mx-60 xl:mx-96">- <h1 className="text-foreground font-cal mb-4 mt-2 text-5xl">Blog</h1>- <BackButton />-- {/* All posts */}- <section className="mb-8 ">- {posts.map((Post, idx) => (- <div key={Post.slug} className="mt-10">- <Link- href={`/blog/${Post.slug}`}- className="text-foreground font-cal text-2xl"- >- <span>{idx + 1}. </span>- {Post.title}- </Link>- <p className="text-muted-foreground text-base">- {Post.description}- </p>-- <div className="text-muted-foreground mt-2 flex flex-row justify-start gap-5 text-sm">- <Link href={Post.authorLink} className="hidden sm:inline">- {Post.author}- </Link>- <span className="hidden sm:inline">/</span>- <p>{Post.publishedAtFormatted}</p>- <span>/</span>- <p>{Post.readingTime}</p>- </div>- </div>+ <div className="grid gap-8">+ <h1 className="text-foreground font-cal text-4xl">Blog</h1>+ <div>+ {posts.map((post) => (+ <Link href={`/blog/${post.slug}`} key={post.slug}>+ <section>+ <p className="text-foreground font-cal text-2xl">{post.title}</p>+ <p className="text-muted-foreground">{post.description}</p>+ <p className="text-muted-foreground mt-1 text-xs">+ {post.author.name}+ <span className="text-muted-foreground/70 mx-1">•</span>+ {formatDate(new Date(post.publishedAt))}+ <span className="text-muted-foreground/70 mx-1">•</span>+ {post.readingTime}+ </p>+ </section>+ </Link>))}- </section>- <Footer />- </main>+ </div>+ </div>);}diff --git a/apps/web/src/app/page.tsx b/apps/web/src/app/page.tsxindex 486bf00b8..b33a67650 100644--- a/apps/web/src/app/page.tsx+++ b/apps/web/src/app/page.tsx@@ -37,9 +37,6 @@ export default async function Page() {Star on GitHub</a></Button>- <Button variant="link">- <Link href="/blog">Blog</Link>- </Button></div><HeroForm /></div>diff --git a/apps/web/src/components/content/mdx-components.tsx b/apps/web/src/components/content/mdx-components.tsxnew file mode 100644index 000000000..22f2bf874--- /dev/null+++ b/apps/web/src/components/content/mdx-components.tsx@@ -0,0 +1,29 @@+import * as React from "react";+import Link from "next/link";++export const components = {+ a: ({+ href = "",+ ...props+ }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {+ if (href.startsWith("http")) {+ return (+ <a+ className="text-foreground underline underline-offset-4 hover:no-underline"+ href={href}+ target="_blank"+ rel="noopener noreferrer"+ {...props}+ />+ );+ }++ return (+ <Link+ href={href}+ className="text-foreground underline underline-offset-4 hover:no-underline"+ {...props}+ />+ );+ },+};diff --git a/apps/web/src/components/Mdx.tsx b/apps/web/src/components/content/mdx.tsxsimilarity index 62%rename from apps/web/src/components/Mdx.tsxrename to apps/web/src/components/content/mdx.tsxindex 97b952e92..edb4eb960 100644--- a/apps/web/src/components/Mdx.tsx+++ b/apps/web/src/components/content/mdx.tsx@@ -10,8 +10,9 @@ export function Mdx({ code }: MdxProps) {const MDXComponent = getMDXComponent(code);return (- <main className="prose prose-quoteless prose-neutral dark:prose-invert mb-6 max-w-none">+ // FIXME: weird behaviour when `prose-headings:font-cal` and on mouse movement font gets bigger+ <div className="prose prose-neutral dark:prose-invert"><MDXComponent components={{ ...components }} />- </main>+ </div>);}diff --git a/apps/web/src/components/mdx-components.tsx b/apps/web/src/components/mdx-components.tsxdeleted file mode 100644index e53b16764..000000000--- a/apps/web/src/components/mdx-components.tsx+++ /dev/null@@ -1,33 +0,0 @@-import React from "react";-import Link from "next/link";--import { cn } from "@/lib/utils";--const LINK_STYLES =- "dark:dark:text-gray-100/90 underline dark:decoration-gray-200/30 decoration-blue-200/30 underline-offset-2 transition-all dark:hover:text-gray-100 dark:hover:decoration-gray-200/50";-const FOCUS_VISIBLE_OUTLINE =- "focus:outline-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-gray-500/70";--export const components = {- a: ({ href = "", ...props }) => {- if (href.startsWith("http")) {- return (- <a- className={cn(LINK_STYLES, FOCUS_VISIBLE_OUTLINE)}- href={href}- target="_blank"- rel="noopener noreferrer"- {...props}- />- );- }-- return (- <Link- href={href}- className={cn(LINK_STYLES, FOCUS_VISIBLE_OUTLINE)}- {...props}- />- );- },-};diff --git a/apps/web/src/content/posts/hello-world.mdx b/apps/web/src/content/posts/hello-world.mdxindex ccc893666..8b5bd4c0a 100644--- a/apps/web/src/content/posts/hello-world.mdx+++ b/apps/web/src/content/posts/hello-world.mdx@@ -2,13 +2,12 @@title: Understanding Hoisting and Promises in JavaScriptdescription:Understanding two important concepts in JavaScript - hoisting and promises.-author: Nikhil Mohite-authorLink: https://nikhilmohite.com+author:+ name: Nikhil Mohite+ url: https://nikhilmohite.compublishedAt: 2023-07-16----Understanding two important concepts in JavaScript: hoisting and promises.-## Understanding Hoisting and Promises in JavaScriptJavaScript is a versatile programming language that offers a wide range of@@ -88,3 +87,5 @@ variable and function declarations to be moved to the top of their scope,enabling early access to these entities. Promises, on the other hand, provide astructured and readable approach to managing asynchronous operations, enhancingcode maintainability and error handling.++[test link](https://openstatus.dev)diff --git a/apps/web/src/contentlayer/documents/post.ts b/apps/web/src/contentlayer/documents/post.tsnew file mode 100644index 000000000..026a1d019--- /dev/null+++ b/apps/web/src/contentlayer/documents/post.ts@@ -0,0 +1,46 @@+import {+ defineDocumentType,+ defineNestedType,+} from "contentlayer/source-files";+import readingTime from "reading-time";++const Author = defineNestedType(() => ({+ name: "Author",+ fields: {+ name: { type: "string", required: true },+ url: { type: "string" },+ avatar: { type: "string" },+ },+}));++export const Post = defineDocumentType(() => ({+ name: "Post",+ contentType: "mdx",+ filePathPattern: "posts/*.mdx",+ fields: {+ title: {+ type: "string",+ required: true,+ },+ description: {+ type: "string",+ required: true,+ },+ publishedAt: { type: "date", required: true },+ author: {+ type: "nested",+ of: Author,+ required: true,+ },+ },+ computedFields: {+ slug: {+ type: "string",+ resolve: (post) => post._raw.sourceFileName.replace(/\.mdx$/, ""),+ },+ readingTime: {+ type: "string",+ resolve: (post) => readingTime(post.body.raw).text,+ },+ },+}));diff --git a/apps/web/src/contentlayer/plugins/autolink-headings.ts b/apps/web/src/contentlayer/plugins/autolink-headings.tsnew file mode 100644index 000000000..1470d4fe5--- /dev/null+++ b/apps/web/src/contentlayer/plugins/autolink-headings.ts@@ -0,0 +1,16 @@+import rehypeAutolinkHeadings from "rehype-autolink-headings";+import type * as unified from "unified";++const autolinkHeadings: unified.Pluggable<any[]> = [+ rehypeAutolinkHeadings,+ {+ behavior: "append",+ properties: {+ className: [+ "no-underline after:content-['#'] after:text-muted-foreground ml-1 after:p-1",+ ],+ },+ },+];++export default autolinkHeadings;diff --git a/apps/web/src/contentlayer/plugins/pretty-code.ts b/apps/web/src/contentlayer/plugins/pretty-code.tsnew file mode 100644index 000000000..51fecd830--- /dev/null+++ b/apps/web/src/contentlayer/plugins/pretty-code.ts@@ -0,0 +1,27 @@+import rehypePrettyCode from "rehype-pretty-code";+import type * as unified from "unified";++const prettyCode: unified.Pluggable<any[]> = [+ rehypePrettyCode,+ {+ // prepacked themes+ // https://github.com/shikijs/shiki/blob/main/docs/themes.md+ theme: "one-dark-pro",++ // https://stackoverflow.com/questions/76549262/onvisithighlightedline-cannot-push-classname-using-rehype-pretty-code+ onVisitLine(node) {+ // Prevent lines from collapsing in `display: grid` mode, and+ // allow empty lines to be copy/pasted+ if (node.children.length === 0) {+ node.children = [{ type: "text", value: " " }];+ }+ node.properties.className = ["line"]; // add 'line' class to each line in the code block+ },++ onVisitHighlightedLine(node) {+ node.properties.className?.push("line--highlighted");+ },+ },+];++export default prettyCode;diff --git a/apps/web/src/lib/contentlayer/documents/Post.ts b/apps/web/src/lib/contentlayer/documents/Post.tsdeleted file mode 100644index 454f19eea..000000000--- a/apps/web/src/lib/contentlayer/documents/Post.ts+++ /dev/null@@ -1,58 +0,0 @@-import { defineDocumentType } from "contentlayer/source-files";-import readingTime from "reading-time";--export const Post = defineDocumentType(() => ({- name: "Post",- contentType: "mdx",- // Location of Blog source files (relative to `contentDirPath`)- filePathPattern: "posts/*.mdx",-- fields: {- title: {- type: "string",- required: true,- },- description: {- type: "string",- required: true,- },- publishedAt: { type: "string", required: true },- author: {- type: "string",- required: true,- },- authorLink: {- type: "string",- required: true,- },- },-- computedFields: {- // file name- slug: {- type: "string",- resolve: (post) =>- post._raw.sourceFileName- // hello-world.mdx => hello-world- .replace(/\.mdx$/, ""),- },- publishedAtFormatted: {- // 2023-03-21 to March 21, 2023- type: "string",- resolve: (post) => {- const dateObj = new Date(post.publishedAt);- // https://stackoverflow.com/questions/66590691/typescript-type-string-is-not-assignable-to-type-numeric-2-digit-in-d- const options = {- year: "numeric",- month: "long",- day: "numeric",- } as const;- return dateObj.toLocaleDateString("en-US", options);- },- },- readingTime: {- type: "string",- resolve: (post) => readingTime(post.body.raw).text,- },- },-}));diff --git a/apps/web/src/lib/contentlayer/rehype-pretty-code.ts b/apps/web/src/lib/contentlayer/rehype-pretty-code.tsdeleted file mode 100644index 1322209fe..000000000--- a/apps/web/src/lib/contentlayer/rehype-pretty-code.ts+++ /dev/null@@ -1,21 +0,0 @@-import type { Options } from "rehype-pretty-code";--export const rehypePrettyCodeOptions: Partial<Options> = {- // prepacked themes- // https://github.com/shikijs/shiki/blob/main/docs/themes.md- theme: "one-dark-pro",-- // https://stackoverflow.com/questions/76549262/onvisithighlightedline-cannot-push-classname-using-rehype-pretty-code- onVisitLine(node) {- // Prevent lines from collapsing in `display: grid` mode, and- // allow empty lines to be copy/pasted- if (node.children.length === 0) {- node.children = [{ type: "text", value: " " }];- }- node.properties.className = ["line"]; // add 'line' class to each line in the code block- },-- onVisitHighlightedLine(node) {- node.properties.className?.push("line--highlighted");- },-};diff --git a/apps/web/src/lib/contentlayer/utils.ts b/apps/web/src/lib/contentlayer/utils.tsdeleted file mode 100644index 93d1a1137..000000000--- a/apps/web/src/lib/contentlayer/utils.ts+++ /dev/null@@ -1,39 +0,0 @@-import type { Post } from "contentlayer/generated";--// return only what is needed for the index page-export const getDisplayPosts = (allPosts: Post[]) => {- return allPosts- .map((Post) => {- const {- title,- slug,- author,- authorLink,- publishedAt,- publishedAtFormatted,- readingTime,- description,- } = Post;-- return Object.fromEntries(- Object.entries({- title,- description,- author,- authorLink,- publishedAt,- publishedAtFormatted,- slug,- readingTime,- }),- );- })- .sort((a, b) => {- console.log(a.publishedAt);- console.log(a.publishedAtFormatted);- const date1 = new Date(a.publishedAt).getTime();- const date2 = new Date(b.publishedAt).getTime();-- return date2 - date1;- });-};diff --git a/apps/web/src/styles/globals.css b/apps/web/src/styles/globals.cssindex f43d9cfd7..57df35928 100644--- a/apps/web/src/styles/globals.css+++ b/apps/web/src/styles/globals.css@@ -1,5 +1,6 @@-@tailwind base;@import "@/styles/syntax-highlighting.css";++@tailwind base;@tailwind components;@tailwind utilities;@@ -77,29 +78,3 @@@apply bg-background text-foreground;}}--/* blog */-.prose h1 > a,-.prose h2 > a,-.prose h3 > a {- @apply hover:before:text-muted-foreground no-underline before:-ml-[0.9em] before:mr-2 before:text-rose-100/0 before:content-['#'];-}--.prose pre {- margin: 0;- padding: 0;-}--.prose h2 {- word-wrap: break-all;-}--.prose p > code {- word-wrap: break-all;- @apply whitespace-nowrap rounded-full border border-rose-200/10 px-1.5 py-px text-red-400/90 dark:bg-white/5 dark:text-rose-300/90;-}--pre {- -ms-overflow-style: none; /* IE and Edge */- scrollbar-width: none; /* Firefox */-}diff --git a/apps/web/src/styles/syntax-highlighting.css b/apps/web/src/styles/syntax-highlighting.cssindex df4ea4277..bb66edd05 100644--- a/apps/web/src/styles/syntax-highlighting.css+++ b/apps/web/src/styles/syntax-highlighting.css@@ -3,11 +3,16 @@ pre > code {display: grid;}+.prose pre {+ margin: 0;+ padding: 0;+}+div[data-rehype-pretty-code-fragment] {overflow: hidden;/* stylist preferences */- background-color: rgba(57, 57, 57, 0.102);+ background-color: var(--muted-foreground);border-radius: 0.5rem;width: 100%;margin: 1rem 0;@@ -36,8 +41,6 @@ div[data-rehype-pretty-code-title] {"Liberation Mono", "Courier New", monospace;font-size: 0.75rem;line-height: 1rem;-- @apply dark:bg-[#ffe4e61a] dark:text-[#ccccccb3];}div[data-rehype-pretty-code-fragment] .line {@@ -50,7 +53,7 @@ div[data-rehype-pretty-code-fragment] .line {}div[data-rehype-pretty-code-fragment] .line--highlighted {- border-left-color: rgba(135, 127, 128, 0.7);+ border-left-color: var(--border);background-color: rgb(254 205 211 / 0.1);}@@ -68,6 +71,4 @@ code[data-line-numbers] .line::before {/* stylistic preferences */margin-right: 0.75rem;width: 1rem;-- @apply dark:text-[#e8e8e8b3];}diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.jsonindex 996dc6dc5..3fdd92f60 100644--- a/apps/web/tsconfig.json+++ b/apps/web/tsconfig.json@@ -3,8 +3,8 @@"compilerOptions": {"baseUrl": ".","paths": {- "@/*": ["./src/*"],- "contentlayer/generated": ["./.contentlayer/generated"]+ "contentlayer/generated": ["./.contentlayer/generated"],+ "@/*": ["./src/*"]},"plugins": [{ "name": "next" }],"strictNullChecks": truediff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3cd2160ca..0a86737d7 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -243,6 +243,9 @@ importers:typescript:specifier: 5.1.3version: 5.1.3+ unified:+ specifier: ^10.1.2+ version: 10.1.2packages/api:dependencies: