Skip to content

Instantly share code, notes, and snippets.

@MakStashkevich
Created January 3, 2023 10:39
Show Gist options
  • Select an option

  • Save MakStashkevich/23e8059f3b018a3c6e8e811b1a2d59b9 to your computer and use it in GitHub Desktop.

Select an option

Save MakStashkevich/23e8059f3b018a3c6e8e811b1a2d59b9 to your computer and use it in GitHub Desktop.

Revisions

  1. MakStashkevich created this gist Jan 3, 2023.
    7 changes: 7 additions & 0 deletions __root_folder.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    ```
    app/
    - head.tsx
    - layout.tsx
    - page.tsx
    - blog/[slug]/page.tsx
    ```
    5 changes: 5 additions & 0 deletions app_head.tsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    import React from 'react';

    export default function RootHead() {
    return undefined; // Disable root head
    }
    13 changes: 13 additions & 0 deletions app_layout.tsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    import React from "react";

    import '../styles/globals.scss';

    export default function RootLayout({children}: { children: React.ReactNode }) {
    return (
    <html>
    <body>
    {children}
    </body>
    </html>
    )
    }
    14 changes: 14 additions & 0 deletions app_page.tsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import React from "react";

    export default function RootPage() {
    return (
    <div>
    // Set title & description without <Head/> components
    <title>Home</title>
    <meta name="description" content="My homepage"/>

    // Set page code
    <p>Other staff...</p>
    </div>
    )
    }
    19 changes: 19 additions & 0 deletions blog_slug_page.tsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import React from "react";

    async function getBlogData() {
    return {title: "About me", description: "Read about me", content: "..."}; // Your blog content
    }

    export default async function BlogPage() {
    const {title, description, content} = await getBlogData();
    return (
    <div>
    // Set title & description without <Head/> components
    <title>{title}</title>
    <meta name="description" content={description}/>

    // Set page content
    <p>{content}</p>
    </div>
    )
    }