Skip to content

Commit

Permalink
feat(website): improve how code-blocks are rendered on pages
Browse files Browse the repository at this point in the history
  • Loading branch information
vst committed Apr 20, 2024
1 parent 1e925a4 commit ac34d12
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 5 deletions.
15 changes: 14 additions & 1 deletion website/next.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import createMDX from '@next/mdx';
import rehypePrettyCode from 'rehype-pretty-code';

/** @type {import('next').NextConfig} */
const nextConfig = {
Expand All @@ -17,6 +18,18 @@ const nextConfig = {
pageExtensions: ['js', 'jsx', 'md', 'mdx', 'ts', 'tsx'],
};

const withMDX = createMDX({})
const withMDX = createMDX({
options: {
remarkPlugins: [],
rehypePlugins: [
[
rehypePrettyCode,
{
theme: 'dracula',
},
],
],
},
});

export default withMDX(nextConfig);
175 changes: 174 additions & 1 deletion website/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
"react-dom": "^18",
"react-icons": "^5.1.0",
"react-toastify": "^10.0.5",
"recharts": "^2.12.3"
"recharts": "^2.12.3",
"rehype-pretty-code": "^0.13.1",
"shiki": "^1.3.0"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.12",
Expand Down
2 changes: 1 addition & 1 deletion website/src/app/(pages)/quickstart/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ nix profile install --file https://github.com/vst/hostpatrol/archive/v<VERSION>.
Instead of providing hosts one-by-one, you can use a configuration
file. For example given a configuration file `config.yaml` like this:

```yaml
```yaml showLineNumbers
## List of known SSH public keys for all hosts.
knownSshKeys:
- gh:some-github-user
Expand Down
26 changes: 25 additions & 1 deletion website/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,29 @@
@tailwind utilities;

.text-balance {
text-wrap: balance;
text-wrap: balance;
}

code {
counter-reset: line;
}

code > [data-line]::before {
counter-increment: line;
content: counter(line);

/* Other styling */
display: inline-block;
width: 1rem;
margin-right: 1rem;
text-align: right;
color: gray;
}

code[data-line-numbers-max-digits='2'] > [data-line]::before {
width: 2rem;
}

code[data-line-numbers-max-digits='3'] > [data-line]::before {
width: 3rem;
}

0 comments on commit ac34d12

Please sign in to comment.