mirror of
https://github.com/hazemKrimi/personal-website.git
synced 2026-05-02 02:10:27 +00:00
Add prettier configuration
This commit is contained in:
@@ -4,31 +4,31 @@ import { Props } from './types';
|
||||
import { Line, LineContent, LineNo, Pre } from './styles';
|
||||
|
||||
const CodeBlock = ({ children, className }: Props) => {
|
||||
const language = className.replace(/language-/, '') as Language;
|
||||
const language = className.replace(/language-/, '') as Language;
|
||||
|
||||
return (
|
||||
<Highlight
|
||||
{...defaultProps}
|
||||
theme={theme}
|
||||
code={(children as string).trim()}
|
||||
language={language}
|
||||
>
|
||||
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
||||
<Pre className={className} style={style}>
|
||||
{tokens.map((line, i) => (
|
||||
<Line key={i} {...getLineProps({ line, key: i })}>
|
||||
<LineNo>{i + 1}</LineNo>
|
||||
<LineContent>
|
||||
{line.map((token, key) => (
|
||||
<span key={key} {...getTokenProps({ token, key })} />
|
||||
))}
|
||||
</LineContent>
|
||||
</Line>
|
||||
))}
|
||||
</Pre>
|
||||
)}
|
||||
</Highlight>
|
||||
);
|
||||
return (
|
||||
<Highlight
|
||||
{...defaultProps}
|
||||
theme={theme}
|
||||
code={(children as string).trim()}
|
||||
language={language}
|
||||
>
|
||||
{({ className, style, tokens, getLineProps, getTokenProps }) => (
|
||||
<Pre className={className} style={style}>
|
||||
{tokens.map((line, i) => (
|
||||
<Line key={i} {...getLineProps({ line, key: i })}>
|
||||
<LineNo>{i + 1}</LineNo>
|
||||
<LineContent>
|
||||
{line.map((token, key) => (
|
||||
<span key={key} {...getTokenProps({ token, key })} />
|
||||
))}
|
||||
</LineContent>
|
||||
</Line>
|
||||
))}
|
||||
</Pre>
|
||||
)}
|
||||
</Highlight>
|
||||
);
|
||||
};
|
||||
|
||||
export default CodeBlock;
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
import styled from 'styled-components';
|
||||
|
||||
export const Pre = styled.pre`
|
||||
text-align: left;
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
overflow: scroll;
|
||||
text-align: left;
|
||||
margin: 1em 0;
|
||||
padding: 0.5em;
|
||||
overflow: scroll;
|
||||
`;
|
||||
|
||||
export const Line = styled.div`
|
||||
display: table-row;
|
||||
display: table-row;
|
||||
`;
|
||||
|
||||
export const LineNo = styled.span`
|
||||
display: table-cell;
|
||||
text-align: right;
|
||||
padding-right: 1em;
|
||||
user-select: none;
|
||||
opacity: 0.5;
|
||||
display: table-cell;
|
||||
text-align: right;
|
||||
padding-right: 1em;
|
||||
user-select: none;
|
||||
opacity: 0.5;
|
||||
`;
|
||||
|
||||
export const LineContent = styled.span`
|
||||
display: table-cell;
|
||||
display: table-cell;
|
||||
`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface Props {
|
||||
className: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
className: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user