Skip to content

Commit 4b940f2

Browse files
authored
Merge pull request #147 from code-hike/monopackage
Monopackage refactor
2 parents 4d4298e + 13d428f commit 4b940f2

File tree

223 files changed

+12201
-13038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+12201
-13038
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ jobs:
99
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
1010
steps:
1111
- uses: actions/checkout@v2
12-
with:
13-
fetch-depth: 10 # 👈 Required to retrieve git history
1412

1513
- name: Prepare repository
1614
run: git fetch --unshallow --tags
@@ -35,6 +33,7 @@ jobs:
3533
run: |
3634
yarn install --frozen-lockfile 2>&1 | grep -v '^[warning|info]'
3735
yarn build
36+
yarn test
3837
yarn release
3938
# - name: Publish to Chromatic
4039
# uses: chromaui/action@v1

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ yarn-error.log
99
.vscode
1010
storybook-static
1111
packages/playground/out
12-
packages/starter
12+
packages/starter
13+
14+
# Contentlayer
15+
.contentlayer

.gitpod.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# and commit this file to your remote git repository to share the goodness with others.
44

55
tasks:
6-
- init: yarn install && yarn run build
7-
command: yarn run playground
6+
- init: yarn install
87

98

examples/.prettierrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"semi": false
3+
}

examples/contentlayer/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.next
3+
.contentlayer
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { defineDocumentType, makeSource } from "contentlayer/source-files"
2+
import { remarkCodeHike } from "@code-hike/mdx"
3+
import { createRequire } from "module"
4+
const require = createRequire(import.meta.url)
5+
const theme = require("shiki/themes/nord.json")
6+
7+
export const Post = defineDocumentType(() => ({
8+
name: "Post",
9+
contentType: "mdx",
10+
filePathPattern: "**/*.mdx",
11+
fields: {
12+
title: {
13+
type: "string",
14+
description: "The title of the post",
15+
required: true,
16+
},
17+
},
18+
}))
19+
20+
export default makeSource({
21+
contentDirPath: "posts",
22+
documentTypes: [Post],
23+
mdx: { remarkPlugins: [[remarkCodeHike, { theme }]] },
24+
})

examples/contentlayer/jsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": ".",
4+
"paths": {
5+
"contentlayer/generated": ["./.contentlayer/generated"]
6+
}
7+
}
8+
}

examples/contentlayer/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const { withContentlayer } = require('next-contentlayer')
2+
3+
module.exports = withContentlayer()({})

examples/contentlayer/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "codehike-contentlayer",
3+
"private": true,
4+
"version": "0.0.0",
5+
"dependencies": {
6+
"@code-hike/mdx": "^0.3.0",
7+
"next": "^12.0.10",
8+
"react": "17.0.2",
9+
"react-dom": "17.0.2"
10+
},
11+
"devDependencies": {
12+
"contentlayer": "^0.1.1",
13+
"next-contentlayer": "^0.1.1"
14+
}
15+
}

examples/contentlayer/pages/[slug].js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { allPosts } from "contentlayer/generated"
2+
import { useMDXComponent } from "next-contentlayer/hooks"
3+
4+
export async function getStaticPaths() {
5+
const paths = allPosts.map((_) => "/" + _._raw.flattenedPath)
6+
return {
7+
paths,
8+
fallback: false,
9+
}
10+
}
11+
12+
export async function getStaticProps({ params }) {
13+
const post = allPosts.find((_) => _._raw.flattenedPath === params.slug)
14+
return {
15+
props: {
16+
post,
17+
},
18+
}
19+
}
20+
21+
const Page = ({ post }) => {
22+
const Component = useMDXComponent(post.body.code)
23+
return (
24+
<article style={{ maxWidth: 800 }}>
25+
<h1>{post.title}</h1>
26+
<Component />
27+
</article>
28+
)
29+
}
30+
31+
export default Page

0 commit comments

Comments
 (0)