Skip to content

Refactor themes #370

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

Merged
merged 12 commits into from
Jun 8, 2023
Merged
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ packages/mdx/components.d.ts

# Contentlayer
.contentlayer

todo.md
11 changes: 6 additions & 5 deletions examples/browser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<title>Code Hike in the browser</title>
<link
rel="stylesheet"
href="https://esm.sh/@code-hike/mdx@0.8.0--canary.308.cf940c7.0/dist/index.css"
href="https://esm.sh/@code-hike/mdx@0.9.0/dist/index.css"
/>
</head>
<body>
Expand All @@ -16,9 +16,8 @@
import { evaluate } from "https://esm.sh/@mdx-js/mdx?bundle"
import * as runtime from "https://esm.sh/react/jsx-runtime.js"

import theme from "https://esm.sh/shiki@0.10.1/themes/dracula.json" assert { type: "json" }
import { remarkCodeHike } from "https://esm.sh/@code-hike/mdx@0.8.0--canary.308.cf940c7.0/dist/index.browser.mjs"
import { CH } from "https://esm.sh/@code-hike/mdx@0.8.0--canary.308.d5a4a6c.0/components"
import { remarkCodeHike } from "https://esm.sh/@code-hike/mdx@0.9.0/dist/index.browser.mjs"
import { CH } from "https://esm.sh/@code-hike/mdx@0.9.0/components"

const mdx = `# Test

Expand All @@ -37,7 +36,9 @@

const { default: Content } = await evaluate(mdx, {
...runtime,
remarkPlugins: [[remarkCodeHike, { autoImport: false, theme }]],
remarkPlugins: [
[remarkCodeHike, { autoImport: false, theme: "dracula" }],
],
})

const App = () => {
Expand Down
3 changes: 1 addition & 2 deletions examples/bundle-test/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { remarkCodeHike } = require("@code-hike/mdx")
const theme = require("shiki/themes/nord.json")

const withMDX = require("@next/mdx")({
extension: /\.mdx?$/,
options: {
remarkPlugins: [[remarkCodeHike, { theme }]],
remarkPlugins: [[remarkCodeHike, { theme: "nord" }]],
},
})

Expand Down
5 changes: 1 addition & 4 deletions examples/contentlayer/contentlayer.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { defineDocumentType, makeSource } from "contentlayer/source-files"
import { remarkCodeHike } from "@code-hike/mdx"
import { createRequire } from "module"
const require = createRequire(import.meta.url)
const theme = require("shiki/themes/material-palenight.json")

const Post = defineDocumentType(() => ({
name: "Post",
Expand All @@ -27,5 +24,5 @@ export default makeSource({
contentDirPath: "posts",
documentTypes: [Post],

mdx: { remarkPlugins: [[remarkCodeHike, { theme }]] },
mdx: { remarkPlugins: [[remarkCodeHike, { theme: "material-palenight" }]] },
})
5 changes: 3 additions & 2 deletions examples/docusaurus/docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const theme = require("shiki/themes/material-palenight.json")
const { remarkCodeHike } = require("@code-hike/mdx")

/** @type {import('@docusaurus/types').Config} */
Expand All @@ -18,7 +17,9 @@ const config = {
/** @type {import('@docusaurus/preset-classic').Options} */
({
docs: {
beforeDefaultRemarkPlugins: [[remarkCodeHike, { theme }]],
beforeDefaultRemarkPlugins: [
[remarkCodeHike, { theme: "material-palenight" }],
],
sidebarPath: require.resolve("./sidebars.js"),
},
theme: {
Expand Down
3 changes: 1 addition & 2 deletions examples/gatsby/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const { remarkCodeHike } = require("@code-hike/mdx")
const theme = require("shiki/themes/material-palenight.json")

module.exports = {
siteMetadata: {
Expand All @@ -11,7 +10,7 @@ module.exports = {
options: {
extensions: [`.mdx`, `.md`],
mdxOptions: {
remarkPlugins: [[remarkCodeHike, { theme }]],
remarkPlugins: [[remarkCodeHike, { theme: "material-palenight" }]],
},
},
},
Expand Down
3 changes: 1 addition & 2 deletions examples/mdx-bundler/src/posts.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import fs from "fs"
import path from "path"
import { remarkCodeHike } from "@code-hike/mdx"
import theme from "shiki/themes/material-palenight.json"
import { bundleMDX } from "mdx-bundler"

export function getPostNames() {
Expand Down Expand Up @@ -42,7 +41,7 @@ export async function getPostSource(postName) {
mdxOptions(options) {
options.remarkPlugins = [
...(options.remarkPlugins ?? []),
[remarkCodeHike, { theme }],
[remarkCodeHike, { theme: "material-palenight" }],
]
return options
},
Expand Down
5 changes: 3 additions & 2 deletions examples/next-mdx-remote/pages/posts/[slug].js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import path from "path"
import { postNames, POSTS_PATH } from "../../src/posts"
import { remarkCodeHike } from "@code-hike/mdx"
import { CH } from "@code-hike/mdx/components"
import theme from "shiki/themes/material-palenight.json"

export default function PostPage({ source }) {
return (
Expand All @@ -28,7 +27,9 @@ export const getStaticProps = async ({ params }) => {

const mdxSource = await serialize(source, {
mdxOptions: {
remarkPlugins: [[remarkCodeHike, { autoImport: false, theme }]],
remarkPlugins: [
[remarkCodeHike, { autoImport: false, theme: "material-palenight" }],
],
useDynamicImport: true,
},
})
Expand Down
3 changes: 1 addition & 2 deletions examples/nextjs/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
const { remarkCodeHike } = require("@code-hike/mdx")
const theme = require("shiki/themes/material-palenight.json")

const withMDX = require("@next/mdx")({
extension: /\.mdx?$/,
options: {
remarkPlugins: [[remarkCodeHike, { theme }]],
remarkPlugins: [[remarkCodeHike, { theme: "material-palenight" }]],
},
})

Expand Down
3 changes: 1 addition & 2 deletions examples/nextra/next.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const { remarkCodeHike } = require("@code-hike/mdx")
const theme = require("shiki/themes/material-palenight.json")

const withNextra = require("nextra")({
theme: "nextra-theme-docs",
themeConfig: "./theme.config.mjs",
mdxOptions: {
remarkPlugins: [[remarkCodeHike, { theme }]],
remarkPlugins: [[remarkCodeHike, { theme: "material-palenight" }]],
},
})

Expand Down
3 changes: 1 addition & 2 deletions examples/nextra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"nextra": "2.4.2",
"nextra-theme-docs": "2.4.2",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"shiki": "^0.10.1"
"react-dom": "^18.1.0"
}
}
4 changes: 1 addition & 3 deletions examples/remix/remix.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { remarkCodeHike } = require("@code-hike/mdx")
const theme = require("shiki/themes/dracula.json")

/**
* @type {import('@remix-run/dev').AppConfig}
*/
Expand All @@ -12,6 +10,6 @@ module.exports = {
// publicPath: "/build/",
// devServerPort: 8002
mdx: {
remarkPlugins: [[remarkCodeHike, { theme }]],
remarkPlugins: [[remarkCodeHike, { theme: "dracula" }]],
},
}
Loading