Skip to content

Commit

Permalink
Merge pull request #107 from vtexdocs/feat/codeblock-copy-button
Browse files Browse the repository at this point in the history
feat: working code block
  • Loading branch information
PedroAntunesCosta authored Oct 7, 2024
2 parents 8dd010e + ed65697 commit a3d8ebf
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"cypress": "cypress open"
},
"dependencies": {
"@code-hike/mdx": "^0.9.0",
"@openreplay/tracker": "^5.0.1",
"@plaiceholder/next": "^2.5.0",
"@types/http-proxy": "^1.17.9",
Expand Down
1 change: 1 addition & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useRouter } from 'next/router'
import { IntlProvider } from 'react-intl'
import { getMessages } from 'utils/get-messages'

import '@code-hike/mdx/dist/index.css'
import 'styles/global.css'
import 'styles/rapidoc.css'
import '@vtexdocs/components/dist/index.css'
Expand Down
4 changes: 4 additions & 0 deletions src/pages/announcements/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import remarkGFM from 'remark-gfm'
import rehypeHighlight from 'rehype-highlight'
import hljsCurl from 'highlightjs-curl'
import remarkBlockquote from 'utils/remark_plugins/rehypeBlockquote'
import { remarkCodeHike } from '@code-hike/mdx'
import theme from 'styles/code-hike-theme'

import remarkImages from 'utils/remark_plugins/plaiceholder'

Expand Down Expand Up @@ -246,11 +248,13 @@ export const getStaticProps: GetStaticProps = async ({
parseFrontmatter: true,
mdxOptions: {
remarkPlugins: [
[remarkCodeHike, theme],
remarkGFM,
remarkImages,
[getHeadings, { headingList }],
remarkBlockquote,
],
useDynamicImport: true,
rehypePlugins: [
[rehypeHighlight, { languages: { hljsCurl }, ignoreMissing: true }],
],
Expand Down
6 changes: 5 additions & 1 deletion src/pages/docs/tracks/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import remarkGFM from 'remark-gfm'
import rehypeHighlight from 'rehype-highlight'
import hljsCurl from 'highlightjs-curl'
import remarkBlockquote from 'utils/remark_plugins/rehypeBlockquote'

import { remarkCodeHike } from '@code-hike/mdx'
import remarkImages from 'utils/remark_plugins/plaiceholder'

import { Box, Flex, Text } from '@vtex/brand-ui'
Expand Down Expand Up @@ -47,6 +47,8 @@ import { MarkdownRenderer } from '@vtexdocs/components'
// import { ParsedUrlQuery } from 'querystring'

import { remarkReadingTime } from 'utils/remark_plugins/remarkReadingTime'

import theme from 'styles/code-hike-theme'
import TimeToRead from 'components/TimeToRead'

const docsPathsGLOBAL = await getTracksPaths('tracks')
Expand Down Expand Up @@ -299,12 +301,14 @@ export const getStaticProps: GetStaticProps = async ({
parseFrontmatter: true,
mdxOptions: {
remarkPlugins: [
[remarkCodeHike, theme],
remarkGFM,
remarkImages,
[getHeadings, { headingList }],
remarkBlockquote,
remarkReadingTime,
],
useDynamicImport: true,
rehypePlugins: [
[rehypeHighlight, { languages: { hljsCurl }, ignoreMissing: true }],
],
Expand Down
5 changes: 4 additions & 1 deletion src/pages/docs/tutorial/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ import {
} from 'utils/navigation-utils'

import { remarkReadingTime } from 'utils/remark_plugins/remarkReadingTime'

import { remarkCodeHike } from '@code-hike/mdx'
import TutorialIndexing from 'components/tutorial-index'
import TutorialMarkdownRender from 'components/tutorial-markdown-render'
import theme from 'styles/code-hike-theme'

// import { ParsedUrlQuery } from 'querystring'

Expand Down Expand Up @@ -395,12 +396,14 @@ export const getStaticProps: GetStaticProps = async ({
parseFrontmatter: true,
mdxOptions: {
remarkPlugins: [
[remarkCodeHike, theme],
remarkGFM,
remarkImages,
[getHeadings, { headingList }],
remarkBlockquote,
remarkReadingTime,
],
useDynamicImport: true,
rehypePlugins: [
[rehypeHighlight, { languages: { hljsCurl }, ignoreMissing: true }],
],
Expand Down
4 changes: 4 additions & 0 deletions src/pages/faq/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import remarkGFM from 'remark-gfm'
import rehypeHighlight from 'rehype-highlight'
import hljsCurl from 'highlightjs-curl'
import remarkBlockquote from 'utils/remark_plugins/rehypeBlockquote'
import { remarkCodeHike } from '@code-hike/mdx'
import theme from 'styles/code-hike-theme'

import remarkImages from 'utils/remark_plugins/plaiceholder'

Expand Down Expand Up @@ -231,10 +233,12 @@ export const getStaticProps: GetStaticProps = async ({
remarkPlugins: [
remarkGFM,
remarkImages,
[remarkCodeHike, theme],
[getHeadings, { headingList }],
remarkBlockquote,
remarkReadingTime,
],
useDynamicImport: true,
rehypePlugins: [
[rehypeHighlight, { languages: { hljsCurl }, ignoreMissing: true }],
],
Expand Down
4 changes: 4 additions & 0 deletions src/pages/known-issues/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import remarkGFM from 'remark-gfm'
import rehypeHighlight from 'rehype-highlight'
import hljsCurl from 'highlightjs-curl'
import remarkBlockquote from 'utils/remark_plugins/rehypeBlockquote'
import { remarkCodeHike } from '@code-hike/mdx'
import theme from 'styles/code-hike-theme'

import remarkImages from 'utils/remark_plugins/plaiceholder'

Expand Down Expand Up @@ -238,12 +240,14 @@ export const getStaticProps: GetStaticProps = async ({
parseFrontmatter: true,
mdxOptions: {
remarkPlugins: [
[remarkCodeHike, theme],
remarkGFM,
remarkImages,
[getHeadings, { headingList }],
remarkBlockquote,
remarkReadingTime,
],
useDynamicImport: true,
rehypePlugins: [
[rehypeHighlight, { languages: { hljsCurl }, ignoreMissing: true }],
],
Expand Down
10 changes: 10 additions & 0 deletions src/styles/code-hike-theme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const theme = {
lineNumbers: false,
showCopyButton: true,
theme: 'github-dark',
skipLanguages: ['mermaid'],
staticMediaQuery: 'not screen, (max-width: 768px)',
autoImport: false,
}

export default theme

0 comments on commit a3d8ebf

Please sign in to comment.