How to implement this with a T3 app? #342
-
Hey, I'm totally new to web dev (I'm an iOS developer) and I'm currently trying to build a website. I used T3 (https://create.t3.gg) to create a next.js project and now I'm trying to implement Code Hike (which looks totally awesome, btw). However, following the installation guide (https://codehike.org/docs/installation/nextjs) leads to an error. This is what my next.config.mjs looks like: /** * Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. * This is especially useful for Docker builds. */ !process.env.SKIP_ENV_VALIDATION && (await import("./src/env.mjs")); /** @type {import("next").NextConfig} */ const config = { reactStrictMode: true, /** * If you have the "experimental: { appDir: true }" setting enabled, then you * must comment the below `i18n` config out. * * @see https://github.com/vercel/next.js/issues/41980 */ i18n: { locales: ["en"], defaultLocale: "en", }, }; export default config; const theme = import("shiki/themes/nord.json") const { remarkCodeHike } = require("@code-hike/mdx") const withMDX = require("@next/mdx")({ extension: /\.mdx?$/, options: { remarkPlugins: [ [remarkCodeHike, { theme }] ], }, }) module.exports = withMDX({ pageExtensions: [ "ts", "tsx", "js", "jsx", "md", "mdx" ], }) When I run
Line 25 is Replacing Does anybody know what's going on here? I'd really appreciate any help. Let me know if you need more information :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi, thanks. The difference with the guide is that you are using a import { remarkCodeHike } from "@code-hike/mdx" (note that it's import from and not equals, like in your example). The theme may be trickier to import because it's a json file. I think this should work with next.js: import theme from "shiki/themes/nord.json" assert { type: "json" } |
Beta Was this translation helpful? Give feedback.
Hi, thanks.
The difference with the guide is that you are using a
.mjs
config. You need to use import(note that it's import from and not equals, like in your example).
The theme may be trickier to import because it's a json file. I think this should work with next.js: