mirror of
https://github.com/timmypidashev/web.git
synced 2026-04-14 02:53:51 +00:00
Colors work on inline code lets go
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
// [slug]/page.jsx
|
||||
import { getBlogBySlug, getAllBlogSlugs } from "@/lib/mdx";
|
||||
import MdxProvider from "@/components/prism/mdx-provider";
|
||||
|
||||
export async function generateStaticParams() {
|
||||
const slugs = await getAllBlogSlugs();
|
||||
@@ -9,14 +11,18 @@ export async function generateStaticParams() {
|
||||
|
||||
export default async function BlogPage({ params }) {
|
||||
const blog = await getBlogBySlug(params.slug);
|
||||
|
||||
return (
|
||||
<section className="py-16 prose">
|
||||
<section className="py-16 prose mx-auto">
|
||||
<article>
|
||||
<h1 className="text-light-foreground dark:text-dark-foreground">{blog.frontmatter.title}</h1>
|
||||
<p className="text-light-yellow-1 dark:text-dark-yellow-1">{blog.frontmatter.author}</p>
|
||||
<p className="text-light-blue-1 dark:text-dark-blue-1">{blog.frontmatter.date}</p>
|
||||
<MdxProvider>
|
||||
<div>{blog.content}</div>
|
||||
</MdxProvider>
|
||||
</article>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,12 @@ description: "This is a sample MDX file."
|
||||
tags: ["coreboot", "t440p", "dgpu"]
|
||||
---
|
||||
|
||||
|
||||
```python
|
||||
import random
|
||||
print(random.randint(1, 100))
|
||||
```
|
||||
|
||||
# Heading 1
|
||||
|
||||
## Heading 2
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
// Imports
|
||||
import "@/style/globals.css";
|
||||
import "@/style/prism-theme.css";
|
||||
import Theme from "@/app/theme";
|
||||
import Header from "@/components/header";
|
||||
import Footer from "@/components/footer";
|
||||
import Container from "@/components/ui/container";
|
||||
import Head from 'next/head';
|
||||
|
||||
// Metadata
|
||||
export const metadata = {
|
||||
@@ -15,6 +17,9 @@ export const metadata = {
|
||||
export default function Layout({children}) {
|
||||
return (
|
||||
<html lang="en" suppressHydrationWarning>
|
||||
<Head>
|
||||
<script src="prism.js"></script>
|
||||
</Head>
|
||||
<body className="
|
||||
bg-light-background text-light-foreground
|
||||
dark:bg-dark-background dark:text-dark-foreground
|
||||
|
||||
32
src/components/prism/mdx-provider.js
Normal file
32
src/components/prism/mdx-provider.js
Normal file
@@ -0,0 +1,32 @@
|
||||
"use client"
|
||||
|
||||
// mdx-provider.js
|
||||
import { MDXProvider } from '@mdx-js/react';
|
||||
import Prism from './prism-setup';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
const CodeBlock = ({ children, className }) => {
|
||||
const language = className?.replace(/language-/, '') || '';
|
||||
|
||||
useEffect(() => {
|
||||
Prism.highlightAll();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<pre className={className}>
|
||||
<code className={className}>{children}</code>
|
||||
</pre>
|
||||
);
|
||||
};
|
||||
|
||||
const components = {
|
||||
pre: CodeBlock,
|
||||
code: CodeBlock,
|
||||
};
|
||||
|
||||
const MdxProvider = ({ children }) => {
|
||||
return <MDXProvider components={components}>{children}</MDXProvider>;
|
||||
};
|
||||
|
||||
export default MdxProvider;
|
||||
|
||||
10
src/components/prism/prism-setup.js
Normal file
10
src/components/prism/prism-setup.js
Normal file
@@ -0,0 +1,10 @@
|
||||
// prism-setup.js
|
||||
import Prism from 'prismjs';
|
||||
import 'prismjs/components/prism-python'; // Add more languages as needed
|
||||
|
||||
// Add more languages as needed, e.g.:
|
||||
// import 'prismjs/components/prism-python';
|
||||
// import 'prismjs/components/prism-java';
|
||||
|
||||
export default Prism;
|
||||
|
||||
143
src/style/prism-theme.css
Normal file
143
src/style/prism-theme.css
Normal file
@@ -0,0 +1,143 @@
|
||||
/**
|
||||
* Gruvbox dark theme
|
||||
*
|
||||
* Adapted from a theme based on:
|
||||
* Vim Gruvbox dark Theme (https://github.com/morhetz/gruvbox)
|
||||
*
|
||||
* @author Azat S. <to@azat.io>
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
color: #ebdbb2; /* fg1 / fg */
|
||||
font-family: Consolas, Monaco, "Andale Mono", monospace;
|
||||
direction: ltr;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
pre[class*="language-"]::-moz-selection,
|
||||
pre[class*="language-"] ::-moz-selection,
|
||||
code[class*="language-"]::-moz-selection,
|
||||
code[class*="language-"] ::-moz-selection {
|
||||
color: #fbf1c7; /* fg0 */
|
||||
background: #7c6f64; /* bg4 */
|
||||
}
|
||||
|
||||
pre[class*="language-"]::selection,
|
||||
pre[class*="language-"] ::selection,
|
||||
code[class*="language-"]::selection,
|
||||
code[class*="language-"] ::selection {
|
||||
color: #fbf1c7; /* fg0 */
|
||||
background: #7c6f64; /* bg4 */
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: 0.5em 0;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
:not(pre) > code[class*="language-"],
|
||||
pre[class*="language-"] {
|
||||
background: #1d2021; /* bg0_h */
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(pre) > code[class*="language-"] {
|
||||
padding: 0.1em;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.cdata {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.delimiter,
|
||||
.token.boolean,
|
||||
.token.keyword,
|
||||
.token.selector,
|
||||
.token.important,
|
||||
.token.atrule {
|
||||
color: #fb4934; /* red2 */
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.punctuation,
|
||||
.token.attr-name {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.tag,
|
||||
.token.tag .punctuation,
|
||||
.token.doctype,
|
||||
.token.builtin {
|
||||
color: #fabd2f; /* yellow2 */
|
||||
}
|
||||
|
||||
.token.entity,
|
||||
.token.number,
|
||||
.token.symbol {
|
||||
color: #d3869b; /* purple2 */
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.constant,
|
||||
.token.variable {
|
||||
color: #fb4934; /* red2 */
|
||||
}
|
||||
|
||||
.token.string,
|
||||
.token.char {
|
||||
color: #b8bb26; /* green2 */
|
||||
}
|
||||
|
||||
.token.attr-value,
|
||||
.token.attr-value .punctuation {
|
||||
color: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.url {
|
||||
color: #b8bb26; /* green2 */
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.token.function {
|
||||
color: #fabd2f; /* yellow2 */
|
||||
}
|
||||
|
||||
.token.regex {
|
||||
background: #b8bb26; /* green2 */
|
||||
}
|
||||
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.inserted {
|
||||
background: #a89984; /* fg4 / gray1 */
|
||||
}
|
||||
|
||||
.token.deleted {
|
||||
background: #fb4934; /* red2 */
|
||||
}
|
||||
Reference in New Issue
Block a user