-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from code-hike/config-props
Better props support for mdx
- Loading branch information
Showing
26 changed files
with
338 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
## Files and Folders | ||
|
||
- `packages/mdx`: the npm package | ||
- `packages/mdx/vite.config.js`: we only use vite for testing with vitest | ||
- `packages/mdx/rollup.config.js`: rollup builds the thing we release to npm | ||
- `packages/mdx/next.config.js`: we have a nextjs testing site, our poor man's storybook | ||
- `packages/mdx/pages`: the pages for the nextjs test site | ||
- `packages/mdx/dev`: code and content used by the nextjs test site | ||
- `packages/mdx/src/remark`: the code that runs at build time when you compile an mdx file | ||
- `examples`: a list of examples, most of them use the Code Hike version from `packages/mdx/dist` | ||
- `examples/bundle-test`: this one is used by `.github/workflows/bundle-analysis.yml` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
`<CH.Code lineNumbers showCopyButton={false} className="foobar">` | ||
|
||
<CH.Code lineNumbers showCopyButton={false} className="foobar"> | ||
|
||
```js | ||
console.log(1) | ||
``` | ||
|
||
</CH.Code> | ||
|
||
`<CH.Code lineNumbers={false} showCopyButton={true} className="foo">` | ||
|
||
<CH.Code lineNumbers={false} showCopyButton={true} className="foo"> | ||
|
||
```js index.js | ||
console.log(2) | ||
``` | ||
|
||
```python foo.py | ||
print(3) | ||
``` | ||
|
||
--- | ||
|
||
```html index.html | ||
<div>Hi</div> | ||
``` | ||
|
||
</CH.Code> | ||
|
||
`<CH.Code className="foobarbazbarbar" style={{border: "2px solid red", height: 160}}>` | ||
|
||
<CH.Code className="foobarbazbarbar" style={{border: "2px solid red", height: 160}}> | ||
|
||
```js index.js | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
console.log(2) | ||
``` | ||
|
||
</CH.Code> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export { remarkCodeHike } from "./mdx-plugin/plugin" | ||
export { transform as remarkCodeHike } from "./remark/transform" | ||
|
||
export { highlight } from "./highlighter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export type CodeHikeConfig = { | ||
theme: any | ||
lineNumbers?: boolean | ||
autoImport?: boolean | ||
showCopyButton?: boolean | ||
} | ||
|
||
/** | ||
* Add defaults and normalize config | ||
*/ | ||
export function addConfigDefaults( | ||
config: Partial<CodeHikeConfig> | undefined | ||
): CodeHikeConfig { | ||
// TODO warn when config looks weird | ||
return { | ||
...config, | ||
theme: config?.theme || {}, | ||
autoImport: config?.autoImport === false ? false : true, | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.