Skip to content

Commit

Permalink
new post assets structure
Browse files Browse the repository at this point in the history
  • Loading branch information
tarcisioandrade committed Sep 27, 2023
1 parent 14be99e commit 92ff4ec
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 43 deletions.
76 changes: 40 additions & 36 deletions contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,49 +1,18 @@
import { slugger } from "./src/utils/slugger";
import { defineDocumentType, makeSource } from "contentlayer/source-files";
import readingTime from "reading-time";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypeSlug from "rehype-slug";
import rehypeVideo from "rehype-video";
import remarkGfm from "remark-gfm";
import { slugger } from "./src/utils/slugger";

export const Post = defineDocumentType(() => ({
name: "Post",
filePathPattern: `**/**/*.{md,mdx}`,
contentType: "mdx",
fields: {
title: { type: "string", required: true },
description: {
type: "string",
required: true,
},
publishedAt: {
type: "date",
required: true,
},
updatedAt: {
type: "date",
},
categories: {
type: "list",
of: { type: "string" },
required: true,
},
isPublished: {
type: "boolean",
default: true,
},
},
computedFields: {
url: {
type: "string",
resolve: (post) => `/${post._raw.flattenedPath}`,
},
readingTime: {
type: "json",
resolve: (doc) => readingTime(doc.body.raw),
type: "json",
},
toc: {
type: "json",
resolve: async (doc) => {
const regulrExp = /\n(?<flag>#{1,6})\s+(?<content>.+)/g;

Expand All @@ -55,27 +24,62 @@ export const Post = defineDocumentType(() => ({
return {
level:
flag?.length == 1 ? "one" : flag?.length == 2 ? "two" : "three",
text: content,
slug: content ? slugger(content) : undefined,
text: content,
};
}
},
);

return headings;
},
type: "json",
},
url: {
resolve: (post) => `/${post._raw.flattenedPath}`,
type: "string",
},
},
contentType: "mdx",
fields: {
categories: {
of: { type: "string" },
required: true,
type: "list",
},
description: {
required: true,
type: "string",
},
image: {
required: true,
type: "image",
},
isPublished: {
default: true,
type: "boolean",
},
publishedAt: {
required: true,
type: "date",
},
title: { required: true, type: "string" },
updatedAt: {
type: "date",
},
},
filePathPattern: `**/**/*.{md,mdx}`,
name: "Post",
}));

export default makeSource({
contentDirPath: "posts",
documentTypes: [Post],
mdx: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
rehypeSlug,
[rehypeVideo, { details: false }],
[rehypeAutolinkHeadings, { behavior: "append" }],
],
remarkPlugins: [remarkGfm],
},
});
5 changes: 3 additions & 2 deletions posts/masterpice-css/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: The masterpice css tricks and utilities
publishedAt: 2023-07-01
image: ../../public/post-assets/masterpice-css/op-image.jpg
description: "This year, the React team unveiled something they've been quietly researching for years: an official way to run React components exclusively on the server."
categories:
- CSS
Expand Down Expand Up @@ -42,7 +43,7 @@ To put React Server Components in context, it's helpful to understand how Server
When I first started using React in 2015, most React setups used a “client-side” rendering strategy. The user would receive an HTML file that looked like this:

```html
<!DOCTYPE html>
<!doctype html>
<html>
<body>
<div id="root"></div>
Expand Down Expand Up @@ -80,7 +81,7 @@ let hello = "hello brightness";
console.log(hello, "my old friend");
```

![Image](https://res.cloudinary.com/drdzrfm15/image/upload/w_1000/q_auto/f_auto/v1694920648/andradev/server-components/wallhaven-m9j1pk_t0o7wm.jpg)
<Image src="/post-assets/masterpice-css/op-image.jpg" alt="Image Top" />

# Bouncing back and forth

Expand Down
7 changes: 4 additions & 3 deletions posts/server-components/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: Making Sense of React Server Components
publishedAt: 2023-07-01
image: ../../public/post-assets/masterpice-css/op-image.jpg
description: "This year, the React team unveiled something they've been quietly researching for years: an official way to run React components exclusively on the server. This is a significant paradigm shift, and it's caused a whole lot of confusion in the React community. In this tutorial, we'll explore this new world, and build an intuition for how it works, and how we can take advantage of it."
categories:
- nextjs
Expand Down Expand Up @@ -42,7 +43,7 @@ To put React Server Components in context, it's helpful to understand how Server
When I first started using React in 2015, most React setups used a “client-side” rendering strategy. The user would receive an HTML file that looked like this:

```html
<!DOCTYPE html>
<!doctype html>
<html>
<body>
<div id="root"></div>
Expand Down Expand Up @@ -78,7 +79,7 @@ let hello = "hello brightness";
console.log(hello, "my old friend");
```

![Image](https://res.cloudinary.com/drdzrfm15/image/upload/w_1000/q_auto/f_auto/v1694920648/andradev/server-components/wallhaven-m9j1pk_t0o7wm.jpg)
<Image src="/post-assets/masterpice-css/op-image.jpg" alt="Image Top" />

# Bouncing back and forth

Expand Down Expand Up @@ -118,7 +119,7 @@ This course has been my full-time focus for almost two years now, and it include

There's so much good stuff I'd love to tell you about. In addition to React itself, and all the bleeding-edge stuff we've alluded to in this blog post, you'll learn about my favourite parts of the React ecosystem. For example, you'll learn how to do next-level layout animations like this, using Framer ==Motion==:

https://res.cloudinary.com/drdzrfm15/video/upload/v1695135961/andradev/server-components/ubereats-loading_rw4xdz.mp4
<Video src="/post-assets/server-components/ubereats-loading.mp4" />

<iframe
src="https://codesandbox.io/embed/sandpack-project-yw1065?fontsize=14&hidenavigation=1&theme=dark"
Expand Down
1 change: 0 additions & 1 deletion public/next.svg

This file was deleted.

Binary file added public/op-default-img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file not shown.
1 change: 0 additions & 1 deletion public/vercel.svg

This file was deleted.

0 comments on commit 92ff4ec

Please sign in to comment.