-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
9,126 additions
and
12,625 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { | ||
SimpleLayout, | ||
DocsLayout, | ||
UnstyledLayout, | ||
BlogLayout, | ||
} from "@portaljs/core"; | ||
|
||
export default { | ||
simple: SimpleLayout, | ||
docs: DocsLayout, | ||
unstyled: UnstyledLayout, | ||
blog: BlogLayout, | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import fs from "fs"; | ||
import React from "react"; | ||
import { GetStaticProps, GetStaticPropsResult } from "next"; | ||
|
||
import { BlogsList, SimpleLayout } from "@portaljs/core"; | ||
import clientPromise from "../../lib/mddb.mjs"; | ||
import computeFields from "../../lib/computeFields"; | ||
import type { CustomAppProps } from "../_app"; | ||
|
||
interface BlogIndexPageProps extends CustomAppProps { | ||
blogs: any[]; // TODO types | ||
} | ||
|
||
export default function Blog({ | ||
blogs, | ||
meta: { title, description }, | ||
}: BlogIndexPageProps) { | ||
return ( | ||
<SimpleLayout title={title} description={description}> | ||
<BlogsList blogs={blogs} /> | ||
</SimpleLayout> | ||
); | ||
} | ||
|
||
export const getStaticProps: GetStaticProps = async (): Promise< | ||
GetStaticPropsResult<BlogIndexPageProps> | ||
> => { | ||
const mddb = await clientPromise; | ||
const blogFiles = await mddb.getFiles({ folder: "blog" }); | ||
const blogsMetadataPromises = blogFiles.map(async (b) => { | ||
const source = fs.readFileSync(b.file_path, { encoding: "utf-8" }); | ||
|
||
// TODO temporary replacement for contentlayer's computedFields | ||
const frontMatterWithComputedFields = await computeFields({ | ||
frontMatter: b.metadata, | ||
urlPath: b.url_path, | ||
filePath: b.file_path, | ||
source, | ||
}); | ||
|
||
return frontMatterWithComputedFields; | ||
}); | ||
|
||
const blogsList = await Promise.all(blogsMetadataPromises); | ||
|
||
return { | ||
props: { | ||
meta: { | ||
title: "Blog posts", | ||
showSidebar: false, | ||
showToc: false, | ||
showComments: false, | ||
showEditLink: false, | ||
urlPath: "/blog", | ||
}, | ||
blogs: blogsList, | ||
}, | ||
}; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.