-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
87 changed files
with
62,587 additions
and
27,424 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 |
---|---|---|
@@ -1,10 +1,20 @@ | ||
# twoslash | ||
You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible code samples | ||
|
||
You take some Shiki, add a hint of TypeScript compiler, and 🎉 incredible statically generated code samples for describing code. | ||
|
||
<center><img src="./misc/repo-icon.png" /></center> | ||
|
||
### This Repo | ||
|
||
This repo uses **npm workspaces - you need `[email protected]` or above** | ||
This repo uses **npm workspaces - you need `[email protected]` or above**. There are three main areas: | ||
|
||
- `packages`, the shiki meets twoslash plugins for markdown renderers and static site generators | ||
- `site`, the docs micro-site | ||
- `examples`, example static site generator projects which use the plugins | ||
|
||
The `site` and `examples` are excluded from the workspace. To work on those, `cd` to their folders and read instructions. | ||
|
||
Otherwise: | ||
|
||
```sh | ||
git clone https://github.com/shiki/twoslash | ||
|
@@ -13,4 +23,10 @@ cd twoslash | |
npm i | ||
npm build | ||
npm test | ||
``` | ||
``` | ||
|
||
### TODO | ||
|
||
- Finish design on microsite | ||
- Website | ||
- Docusaurus support is broken |
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,3 @@ | ||
### Examples | ||
|
||
All these use `yarn` because I'm lazy and yarn is a good default. |
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 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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,33 @@ | ||
# Website | ||
|
||
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. | ||
|
||
## Installation | ||
|
||
```console | ||
yarn install | ||
``` | ||
|
||
## Local Development | ||
|
||
```console | ||
yarn start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
## Build | ||
|
||
```console | ||
yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
## Deployment | ||
|
||
```console | ||
GIT_USER=<Your GitHub username> USE_SSH=true yarn deploy | ||
``` | ||
|
||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. |
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,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
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,17 @@ | ||
--- | ||
slug: hola | ||
title: A post with twoslash | ||
author: Gao Wei | ||
author_title: Docusaurus Core Team | ||
author_url: https://github.com/wgao19 | ||
author_image_url: https://avatars1.githubusercontent.com/u/2055384?v=4 | ||
tags: [hola, docusaurus] | ||
--- | ||
|
||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet | ||
|
||
```ts twoslash | ||
const a = 123 | ||
// ---cut--- | ||
const b = 321 | ||
``` |
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,12 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# An example twoslash | ||
|
||
```ts twoslash | ||
const a = 123 | ||
const b = "OK" | ||
// ---cut--- | ||
console.log(b) | ||
``` |
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,104 @@ | ||
/** @type {import('@docusaurus/types').DocusaurusConfig} */ | ||
module.exports = { | ||
title: 'My Site', | ||
tagline: 'Dinosaurs are cool', | ||
url: 'https://your-docusaurus-test-site.com', | ||
baseUrl: '/', | ||
onBrokenLinks: 'throw', | ||
onBrokenMarkdownLinks: 'warn', | ||
favicon: 'img/favicon.ico', | ||
organizationName: 'facebook', // Usually your GitHub org/user name. | ||
projectName: 'docusaurus', // Usually your repo name. | ||
themeConfig: { | ||
navbar: { | ||
title: 'My Site', | ||
logo: { | ||
alt: 'My Site Logo', | ||
src: 'img/logo.svg', | ||
}, | ||
items: [ | ||
{ | ||
type: 'doc', | ||
docId: 'intro', | ||
position: 'left', | ||
label: 'Tutorial', | ||
}, | ||
{to: '/blog', label: 'Blog', position: 'left'}, | ||
{ | ||
href: 'https://github.com/facebook/docusaurus', | ||
label: 'GitHub', | ||
position: 'right', | ||
}, | ||
], | ||
}, | ||
footer: { | ||
style: 'dark', | ||
links: [ | ||
{ | ||
title: 'Docs', | ||
items: [ | ||
{ | ||
label: 'Tutorial', | ||
to: '/docs/intro', | ||
}, | ||
], | ||
}, | ||
{ | ||
title: 'Community', | ||
items: [ | ||
{ | ||
label: 'Stack Overflow', | ||
href: 'https://stackoverflow.com/questions/tagged/docusaurus', | ||
}, | ||
{ | ||
label: 'Discord', | ||
href: 'https://discordapp.com/invite/docusaurus', | ||
}, | ||
{ | ||
label: 'Twitter', | ||
href: 'https://twitter.com/docusaurus', | ||
}, | ||
], | ||
}, | ||
{ | ||
title: 'More', | ||
items: [ | ||
{ | ||
label: 'Blog', | ||
to: '/blog', | ||
}, | ||
{ | ||
label: 'GitHub', | ||
href: 'https://github.com/facebook/docusaurus', | ||
}, | ||
], | ||
}, | ||
], | ||
copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`, | ||
}, | ||
}, | ||
presets: [ | ||
[ | ||
'@docusaurus/preset-classic', | ||
{ | ||
|
||
docs: { | ||
sidebarPath: require.resolve('./sidebars.js'), | ||
// Please change this to your repo. | ||
editUrl: | ||
'https://github.com/facebook/docusaurus/edit/master/website/', | ||
}, | ||
blog: { | ||
showReadingTime: true, | ||
// Please change this to your repo. | ||
editUrl: | ||
'https://github.com/facebook/docusaurus/edit/master/website/blog/', | ||
}, | ||
theme: { | ||
customCss: require.resolve('./src/css/custom.css'), | ||
}, | ||
}, | ||
], | ||
["docusaurus-preset-shiki-twoslash", { theme: "nord" }] | ||
], | ||
}; |
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,40 @@ | ||
{ | ||
"name": "docusaurus-example", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"docusaurus": "docusaurus", | ||
"start": "docusaurus start", | ||
"build": "docusaurus build", | ||
"swizzle": "docusaurus swizzle", | ||
"deploy": "docusaurus deploy", | ||
"clear": "docusaurus clear", | ||
"serve": "docusaurus serve", | ||
"write-translations": "docusaurus write-translations", | ||
"write-heading-ids": "docusaurus write-heading-ids" | ||
}, | ||
"dependencies": { | ||
"@docusaurus/core": "2.0.0-beta.0", | ||
"@docusaurus/preset-classic": "2.0.0-beta.0", | ||
"@mdx-js/react": "^1.6.21", | ||
"@svgr/webpack": "^5.5.0", | ||
"clsx": "^1.1.1", | ||
"docusaurus-preset-shiki-twoslash": "file:../../packages/docusaurus-preset-shiki-twoslash", | ||
"file-loader": "^6.2.0", | ||
"react": "^17.0.1", | ||
"react-dom": "^17.0.1", | ||
"url-loader": "^4.1.1" | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.5%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
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,4 @@ | ||
module.exports = { | ||
// By default, Docusaurus generates a sidebar from the docs folder structure | ||
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], | ||
}; |
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,64 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import styles from './HomepageFeatures.module.css'; | ||
|
||
const FeatureList = [ | ||
{ | ||
title: 'Easy to Use', | ||
Svg: require('../../static/img/undraw_docusaurus_mountain.svg').default, | ||
description: ( | ||
<> | ||
Docusaurus was designed from the ground up to be easily installed and | ||
used to get your website up and running quickly. | ||
</> | ||
), | ||
}, | ||
{ | ||
title: 'Focus on What Matters', | ||
Svg: require('../../static/img/undraw_docusaurus_tree.svg').default, | ||
description: ( | ||
<> | ||
Docusaurus lets you focus on your docs, and we'll do the chores. Go | ||
ahead and move your docs into the <code>docs</code> directory. | ||
</> | ||
), | ||
}, | ||
{ | ||
title: 'Powered by React', | ||
Svg: require('../../static/img/undraw_docusaurus_react.svg').default, | ||
description: ( | ||
<> | ||
Extend or customize your website layout by reusing React. Docusaurus can | ||
be extended while reusing the same header and footer. | ||
</> | ||
), | ||
}, | ||
]; | ||
|
||
function Feature({Svg, title, description}) { | ||
return ( | ||
<div className={clsx('col col--4')}> | ||
<div className="text--center"> | ||
<Svg className={styles.featureSvg} alt={title} /> | ||
</div> | ||
<div className="text--center padding-horiz--md"> | ||
<h3>{title}</h3> | ||
<p>{description}</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default function HomepageFeatures() { | ||
return ( | ||
<section className={styles.features}> | ||
<div className="container"> | ||
<div className="row"> | ||
{FeatureList.map((props, idx) => ( | ||
<Feature key={idx} {...props} /> | ||
))} | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
} |
13 changes: 13 additions & 0 deletions
13
examples/docusaurus/src/components/HomepageFeatures.module.css
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,13 @@ | ||
/* stylelint-disable docusaurus/copyright-header */ | ||
|
||
.features { | ||
display: flex; | ||
align-items: center; | ||
padding: 2rem 0; | ||
width: 100%; | ||
} | ||
|
||
.featureSvg { | ||
height: 200px; | ||
width: 200px; | ||
} |
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,29 @@ | ||
/* stylelint-disable docusaurus/copyright-header */ | ||
/** | ||
* Any CSS included here will be global. The classic template | ||
* bundles Infima by default. Infima is a CSS framework designed to | ||
* work well for content-centric websites. | ||
*/ | ||
|
||
/* You can override the default Infima variables here. */ | ||
:root { | ||
--ifm-color-primary: #25c2a0; | ||
--ifm-color-primary-dark: rgb(33, 175, 144); | ||
--ifm-color-primary-darker: rgb(31, 165, 136); | ||
--ifm-color-primary-darkest: rgb(26, 136, 112); | ||
--ifm-color-primary-light: rgb(70, 203, 174); | ||
--ifm-color-primary-lighter: rgb(102, 212, 189); | ||
--ifm-color-primary-lightest: rgb(146, 224, 208); | ||
--ifm-code-font-size: 95%; | ||
} | ||
|
||
.docusaurus-highlight-code-line { | ||
background-color: rgb(72, 77, 91); | ||
display: block; | ||
margin: 0 calc(-1 * var(--ifm-pre-padding)); | ||
padding: 0 var(--ifm-pre-padding); | ||
} | ||
|
||
body { | ||
color: red; | ||
} |
Oops, something went wrong.