Skip to content

Commit c397a81

Browse files
committed
Configure shiki syntax highlight
1 parent af10a3a commit c397a81

File tree

2 files changed

+39
-10
lines changed

2 files changed

+39
-10
lines changed

astro.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@ export default defineConfig({
1919
markdown: {
2020
remarkPlugins: [ [remarkToc, { heading: 'contents',} ] ],
2121
rehypePlugins: [rehipeFigure],
22+
shikiConfig: {
23+
theme: 'plastic',
24+
}
2225
},
2326
});

src/styles/styles.css

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -309,21 +309,47 @@ var, kbd, samp {
309309
font-family: var(--font-mono);
310310
}
311311

312-
code {
313-
padding: 2px 5px;
314-
background-color: rgb(var(--gray-light));
315-
border-radius: 2px;
312+
pre {
313+
padding: 1em;
314+
border-radius: 6px;
316315
width: 100%;
316+
/* text-wrap: auto; */
317+
overflow-x: auto;
318+
white-space-collapse: preserve;
319+
text-wrap-mode: wrap;
320+
line-height: 1em;
317321
}
318-
pre {
319-
padding: 1.5em;
320-
border-radius: 8px;
321-
width:100%
322+
323+
code {
324+
font-size: var(--text-sm);
325+
font-family: 'Courier New', Courier, monospace;
326+
@apply block leading-tight p-2 pl-1;
327+
counter-reset: step;
328+
counter-increment: step 0;
329+
322330
}
323-
pre > code {
324-
all: unset;
331+
332+
pre code .line {
333+
@apply relative;
334+
}
335+
336+
pre code .line::before {
337+
@apply absolute overflow-hidden w-7 h-4 -left- top-0 text-right;
338+
padding-right: 1em;
339+
content: counter(step);
340+
counter-increment: step;
341+
color: rgba(115, 138, 148, 0.4);
342+
}
343+
344+
/* For some reason astro always adds a blank .line element at the bottom */
345+
pre code .line:last-child {
346+
display:none;
325347
}
326348

349+
/* pre > code {
350+
all: unset;
351+
}
352+
*/
327353

328354
del {
329355
text-decoration: line-through;

0 commit comments

Comments
 (0)