Skip to content
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

fixed the layout #33

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"dependencies": {
"@amplitude/analytics-browser": "1.6.6",
"@code-hike/mdx": "^0.7.4",
"@code-hike/mdx": "0.7.4",
"@cube-dev/ui-kit": "0.11.1",
"@mdx-js/loader": "2.2.1",
"@next/mdx": "13.0.7",
Expand Down Expand Up @@ -40,6 +40,7 @@
"react-hotjar": "5.3.0",
"react-icons": "^4.7.1",
"rehype-autolink-headings": "6.1.1",
"rehype-prism-plus": "1.5.0",
"rehype-slug": "5.1.0",
"remark-gfm": "^3.0.1",
"shiki": "^0.11.1",
Expand Down
40 changes: 22 additions & 18 deletions packages/app/src/lib/getMDXContent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { remarkCodeHike } from '@code-hike/mdx';
import { Octokit } from 'octokit';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
import { bundle } from './bundler/bundler';
import remarkCodeHike from '@code-hike/mdx';
import theme from 'shiki/themes/material-palenight.json';

async function getMdxContent(
Expand All @@ -13,25 +13,29 @@ async function getMdxContent(
) {
const octokit = new Octokit({ auth: process.env.GITHUB_PAT });
let route = `/${path}/${page}.mdx`;
const { data }: any = await octokit.rest.repos.getContent({
owner: owner,
repo: repoName,
path: route,
});
let mdx;
try {
const { data }: any = await octokit.rest.repos.getContent({
owner: owner,
repo: repoName,
path: route,
});
let mdx;
if (Array.isArray(data)) {
mdx = Buffer.from(data[0].content!, 'base64').toString('utf-8');
} else {
mdx = Buffer.from(data?.content, 'base64').toString('utf-8');
}

if (Array.isArray(data)) {
mdx = Buffer.from(data[0].content!, 'base64').toString('ascii');
} else {
mdx = Buffer.from(data?.content, 'base64').toString('ascii');
let pageContent = await bundle(mdx, {
rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings],
// remarkPlugins: [remarkCodeHike, { showCopyButton: true, theme }],
remarkPlugins: [],
headerDepth: 3,
});
return pageContent;
} catch (err) {
console.log(err);
}

let pageContent = await bundle(mdx, {
rehypePlugins: [rehypeSlug, rehypeAutolinkHeadings],
remarkPlugins: [[remarkCodeHike, { showCopyButton: true, theme }]],
headerDepth: 3,
});
return pageContent;
}

export { getMdxContent };
21 changes: 13 additions & 8 deletions packages/app/src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ import '../../styles/globals.css';
import type { AppProps } from 'next/app';
import { BreakpointsProvider, Root, SSRProvider } from '@cube-dev/ui-kit';
import Layout from '../components/shared/Layouts/Layout';
import '@code-hike/mdx/dist/index.css';

import { useRouter } from 'next/router';
export default function App({ Component, pageProps }: AppProps) {
const router = useRouter();

return (
<Root bodyStyles={{ 'background-color': '#121312' }}>
<SSRProvider>
<SSRProvider>
<Root bodyStyles={{ 'background-color': '#121312' }}>
<BreakpointsProvider value={[1140, 900, 500]}>
<Layout>
{router.asPath !== '/' ? (
<Layout>
<Component {...pageProps} />
</Layout>
) : (
<Component {...pageProps} />
</Layout>
)}
</BreakpointsProvider>
</SSRProvider>
</Root>
</Root>
</SSRProvider>
);
}
10 changes: 10 additions & 0 deletions packages/app/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,13 @@ a:hover {
.ch-codeblock:hover .ch-code-button {
display: block;
}

code {
color: #f2f2f2 !important;
}
pre {
background: #171817 !important;
border: 1px solid #3e3e3e !important;
border-radius: 1rem;
padding: 0.5rem 1rem;
}
85 changes: 83 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.