Skip to content

Commit

Permalink
feat: new docs (#224)
Browse files Browse the repository at this point in the history
new documentation to site to include plugins
  • Loading branch information
o-az authored Jun 26, 2024
1 parent f76c743 commit c796c92
Show file tree
Hide file tree
Showing 63 changed files with 4,502 additions and 3,175 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
echo "PNPM_VERSION=$PNPM_VERSION" >> $GITHUB_OUTPUT
- name: 'Setup pnpm'
uses: pnpm/action-setup@v3
uses: pnpm/action-setup@v4
with:
version: ${{ steps.pnpm-version.outputs.PNPM_VERSION }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
echo "PNPM_VERSION=$PNPM_VERSION" >> $GITHUB_OUTPUT
- name: 'Setup pnpm'
uses: pnpm/action-setup@v3
uses: pnpm/action-setup@v4
with:
version: ${{ steps.pnpm-version.outputs.PNPM_VERSION }}

Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ _
.svelte-kit
.wrangler
build/
cache
**/.vitepress/cache/
.vitepress/dist
*.timestamp-*
site
.zed
7 changes: 7 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"default": true,
"MD013": false,
"MD033": false,
"MD036": false,
"MD041": false
}
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ shell-emulator=true
shamefully-hoist=true
enable-pre-post-scripts=true
package-manager-strict=false
node-options="--no-warnings"
ignore-workspace-root-check=true
node-options="--no-warnings NODE_NO_WARNINGS=1"

@jsr:registry=https://npm.jsr.io
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"recommendations": [
"biomejs.biome",
"astro-build.astro-vscode",
"bradlc.vscode-tailwindcss",
"tobermory.es6-string-html",
"EditorConfig.EditorConfig",
"yzhang.markdown-all-in-one",
"orta.vscode-twoslash-queries"
],
"unwantedRecommendations": [
Expand Down
15 changes: 10 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.preferences.importModuleSpecifier": "non-relative",
"typescript.inlayHints.parameterNames.enabled": "all",
"typescript.preferences.importModuleSpecifier": "shortest",
"typescript.preferences.preferTypeOnlyAutoImports": true,
"references.preferredLocation": "peek",
"editor.quickSuggestions": {
"strings": "on"
},
"tailwindCSS.includeLanguages": {
"plaintext": "html"
},
"biome.enabled": true,
// format & lint settings
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports.biome": "always",
Expand All @@ -27,9 +27,11 @@
"[jsonc]": { "editor.defaultFormatter": "biomejs.biome" },
"[astro]": { "editor.defaultFormatter": "astro-build.astro-vscode" },
"[svelte]": { "editor.defaultFormatter": "svelte.svelte-vscode" },
"[vue]": { "editor.defaultFormatter": "vue.volar" },
"files.associations": {
"biome.json": "jsonc",
"*.css": "tailwindcss"
"*.css": "tailwindcss",
".markdownlint.json": "jsonc"
},
"search.exclude": {
"_": true,
Expand All @@ -39,7 +41,10 @@
"**/pnpm-lock.yaml": true,
"**/package-lock.json": true
},
"[elixir]": {
"editor.defaultFormatter": "JakeBecker.elixir-ls"
"files.exclude": {
"**/*.timestamp-*": true
},
"[markdown]": {
"editor.defaultFormatter": "yzhang.markdown-all-in-one"
}
}
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

<h1 align="center" style="font-size: 2.8rem; font-weight: 900; color: white;">Rehype Pretty Code</h1>

<a href="https://npmjs.com/package/rehype-pretty-code" target="\_parent">
<img alt="" src="https://img.shields.io/npm/dm/rehype-pretty-code.svg" />
</a>
<a href="https://github.com/rehype-pretty/rehype-pretty-code/discussions">
<img alt="Join the discussion on Github" src="https://img.shields.io/badge/Github%20Discussions%20%26%20Support-Chat%20now!-blue" />
</a>
<a href="https://github.com/rehype-pretty/rehype-pretty-code" target="\_parent">
<img alt="" src="https://img.shields.io/github/stars/rehype-pretty/rehype-pretty-code.svg?style=social&label=Star" />
</a>

<p align="center">
<a href="https://rehype-pretty.pages.dev" target="_blank" rel="noopener noreferrer">
<img width="750" src="./.github/images/screenshot.png" alt="screenshot" />
Expand All @@ -18,8 +28,7 @@ Beautiful code blocks for your MD/MDX docs.

## Integration Examples


| <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/examples/sveltekit"><img src="https://api.iconify.design/vscode-icons:file-type-svelte.svg" alt="svelte logo" width="100" style="padding:1px;" /> <br/> [SvelteKit](./examples/sveltekit)</a> | <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/examples/astro"><img src="https://api.iconify.design/vscode-icons:file-type-astro.svg" alt="Astro logo" width="100" style="padding:1px;" /><br/> [Astro](./examples/astro)</a> | <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/examples/cdn/index.html"><img src="https://api.iconify.design/vscode-icons:file-type-html.svg" alt="html logo" width="100" style="padding:1px;" /><br/> [CDN](./examples/cdn/index.html)</a> | <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/website"><img src="https://api.iconify.design/devicon:nextjs.svg" alt="html logo" width="100" style="padding:1px;" /><br/> [Next.js](./website)</a> |
| <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/examples/sveltekit"><img src="https://api.iconify.design/vscode-icons:file-type-svelte.svg" alt="svelte logo" width="100" style="padding:1px;" /> <br/> [SvelteKit](./examples/sveltekit)</a> | <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/examples/astro"><img src="https://api.iconify.design/vscode-icons:file-type-astro.svg" alt="Astro logo" width="100" style="padding:1px;" /><br/> [Astro](./examples/astro)</a> | <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/examples/cdn/index.html"><img src="https://api.iconify.design/vscode-icons:file-type-html.svg" alt="html logo" width="100" style="padding:1px;" /><br/> [CDN](./examples/cdn/index.html)</a> | <a href="https://github.com/rehype-pretty/rehype-pretty-code/tree/master/examples/next"><img src="https://api.iconify.design/devicon:nextjs.svg" alt="html logo" width="100" style="padding:1px;" /><br/> [Next.js](./examples/next)</a> |
|---|---|---|---|

</div>
26 changes: 19 additions & 7 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://biomejs.dev/schemas/1.7.3/schema.json",
"$schema": "https://biomejs.dev/schemas/1.8.2/schema.json",
"vcs": {
"root": ".",
"enabled": true,
Expand All @@ -21,7 +21,16 @@
"*.astro",
"*.svelte"
],
"ignore": ["node_modules", "dist", "_", ".turbo"],
"ignore": [
"_",
"dist",
".turbo",
"node_modules",
"examples/astro/src/globals.css",
"examples/sveltekit/src/app.css",
"examples/next/src/app/globals.css",
"docs/.vitepress/theme/styles/index.css"
],
"ignoreUnknown": true
},
"organizeImports": {
Expand All @@ -30,11 +39,14 @@
"css": {
"formatter": {
"enabled": true,
"indentWidth": 2,
"lineWidth": 80,
"indentWidth": 2,
"quoteStyle": "double",
"indentStyle": "space"
},
"linter": {
"enabled": true
},
"parser": {
"allowWrongLineComments": true
}
Expand Down Expand Up @@ -71,9 +83,9 @@
"noAccumulatingSpread": "off"
},
"a11y": { "noSvgWithoutTitle": "off" },
"correctness": { "noUndeclaredVariables": "off" },
"nursery": {
"noNodejsModules": "off"
"correctness": {
"noNodejsModules": "off",
"noUndeclaredVariables": "off"
},
"suspicious": {
"useAwait": "off",
Expand Down Expand Up @@ -119,9 +131,9 @@
"indentWidth": 2,
"indentStyle": "space",
"quoteStyle": "single",
"trailingComma": "all",
"semicolons": "always",
"bracketSpacing": true,
"trailingCommas": "all",
"bracketSameLine": false,
"jsxQuoteStyle": "double",
"arrowParentheses": "always",
Expand Down
21 changes: 21 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# build output
dist/
# generated types
.astro/

# dependencies
node_modules/

# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*


# environment variables
.env
.env.production

# macOS-specific files
.DS_Store
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Rehype Pretty Code Documentation
111 changes: 111 additions & 0 deletions docs/astro.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import {
transformerNotationDiff,
transformerNotationFocus,
transformerMetaHighlight,
transformerRenderWhitespace,
transformerNotationHighlight,
transformerMetaWordHighlight,
transformerNotationErrorLevel,
transformerCompactLineOptions,
transformerNotationWordHighlight,
} from '@shikijs/transformers';
import remarkToc from 'remark-toc';
import rehypeSlug from 'rehype-slug';
import tailwind from '@astrojs/tailwind';
import starlight from '@astrojs/starlight';
import { defineConfig } from 'astro/config';
import remarkSmartypants from 'remark-smartypants';
import { rehypePrettyCode } from 'rehype-pretty-code';
import { rehypeHeadingIds } from '@astrojs/markdown-remark';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import { transformerCopyButton } from '@rehype-pretty/transformers';
import { transformerTwoslash, rendererRich } from '@shikijs/twoslash';
import moonlightTheme from './public/theme/moonlight-ii.json' with {
type: 'json',
};

// https://astro.build/config
export default defineConfig({
markdown: {
syntaxHighlight: false,
shikiConfig: {
transformers: [
transformerTwoslash({ renderer: rendererRich() }),
transformerNotationDiff(),
transformerNotationFocus(),
transformerMetaHighlight(),
transformerRenderWhitespace(),
transformerNotationHighlight(),
transformerMetaWordHighlight(),
transformerNotationErrorLevel(),
transformerCompactLineOptions(),
transformerNotationWordHighlight(),
],
},
remarkPlugins: [
// @ts-expect-error
remarkSmartypants,
[remarkToc, { heading: 'contents', prefix: 'toc-' }],
],
rehypePlugins: [
rehypeHeadingIds,
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: 'wrap' }],
[
rehypePrettyCode,
{
keepBackground: true,
theme: moonlightTheme,
transformers: [
transformerCopyButton({
visibility: 'always',
feedbackDuration: 2_500,
}),
],
},
],
rehypeSlug,
],
},
integrations: [
starlight({
expressiveCode: false,
title: 'Rehype Pretty',
favicon: '/favicon.ico',
social: {
github: 'https://github.com/rehype-pretty/rehype-pretty-code',
},
lastUpdated: true,
customCss: [
'./src/styles/index.css',
'./src/styles/tailwind.css',
'@shikijs/twoslash/style-rich.css',
],
plugins: [],
head: [
{
tag: 'script',
attrs: { src: '/scripts/anchor-targets.js' },
},
],
sidebar: [
{
label: 'Rehype Pretty Code',
link: '/',
},
{
label: 'Plugins',
autogenerate: {
directory: 'plugins',
collapsed: false,
},
},
{
label: 'Examples',
link: '/examples',
},
],
}),
tailwind({ applyBaseStyles: false }),
],
});
36 changes: 36 additions & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "docs",
"type": "module",
"version": "0.0.0",
"scripts": {
"dev": "NODE_NO_WARNINGS=1 astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^3.1.2",
"@astrojs/starlight": "^0.24.4",
"@astrojs/starlight-tailwind": "^2.0.3",
"@astrojs/tailwind": "^5.1.0",
"@rehype-pretty/transformers": "workspace:*",
"astro": "^4.11.1",
"rehype-autolink-headings": "^7.1.0",
"rehype-pretty-code": "workspace:*",
"rehype-slug": "^6.0.0",
"rehype-stringify": "^10.0.0",
"remark-toc": "^9.0.0",
"sharp": "^0.33.4",
"shiki": "^1.9.1",
"tailwindcss": "^3.4.4"
},
"devDependencies": {
"@astrojs/check": "^0.7.0",
"@shikijs/transformers": "^1.9.1",
"@shikijs/twoslash": "^1.9.1",
"@total-typescript/ts-reset": "^0.5.1",
"@types/node": "^20.14.9",
"typescript": "^5.5.2"
}
}
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions docs/public/scripts/anchor-targets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Add target="_blank" to all external links
*/

window.addEventListener('DOMContentLoaded', () => {
const externalLinks = document.querySelectorAll('a[href^="http"]');
try {
for (const link of externalLinks) {
link.setAttribute('target', '_blank');
link.setAttribute('rel', 'noopener noreferrer');
}
} catch {
/* empty */
}
});
File renamed without changes.
2 changes: 2 additions & 0 deletions docs/reset.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* https://github.com/total-typescript/ts-reset */
import '@total-typescript/ts-reset/dom';
6 changes: 6 additions & 0 deletions docs/src/content/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { defineCollection } from 'astro:content';
import { docsSchema } from '@astrojs/starlight/schema';

export const collections = {
docs: defineCollection({ schema: docsSchema() }),
};
Loading

0 comments on commit c796c92

Please sign in to comment.