Skip to content

WIP 0.0.28 #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 30 commits into from
Nov 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
30ed02a
WIP
schickling Nov 1, 2021
7c85a01
WIP
schickling Nov 1, 2021
e5d75a1
WIP
schickling Nov 1, 2021
2ff930b
changeset
schickling Nov 1, 2021
25d4f06
remove changelog
schickling Nov 1, 2021
6db0798
re-enabled shiki for gatsby example
schickling Nov 2, 2021
9bf06c7
pass contentDirPath to mdx processing
schickling Nov 2, 2021
740768a
improved CLI error handling
schickling Nov 3, 2021
eb8ab95
improved error handling
schickling Nov 3, 2021
7193a37
Make effect peerDependency (fix #6)
schickling Nov 3, 2021
e5545bf
fix windows
schickling Nov 3, 2021
71b82ee
added windows to CI/CD
schickling Nov 4, 2021
dd9cfba
added windows to CI/CD
schickling Nov 4, 2021
13e7279
added windows to CI/CD
schickling Nov 4, 2021
0da3caa
improve CI
schickling Nov 4, 2021
ea35c3c
improve CI
schickling Nov 4, 2021
802f203
improve CI
schickling Nov 4, 2021
a2b455c
improve CI
schickling Nov 4, 2021
312c13e
improve CI
schickling Nov 4, 2021
80493d8
improve CI
schickling Nov 4, 2021
ff7e9be
cleanup based command
schickling Nov 4, 2021
34be7d4
Added timezone support for `type: 'date'` values. Closing #9.
schickling Nov 4, 2021
7460bbe
move infra files
schickling Nov 4, 2021
4df64d0
new dev version
schickling Nov 4, 2021
cfd9662
save read cache
schickling Nov 6, 2021
0f355b7
Merge branch 'main' of github.com:schickling/contentlayer into change…
schickling Nov 6, 2021
e38fa74
new version + small improvements
schickling Nov 6, 2021
f4d9576
readme
schickling Nov 8, 2021
b0d2015
0.0.28
schickling Nov 8, 2021
b543361
update snapshots
schickling Nov 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [["@contentlayer/*", "contentlayer", "next-contentlayer"]],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": ["examples-*"]
}
63 changes: 11 additions & 52 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,29 @@ jobs:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install
- uses: schickling-actions/checkout-and-install@main
- run: yarn lint:check

test:
strategy:
matrix:
node-version: [16.x]
# Note tests are currently not run in Windows because the path seperator on Windows invalidates the test results 🙈
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install
- uses: schickling-actions/checkout-and-install@main
- run: yarn build
- run: yarn test

build-example-starter:
strategy:
matrix:
node-version: [16.x]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install
- uses: schickling-actions/checkout-and-install@main
- run: yarn build
- run: yarn build
working-directory: examples/starter
Expand All @@ -63,17 +43,10 @@ jobs:
strategy:
matrix:
node-version: [16.x]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install
- uses: schickling-actions/checkout-and-install@main
- run: yarn build
- run: yarn build
working-directory: examples/playground-azimuth
Expand All @@ -82,17 +55,10 @@ jobs:
strategy:
matrix:
node-version: [16.x]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install
- uses: schickling-actions/checkout-and-install@main
- run: yarn build
- run: yarn build
working-directory: examples/gatsby-docs
Expand All @@ -101,17 +67,10 @@ jobs:
strategy:
matrix:
node-version: [16.x]
os: [ubuntu-latest]
os: [ubuntu-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: yarn install
- uses: schickling-actions/checkout-and-install@main
- run: yarn build
- run: yarn build
working-directory: examples/mdx
File renamed without changes.
File renamed without changes.
26 changes: 12 additions & 14 deletions examples/gatsby-docs/contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// import rehypeShiki from '@leafac/rehype-shiki'
// import { createRequire } from 'module'
import rehypeShiki from '@stefanprobst/rehype-shiki'

import { createRequire } from 'module'
import { defineDocumentType, makeSource, defineNestedType, FieldDef } from 'contentlayer/source-files'
// import * as path from 'path'
// import * as shiki from 'shiki'
import * as path from 'path'
import * as shiki from 'shiki'

const Example = defineNestedType(() => ({
name: 'Example',
Expand Down Expand Up @@ -55,22 +56,19 @@ const Tutorial = defineDocumentType(() => ({
}))

export default makeSource(async () => {
// TODO re-enable once this is fixed https://github.com/leafac/rehype-shiki/issues/2

// const require = createRequire(import.meta.url)
// const shikiPath = (dir: string) => path.join(require.resolve('shiki'), '..', '..', dir, path.sep)
// const highlighter = await shiki.getHighlighter({
// paths: { languages: shikiPath('languages'), themes: shikiPath('themes') },
// theme: 'github-light',
// })
const require = createRequire(import.meta.url)
const shikiPkgPath = (dir: string) => path.join(require.resolve('shiki'), '..', '..', dir, path.sep)
const highlighter = await shiki.getHighlighter({
paths: { languages: shikiPkgPath('languages'), themes: shikiPkgPath('themes') },
theme: 'github-light',
})

return {
contentDirPath: 'gatsby/docs',
// contentDirPath: path.join(process.cwd(), 'gatsby', 'docs'),
documentTypes: [Reference, HowTo, Conceptual, Tutorial],
onUnknownDocuments: 'skip-ignore',
markdown: {
// rehypePlugins: [[rehypeShiki as any, { highlighter }]],
rehypePlugins: [[rehypeShiki, { highlighter }]],
},
}
})
2 changes: 1 addition & 1 deletion examples/gatsby-docs/gatsby
Submodule gatsby updated 849 files
7 changes: 4 additions & 3 deletions examples/gatsby-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
"start": "next start"
},
"dependencies": {
"next": "^11.1.2",
"next": "^12.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@leafac/rehype-shiki": "^1.3.1",
"@stefanprobst/rehype-shiki": "^2.0.4",
"@types/react": "^17.0.21",
"@types/react-dom": "^17.0.9",
"contentlayer": "workspace:*",
"eslint-config-next": "^11.0.1",
"next-contentlayer": "workspace:*",
"shiki": "^0.9.4",
"typescript": "^4.4.3"
"typescript": "^4.4.4"
}
}
}
6 changes: 6 additions & 0 deletions examples/mdx/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Usage

```sh
curl https://codeload.github.com/contentlayerdev/contentlayer/tar.gz/main | \
tar -xz --strip=2 contentlayer-main/examples/mdx
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions examples/mdx/contentlayer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ const Doc = defineDocumentType(() => ({
filePathPattern: '**/*.mdx',
bodyType: 'mdx',
fields: {
title: { type: 'string' },
title: { type: 'string', required: true },
},
}))

const contentLayerConfig = makeSource({
contentDirPath: 'docs',
export default makeSource({
contentDirPath: 'content',
documentTypes: [Doc],
})

export default contentLayerConfig
5 changes: 2 additions & 3 deletions examples/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
},
"dependencies": {
"contentlayer": "latest",
"mdx-bundler": "^6.0.2",
"next": "11.1.2",
"next": "12.0.2",
"next-contentlayer": "latest",
"react": "17.0.2",
"react-dom": "17.0.2"
},
"devDependencies": {
"@types/react": "17.0.20",
"typescript": "4.4.3"
"typescript": "4.4.4"
}
}
17 changes: 11 additions & 6 deletions examples/mdx/pages/[[...slug]].tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { GetStaticPaths, InferGetStaticPropsType } from 'next'
import { getMDXComponent } from 'mdx-bundler/client'
import { useMDXComponent } from 'next-contentlayer/hooks'

import { allDocs } from '.contentlayer/data'
import { useMemo } from 'react'
import { Button } from '../components/Button'
import { Doc } from '.contentlayer/types'

const mdxComponents = {
Button,
}

const DocPage: React.FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ doc, navInfo }) => {
const MDXContent = useMemo(() => getMDXComponent(doc.body.code), [doc.body.code])
const DocPage: React.FC<StaticProps> = ({ doc, navInfo }) => {
const MDXContent = useMDXComponent(doc.body.code)

return (
<div>
Expand All @@ -29,9 +29,14 @@ const DocPage: React.FC<InferGetStaticPropsType<typeof getStaticProps>> = ({ doc

export default DocPage

export const getStaticProps = ({ params: { slug = [] } }) => {
type StaticProps = {
doc: Doc
navInfo: { title: string; path: string }[]
}

export const getStaticProps = ({ params: { slug = [] } }): { props: StaticProps } => {
const pagePath = slug.join('/')
const doc = allDocs.find((doc) => doc._raw.flattenedPath === pagePath)
const doc = allDocs.find((doc) => doc._raw.flattenedPath === pagePath)!

const navInfo = allDocs.map((_) => ({ title: _.title, path: `/${_._raw.flattenedPath}` }))

Expand Down
5 changes: 3 additions & 2 deletions examples/mdx/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve"
"jsx": "preserve",
"incremental": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
Expand Down
4 changes: 2 additions & 2 deletions examples/playground-azimuth-colocated/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"date-fns": "^2.24.0",
"marked": "^3.0.4",
"next": "^11.1.2",
"next": "^12.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
Expand All @@ -24,6 +24,6 @@
"contentlayer": "workspace:*",
"contentlayer-stackbit-yaml-generator": "workspace:*",
"next-contentlayer": "workspace:*",
"typescript": "^4.4.3"
"typescript": "^4.4.4"
}
}
4 changes: 2 additions & 2 deletions examples/playground-azimuth-contentful/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"date-fns": "^2.24.0",
"marked": "^3.0.4",
"next": "^11.1.2",
"next": "^12.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
Expand All @@ -25,6 +25,6 @@
"contentlayer": "workspace:*",
"contentlayer-stackbit-yaml-generator": "workspace:*",
"next-contentlayer": "workspace:*",
"typescript": "^4.4.3"
"typescript": "^4.4.4"
}
}
1 change: 1 addition & 0 deletions examples/playground-azimuth-sanity/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "example-azimuth-sanity-monorepo",
"private": true,
"workspaces": [
"./web",
Expand Down
4 changes: 2 additions & 2 deletions examples/playground-azimuth-sanity/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"contentlayer": "workspace:*",
"date-fns": "^2.24.0",
"marked": "^3.0.4",
"next": "^11.1.2",
"next": "^12.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
Expand All @@ -24,6 +24,6 @@
"@types/react": "^17.0.21",
"@types/react-dom": "^17.0.9",
"@types/react-helmet": "^6.1.2",
"typescript": "^4.4.3"
"typescript": "^4.4.4"
}
}
4 changes: 2 additions & 2 deletions examples/playground-azimuth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"date-fns": "^2.24.0",
"marked": "^3.0.4",
"next": "^11.1.2",
"next": "^12.0.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
Expand All @@ -24,6 +24,6 @@
"contentlayer": "workspace:*",
"contentlayer-stackbit-yaml-generator": "workspace:*",
"next-contentlayer": "workspace:*",
"typescript": "^4.4.3"
"typescript": "^4.4.4"
}
}
4 changes: 2 additions & 2 deletions examples/playground-contentful-starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"date-fns": "^2.24.0",
"next": "^11.1.2",
"next": "^12.0.2",
"react": "17.0.2",
"react-dom": "17.0.2"
},
Expand All @@ -19,6 +19,6 @@
"contentlayer": "latest",
"next-contentlayer": "latest",
"rehype-highlight": "^5.0.0",
"typescript": "^4.4.3"
"typescript": "^4.4.4"
}
}
Loading