Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ out
!tap-snapshots/dist/*

.contentlayer
.DS_Store
17 changes: 8 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
"examples/gatsby-docs/gatsby": true
},
"files.exclude": {
"**/.direnv": true,
"**/.DS_Store": true,
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/.svn": true,
"**/.yarn": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/dist": true,
"**/vercel.json": true,
"**/.yarn": true,
"**/.direnv": true
"**/vercel.json": true
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": false,
"source.fixAll": true,
"source.addMissingImports": true
"source.organizeImports": "never",
"source.fixAll": "explicit",
"source.addMissingImports": "explicit"
},
"typescript.enablePromptUseWorkspaceTsdk": true,
"prettier.singleQuote": true,
Expand Down
25 changes: 10 additions & 15 deletions examples/next-images/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,30 @@
import Link from "next/link";
import { compareDesc, format, parseISO } from "date-fns";
import { allPosts, Post } from "contentlayer/generated";
import { getMDXComponent } from "next-contentlayer/hooks";
import Link from 'next/link'
import { compareDesc, format, parseISO } from 'date-fns'
import { allPosts, Post } from 'contentlayer/generated'
import { getMDXComponent } from 'next-contentlayer2/hooks'

function PostCard(post: Post) {
const Content = getMDXComponent(post.body.code);
const Content = getMDXComponent(post.body.code)

return (
<div className="mb-8">
<h2 className="text-xl">
<Link
href={post.url}
className="text-blue-700 hover:text-blue-900"
legacyBehavior>
<Link href={post.url} className="text-blue-700 hover:text-blue-900" legacyBehavior>
{post.title}
</Link>
</h2>
<time dateTime={post.date} className="block mb-2 text-xs text-gray-600">
{format(parseISO(post.date), "LLLL d, yyyy")}
{format(parseISO(post.date), 'LLLL d, yyyy')}
</time>
<div className="text-sm">
<Content />
</div>
</div>
);
)
}

export default function Home() {
const posts = allPosts.sort((a, b) =>
compareDesc(new Date(a.date), new Date(b.date))
);
const posts = allPosts.sort((a, b) => compareDesc(new Date(a.date), new Date(b.date)))

return (
<div className="max-w-xl py-8 mx-auto">
Expand All @@ -39,5 +34,5 @@ export default function Home() {
<PostCard key={idx} {...post} />
))}
</div>
);
)
}
2 changes: 1 addition & 1 deletion examples/next-images/app/posts/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { format, parseISO } from 'date-fns'
import { allPosts } from 'contentlayer/generated'
import { getMDXComponent } from 'next-contentlayer/hooks'
import { getMDXComponent } from 'next-contentlayer2/hooks'
import Image from 'next/image'

export const generateStaticParams = async () => allPosts.map((post) => ({ slug: post._raw.flattenedPath }))
Expand Down
2 changes: 1 addition & 1 deletion examples/next-images/contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'

const Post = defineDocumentType(() => ({
name: 'Post',
Expand Down
2 changes: 1 addition & 1 deletion examples/next-images/next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { withContentlayer } = require("next-contentlayer");
const { withContentlayer } = require("next-contentlayer2");

/** @type {import('next').NextConfig} */
const nextConfig = {}
Expand Down
4 changes: 2 additions & 2 deletions examples/next-images/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"start": "next start"
},
"dependencies": {
"contentlayer": "latest",
"contentlayer2": "latest",
"date-fns": "2.30.0",
"next": "14.1.0",
"next-contentlayer": "latest",
"next-contentlayer2": "latest",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
4 changes: 2 additions & 2 deletions examples/next-rsc-dynamic/contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineDocumentType } from 'contentlayer/source-files'
import { defineDocumentType } from 'contentlayer2/source-files'
import { spawn } from 'node:child_process'
import { makeSource } from 'contentlayer/source-remote-files'
import { makeSource } from 'contentlayer2/source-remote-files'

const Post = defineDocumentType(() => ({
name: 'Post',
Expand Down
2 changes: 1 addition & 1 deletion examples/next-rsc-dynamic/next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const { withContentlayer } = require('next-contentlayer')
const { withContentlayer } = require('next-contentlayer2')

module.exports = withContentlayer({})
4 changes: 2 additions & 2 deletions examples/next-rsc-dynamic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"start": "next start"
},
"dependencies": {
"contentlayer": "latest",
"contentlayer2": "latest",
"date-fns": "2.30.0",
"next": "14.1.0",
"next-contentlayer": "latest",
"next-contentlayer2": "latest",
"react": "18.2.0",
"react-dom": "18.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion examples/node-script-mdx/contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'
import { bundleMDX } from 'mdx-bundler'
import * as ReactDOMServer from 'react-dom/server'
import { getMDXComponent } from 'mdx-bundler/client/index.js'
Expand Down
4 changes: 2 additions & 2 deletions examples/node-script-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "node-script-mdx-example",
"private": true,
"scripts": {
"start": "contentlayer build && node --experimental-json-modules my-script.mjs"
"start": "contentlayer2 build && node --experimental-json-modules my-script.mjs"
},
"dependencies": {
"contentlayer": "latest"
"contentlayer2": "latest"
}
}
4 changes: 2 additions & 2 deletions examples/node-script-remote-content/contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineDocumentType } from 'contentlayer/source-files'
import { defineDocumentType } from 'contentlayer2/source-files'
import { spawn } from 'node:child_process'
import { makeSource } from 'contentlayer/source-remote-files'
import { makeSource } from 'contentlayer2/source-remote-files'

const Post = defineDocumentType(() => ({
name: 'Post',
Expand Down
4 changes: 2 additions & 2 deletions examples/node-script-remote-content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "node-script-remote-content-example",
"private": true,
"scripts": {
"start": "contentlayer build && node --experimental-json-modules my-script.mjs"
"start": "contentlayer2 build && node --experimental-json-modules my-script.mjs"
},
"dependencies": {
"contentlayer": "latest"
"contentlayer2": "latest"
}
}
2 changes: 1 addition & 1 deletion examples/node-script/contentlayer.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineDocumentType, makeSource } from 'contentlayer/source-files'
import { defineDocumentType, makeSource } from 'contentlayer2/source-files'

const Post = defineDocumentType(() => ({
name: 'Post',
Expand Down
4 changes: 2 additions & 2 deletions examples/node-script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "node-script-example",
"private": true,
"scripts": {
"start": "contentlayer build && node --experimental-json-modules my-script.mjs"
"start": "contentlayer2 build && node --experimental-json-modules my-script.mjs"
},
"dependencies": {
"contentlayer": "latest"
"contentlayer2": "latest"
}
}
16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "contentlayer-monorepo",
"name": "contentlayer2-monorepo",
"private": true,
"workspaces": [
"./packages/@contentlayer/*",
Expand All @@ -10,11 +10,11 @@
"postinstall": "ts-patch install",
"prepare": "ts-patch install -s",
"test": "CI=true VITEST_SEGFAULT_RETRY=3 yarn workspaces foreach --parallel run test",
"build": "run build:clean && run build:ts && yarn workspace next-contentlayer run prepack",
"build": "run build:clean && run build:ts && yarn workspace next-contentlayer2 run prepack",
"build:ts": "tsc --build tsconfig.all.json",
"dev:ts": "run build:ts --watch",
"build:clean": "bash -c 'rm -rf packages/*/dist packages/@contentlayer/*/dist'",
"examples:postinstall": "yarn workspaces foreach --verbose --include \"examples-*\" exec yarn contentlayer postinstall",
"examples:postinstall": "yarn workspaces foreach --verbose --include \"examples-*\" exec yarn contentlayer2 postinstall",
"release:prerelease": "yarn build && yarn workspaces foreach --verbose --topological-dev --parallel --no-private npm publish --tolerate-republish --tag=dev",
"release:patch": "yarn build && yarn workspaces foreach --verbose --topological-dev --parallel --no-private npm publish --tolerate-republish",
"release:minor": "yarn build && yarn workspaces foreach --verbose --topological-dev --parallel --no-private npm publish --tolerate-republish",
Expand Down Expand Up @@ -42,11 +42,11 @@
},
"resolutions": {
"esbuild": "0.18.0",
"contentlayer": "workspace:*",
"@contentlayer/*": "workspace:*",
"contentlayer-stackbit-yaml-generator": "workspace:*",
"next-contentlayer": "workspace:*",
"contentlayer2": "workspace:*",
"@contentlayer2/*": "workspace:*",
"contentlayer-stackbit-yaml-generator2": "workspace:*",
"next-contentlayer2": "workspace:*",
"rxjs": "^7.1.0"
},
"packageManager": "yarn@3.2.3"
}
}
8 changes: 4 additions & 4 deletions packages/@contentlayer/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/cli",
"version": "0.3.4",
"name": "@contentlayer2/cli",
"version": "0.4.1",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand All @@ -13,8 +13,8 @@
"test": "echo No tests yet"
},
"dependencies": {
"@contentlayer/core": "workspace:*",
"@contentlayer/utils": "workspace:*",
"@contentlayer2/core": "workspace:*",
"@contentlayer2/utils": "workspace:*",
"clipanion": "^3.2.1",
"typanion": "^3.12.1"
},
Expand Down
6 changes: 3 additions & 3 deletions packages/@contentlayer/cli/src/commands/BuildCommand.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@contentlayer/core'
import { OT, pipe, T } from '@contentlayer/utils/effect'
import * as core from '@contentlayer2/core'
import { OT, pipe, T } from '@contentlayer2/utils/effect'
import type { Usage } from 'clipanion'

import { BaseCommand } from './_BaseCommand.js'
Expand All @@ -25,6 +25,6 @@ export class BuildCommand extends BaseCommand {
T.tap((config) => (config.source.options.disableImportAliasWarning ? T.unit : T.fork(core.validateTsconfig))),
T.chain((config) => core.generateDotpkg({ config, verbose: this.verbose })),
T.tap(core.logGenerateInfo),
OT.withSpan('@contentlayer/cli/commands/BuildCommand:executeSafe'),
OT.withSpan('@contentlayer2/cli/commands/BuildCommand:executeSafe'),
)
}
4 changes: 2 additions & 2 deletions packages/@contentlayer/cli/src/commands/DefaultCommand.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OT, pipe, T } from '@contentlayer/utils/effect'
import { OT, pipe, T } from '@contentlayer2/utils/effect'
import { Command } from 'clipanion'

import { BaseCommand } from './_BaseCommand.js'
Expand All @@ -9,6 +9,6 @@ export class DefaultCommand extends BaseCommand {
executeSafe = () =>
pipe(
T.succeedWith(() => console.log(this.cli.usage())),
OT.withSpan('@contentlayer/cli/commands/DefaultCommand:executeSafe', { attributes: { cwd: process.cwd() } }),
OT.withSpan('@contentlayer2/cli/commands/DefaultCommand:executeSafe', { attributes: { cwd: process.cwd() } }),
)
}
10 changes: 5 additions & 5 deletions packages/@contentlayer/cli/src/commands/DevCommand.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as core from '@contentlayer/core'
import { errorToString } from '@contentlayer/utils'
import { E, OT, pipe, S, T } from '@contentlayer/utils/effect'
import * as core from '@contentlayer2/core'
import { errorToString } from '@contentlayer2/utils'
import { E, OT, pipe, S, T } from '@contentlayer2/utils/effect'
import type { Usage } from 'clipanion'

import { BaseCommand } from './_BaseCommand.js'
Expand Down Expand Up @@ -31,8 +31,8 @@ export class DevCommand extends BaseCommand {
core.generateDotpkgStream({ config, verbose: this.verbose, isDev: true }),
),
S.tap(E.fold((error) => T.log(errorToString(error)), core.logGenerateInfo)),
OT.withStreamSpan('@contentlayer/cli/commands/DevCommand:stream'),
OT.withStreamSpan('@contentlayer2/cli/commands/DevCommand:stream'),
S.runDrain,
OT.withSpan('@contentlayer/cli/commands/DevCommand:executeSafe'),
OT.withSpan('@contentlayer2/cli/commands/DevCommand:executeSafe'),
)
}
10 changes: 6 additions & 4 deletions packages/@contentlayer/cli/src/commands/PostInstallCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as path from 'node:path'

import * as core from '@contentlayer/core'
import { fs } from '@contentlayer/utils'
import { OT, pipe, T } from '@contentlayer/utils/effect'
import * as core from '@contentlayer2/core'
import { fs } from '@contentlayer2/utils'
import { OT, pipe, T } from '@contentlayer2/utils/effect'

import { BaseCommand } from './_BaseCommand.js'

Expand All @@ -19,7 +19,9 @@ export class PostInstallCommand extends BaseCommand {

yield* $(addToplevelDotpkgToGitignore())
}),
OT.withSpan('@contentlayer/cli/commands/PostInstallCommand:executeSafe', { attributes: { cwd: process.cwd() } }),
OT.withSpan('@contentlayer2/cli/commands/PostInstallCommand:executeSafe', {
attributes: { cwd: process.cwd() },
}),
)
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/@contentlayer/cli/src/commands/_BaseCommand.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { HasCwd } from '@contentlayer/core'
import * as core from '@contentlayer/core'
import { fs } from '@contentlayer/utils'
import type { HasClock, HasConsole, OT } from '@contentlayer/utils/effect'
import { pipe, T } from '@contentlayer/utils/effect'
import type { HasCwd } from '@contentlayer2/core'
import * as core from '@contentlayer2/core'
import { fs } from '@contentlayer2/utils'
import type { HasClock, HasConsole, OT } from '@contentlayer2/utils/effect'
import { pipe, T } from '@contentlayer2/utils/effect'
import { Command, Option } from 'clipanion'
import * as t from 'typanion'

Expand Down
8 changes: 4 additions & 4 deletions packages/@contentlayer/cli/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import '@contentlayer/utils/effect/Tracing/Enable'
import '@contentlayer2/utils/effect/Tracing/Enable'

import process from 'node:process'

import { provideDummyTracing } from '@contentlayer/utils'
import { pipe, T } from '@contentlayer/utils/effect'
import { getContentlayerVersion, NodeFsLive } from '@contentlayer/utils/node'
import { provideDummyTracing } from '@contentlayer2/utils'
import { pipe, T } from '@contentlayer2/utils/effect'
import { getContentlayerVersion, NodeFsLive } from '@contentlayer2/utils/node'
import { Builtins, Cli } from 'clipanion'

import { BuildCommand } from './commands/BuildCommand.js'
Expand Down
2 changes: 1 addition & 1 deletion packages/@contentlayer/cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// TODO Note this seems to be unused and should be deleted soon
import type { DocumentTypeDef, DocumentTypeDefMap, NestedTypeDef, NestedTypeDefMap } from '@contentlayer/core'
import type { DocumentTypeDef, DocumentTypeDefMap, NestedTypeDef, NestedTypeDefMap } from '@contentlayer2/core'

export const derefDocumentOrThrow = (documentDefMap: DocumentTypeDefMap, documentDefName: string): DocumentTypeDef => {
if (!(documentDefName in documentDefMap)) {
Expand Down
6 changes: 3 additions & 3 deletions packages/@contentlayer/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentlayer/client",
"version": "0.3.4",
"name": "@contentlayer2/client",
"version": "0.4.1",
"type": "module",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand All @@ -13,7 +13,7 @@
"test": "echo No tests yet"
},
"dependencies": {
"@contentlayer/core": "workspace:*"
"@contentlayer2/core": "workspace:*"
},
"license": "MIT"
}
2 changes: 1 addition & 1 deletion packages/@contentlayer/client/src/guards.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Document, GetDocumentTypeMapGen, GetDocumentTypeNamesGen } from '@contentlayer/core'
import type { Document, GetDocumentTypeMapGen, GetDocumentTypeNamesGen } from '@contentlayer2/core'

// type Guards = {
// isType: TypeGuards
Expand Down
Loading