Skip to content

Commit 846daf3

Browse files
author
Brijesh Bittu
committed
Add Edit on Github link and fix rtl
1 parent 4c10dbd commit 846daf3

File tree

5 files changed

+45
-8
lines changed

5 files changed

+45
-8
lines changed

docs/src/app/(public)/page.pigment.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ export const linkStyle = css(
4242
padding: ${spacing(theme, 1)};
4343
gap: ${spacing(theme, 1)};
4444
margin: ${spacing(theme, -1)};
45+
46+
[dir="rtl"] & .arrow-icon {
47+
transform: rotate(180deg);
48+
}
4549
`,
4650
);
4751

@@ -69,7 +73,7 @@ export default function HomePage() {
6973
<Heading>{process.env.APP_NAME}</Heading>
7074
<Caption>{description}</Caption>
7175
<Link className={`${linkStyle}`} href={nav[0].links[0].href}>
72-
Documentation <ArrowRightIcon />
76+
Documentation <ArrowRightIcon className="arrow-icon" />
7377
</Link>
7478
</Content>
7579
</Root>
Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
1+
import { notFound } from 'next/navigation';
2+
13
import { useMDXComponents } from 'docs/mdx-components';
24
import { readMarkdown } from 'docs/utils/mdx';
3-
import { notFound } from 'next/navigation';
5+
import { Link } from './Link';
46

57
export default async function ContentPage({ basePath, slug }: { basePath: string; slug: string }) {
68
const components = useMDXComponents();
7-
const MdxContent = await readMarkdown(basePath, slug);
8-
if (!MdxContent) {
9+
const result = await readMarkdown(basePath, slug);
10+
if (!result) {
911
return notFound();
1012
}
11-
return <MdxContent components={components} />;
13+
const { MdxContent, githubFilePath } = result;
14+
return (
15+
<div>
16+
<MdxContent components={components} />
17+
<div style={{ display: 'flex', justifyContent: 'flex-end', fontSize: '0.8rem' }}>
18+
<Link href={githubFilePath} target="_blank" rel="noopener noreferrer">
19+
Edit on GitHub
20+
</Link>
21+
</div>
22+
</div>
23+
);
1224
}

docs/src/components/QuickNav.pigment.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export const Root = styled.nav(({ theme }) => ({
3030
[theme.breakpoints.lt('quickNav')]: {
3131
float: 'none',
3232
},
33+
'[dir="rtl"] &': {
34+
float: 'left',
35+
},
3336
}));
3437

3538
export const Inner = styled.div`
@@ -39,6 +42,11 @@ export const Inner = styled.div`
3942
padding-top: 0.75rem;
4043
padding-bottom: 2.5rem;
4144
width: calc(${'$sidebarWidth'} - ${'$quickNavMarginX'} * 2);
45+
46+
[dir='rtl'] & {
47+
left: auto;
48+
right: ${'$quickNavMarginX'};
49+
}
4250
`;
4351

4452
export const Title = styled.header`
@@ -53,7 +61,7 @@ export const List = styled.ul`
5361
align-items: start;
5462
5563
& & {
56-
padding-left: 0.75rem;
64+
padding-inline-start: 0.75rem;
5765
}
5866
`;
5967

docs/src/mdx-components.pigment.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ export const Heading = styled('h1')(({ theme }) => ({
4141
},
4242
},
4343
three: {
44+
...applyText(theme, 'lg'),
4445
marginTop: spacing(theme, 8),
4546
marginBottom: spacing(theme, 1.5),
4647
scrollMarginTop: spacing(theme, 6),
47-
...applyText(theme, 'lg'),
4848
fontWeight: t('$font.weight.medium'),
49+
textDecoration: 'underline',
50+
textUnderlineOffset: '0.3rem',
51+
textDecorationThickness: '1px',
52+
textDecorationColor: t('$color.line.highlight'),
4953
},
5054
other: {
5155
marginTop: spacing(theme, 8),

docs/src/utils/mdx.tsx renamed to docs/src/utils/mdx.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,5 +389,14 @@ export async function readMarkdown(baseDir: string, filePath: string) {
389389
await file?.close();
390390
}
391391

392-
return renderMdx(mdxSource);
392+
const MdxContent = await renderMdx(mdxSource);
393+
const githubFilePath = mdxFilePath.replace(
394+
process.env.CONTENT_DIR.split(path.delimiter).join('/'),
395+
`${process.env.GITHUB}/edit/master/docs/src/content`,
396+
);
397+
398+
return {
399+
MdxContent,
400+
githubFilePath,
401+
};
393402
}

0 commit comments

Comments
 (0)