-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding guide with contentlayer, wip
Signed-off-by: sarthakjdev <[email protected]>
- Loading branch information
1 parent
5c1b50c
commit 9fd8c67
Showing
14 changed files
with
1,290 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ yarn-error.log* | |
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
.contentlayer |
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,52 @@ | ||
import { defineDocumentType, makeSource } from 'contentlayer/source-files' | ||
import remarkGfm from 'remark-gfm' | ||
import { remarkCodeHike } from '@code-hike/mdx';; | ||
import rehypeAutolinkHeadings from 'rehype-autolink-headings'; | ||
import rehypeSlug from 'rehype-slug'; | ||
|
||
export const GuideDocument = defineDocumentType(() => ({ | ||
name: 'Content', | ||
filePathPattern: `**/*.mdx`, | ||
contentType: 'mdx', | ||
fields: { | ||
title: { | ||
type: 'string', | ||
required: true, | ||
}, | ||
category: { | ||
type: 'string', | ||
required: true, | ||
}, | ||
}, | ||
computedFields: { | ||
slug: { | ||
type: 'string', | ||
resolve: (doc) => doc._raw.flattenedPath.replace(/\d+-/g, ''), | ||
}, | ||
url: { | ||
type: 'string', | ||
resolve: (doc) => `/guide/${doc._raw.flattenedPath.replace(/\d+-/g, '')}`, | ||
}, | ||
}, | ||
})); | ||
|
||
export default makeSource({ | ||
contentDirPath: 'src/guide-content', | ||
documentTypes: [GuideDocument], | ||
mdx: { | ||
remarkPlugins: [remarkGfm, [remarkCodeHike]], | ||
rehypePlugins: [ | ||
rehypeSlug, | ||
[ | ||
rehypeAutolinkHeadings, | ||
{ | ||
properties: { | ||
class: | ||
'relative inline-flex place-items-center place-content-center outline-none text-black dark:text-white pr-2 -ml-8 opacity-0 group-hover:opacity-100', | ||
}, | ||
behavior: 'prepend', | ||
}, | ||
], | ||
], | ||
}, | ||
}); |
1 change: 1 addition & 0 deletions
1
apps/wapijs.co/guide-content/installation-and-setup/get-api-credentials.mdx
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 @@ | ||
## How to get your Whatsapp Cloud API credentials |
1 change: 1 addition & 0 deletions
1
apps/wapijs.co/guide-content/installation-and-setup/initiate-bot.mdx
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 @@ | ||
## How to initiate your Wapi.js Bot |
1 change: 1 addition & 0 deletions
1
apps/wapijs.co/guide-content/installation-and-setup/register-phone-number.mdx
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 @@ | ||
## How to register a phone number |
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 @@ | ||
## Before you begin |
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 |
---|---|---|
@@ -1,9 +1,20 @@ | ||
/** @type {import('next').NextConfig} */ | ||
const nextConfig = { | ||
reactStrictMode: true, | ||
compiler: { | ||
removeConsole: process.env.NODE_ENV === 'production' | ||
} | ||
} | ||
|
||
import BundleAnalyzerPlugin from '@next/bundle-analyzer' | ||
import { withContentlayer } from 'next-contentlayer' | ||
|
||
const withBundleAnalyzer = BundleAnalyzerPlugin({ | ||
enabled: process.env.ANALYZE === 'true' | ||
}) | ||
|
||
const nextConfig = withBundleAnalyzer( | ||
withContentlayer({ | ||
reactStrictMode: true, | ||
compiler: { | ||
removeConsole: process.env.NODE_ENV === 'production' | ||
}, | ||
poweredByHeader: false | ||
}) | ||
) | ||
|
||
export default nextConfig |
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,5 @@ | ||
const GuideDynamicPageLayout: React.FC<{ | ||
children: React.ReactNode | ||
}> = ({ children }) => { | ||
return <>{children}</> | ||
} |
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,18 @@ | ||
import { notFound } from 'next/navigation' | ||
import { allContents } from 'contentlayer/generated' | ||
|
||
export async function generateStaticParams() { | ||
return allContents.map(content => ({ slug: [content.slug] })) | ||
} | ||
|
||
const Page = ({ params }: { readonly params: { slug: string[] } }) => { | ||
const content = allContents.find(content => content.slug === params.slug?.join('/')) | ||
|
||
if (!content) { | ||
notFound() | ||
} | ||
|
||
return <article className="prose max-w-none px-5">{/* render the content here */}</article> | ||
} | ||
|
||
export default Page |
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,7 @@ | ||
const GuideLayout: React.FC<{ | ||
children: React.ReactNode | ||
}> = ({ children }) => { | ||
return <>{children}</> | ||
} | ||
|
||
export default GuideLayout |
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,5 @@ | ||
const WapiGuidePage = () => { | ||
return <section></section> | ||
} | ||
|
||
export default WapiGuidePage |
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
Oops, something went wrong.