This is an experimental course website for 10.020 Data Driven World module.
You can contribute by forking this repository and creating pull requests 😊
- Clone this project, then
npm install - Afterwards, type
npm start - You can publish this site to github automatically by pushing this to your
masterbranch. See.github/workflows/deploy.ymlaction script - You need to give read and write Action permission in your workflow

- Edit
docusaurus.config.jsaccordingly to use on your site and deploy it on your repo, namely thebaseUrl - The file
src/pages/index.jscontains the homepage. Edit it to your liking.
- The website is built from files in this repo using Github workflows.
- To contribute, fork this repo, then create
docusaurus.local.config.jslocally. This allows you to create a self-hosted site to test any changes. - In
docusaurus.local.config.js, add this:const config = { url: YOUR_NEW_URL, baseUrl: "/2023/", // or your new baseURL organizationName: YOUR_USERNAME, projectName: "2023", // or your new projectName }
- If you want Github Pages to deploy the site for you, do:
git add docusaurus.local.config.js git commit -m 'Local' git push - In Github > Actions, check that the workflow to build is triggered. If it doesn't work, you may need to set the permissions under Actions > General. When successful, Github should create a new branch
gh-pagesfor the built website files and the site should be up at your given URL. - Now we should remove this
'Local'commit to avoid it going into the PR for the upstream repo, but still retaindocusaurus.local.config.jsfor Github Actions. - Add
docusaurus.local.config.jsto.gitignore. Rungit update-index --assume-unchanged .gitignoreto avoid committing the.gitignoreitself. - On your next change, amend the
'Local'commit:git add . git commit --amend -m 'First change' git push --force
- Now, your commit history should not contain
docusaurus.local.config.js, but should have your new changes. Then you can start the pull request.
- If you have admin / sudo rights to your workstation, it could be easier to build the site locally.
- Install Node Version Manager, reopen Terminal and
nvm install 18. Important: you must install Node v18 because v20 breaks Docusaurus! - Clone this project,
cdto the root folder and runnvm install. - Run
npm start. The site should be up.
- The file
src/pages/index.jscontains the homepage. Edit it to your liking. - Add icons to /static/img
- Add setting to the docusaurus search local to include other docs route base path like psets labs etc
- Enable brython
npm i docusaurus-live-brython - Swizzled Admonitions: see
docusaurus.config.js - Custom components: see
src/components
You can generate admonitions using:
:::[keyword]
<your content>
:::
where [keyword] can be any of the following:
keywords: [
"info",
"success",
"danger",
"note",
"tip",
"warning",
"important",
"caution",
"keyword",
"think",
],
Edit /src/theme/Admonition.index.js to add more custom admonition, and add it in docusaurus.config.js.
It's advisable to add custom markdown snippets as follows in your VSCode's markdown.json:
...
"Red block": {
"prefix": "redwords",
"body": [
"<span style={{ \"color\":\"red\", \"fontWeight\": \"bold\" }}>$TM_SELECTED_TEXT$1</span>"
],
"description": "custom redword block"
},
"Image Block React": {
"prefix": "imageblockreact",
"body": [
"<ImageCard path={require(\"./$1\").default} widthPercentage=\"70%$2\"/>"
],
"description": "custom image block in React"
},
"Image Block React With Prefix": {
"prefix": "imageblockreactwithprefix",
"body": [
"<ImageCard path={require(\"./images/$1\").default} widthPercentage=\"70%$2\"/>"
],
"description": "custom image block in React with prefix"
},
"Deep Dive React": {
"prefix": "deepdivereact",
"body": [
"<DeepDive title=\"Show Pseudocode\">\n\n$1\n```\n$2\n```\n\n</DeepDive>\n$3"
],
"description": "custom deepdive block in React"
},
"Front Matter MDX": {
"prefix": "frontmattermdx",
"body": [
"---\nsidebar_position: $1\n---\n\nimport CollapsibleAnswer from '@site/src/components/CollapsibleAnswer';\nimport DeepDive from '@site/src/components/DeepDive';\nimport ImageCard from '@site/src/components/ImageCard';\nimport ChatBaseBubble from \"@site/src/components/ChatBaseBubble\";\n\n$2\n\n<ChatBaseBubble/>\n\n$3"
],
"description": "custom yaml frontmatter block"
},
"Keywords React": {
"prefix": "keywordsreact",
"body": [":::keyword Keywords\n$1\n:::"],
"description": "custom keyword admonition"
},
"Admonitions React": {
"prefix": "admonitionsreact",
"body": [":::$1\n$2\n:::"],
"description": "shortcut admonition"
}
...
Then bind it to a keyboard shortcut in VSCode's keybindings.json:
...
{
"key": "ctrl+alt+e",
"command": "editor.action.insertSnippet",
"args": {
"name": "Image Block React"
},
"when": "editorTextFocus && markdownShortcuts:enabled"
},
{
"key": "ctrl+alt+g",
"command": "editor.action.insertSnippet",
"args": {
"name": "Image Block React With Prefix"
},
"when": "editorTextFocus && markdownShortcuts:enabled"
},
{
"key": "ctrl+alt+d",
"command": "editor.action.insertSnippet",
"args": {
"name": "Deep Dive React"
},
"when": "editorTextFocus && markdownShortcuts:enabled"
},
{
"key": "ctrl+alt+f",
"command": "editor.action.insertSnippet",
"args": {
"name": "Front Matter MDX"
},
"when": "editorTextFocus && markdownShortcuts:enabled"
},
{
"key": "ctrl+alt+o",
"command": "editor.action.insertSnippet",
"args": {
"name": "Keywords React"
},
"when": "editorTextFocus && markdownShortcuts:enabled"
},
...
Images should be placed in the same directory as the markdown file, inside /images folder. See /docs for reference.
VSCode extension: mushan.vscode-paste-image is immensely useful. You can install it from here.
You can then bind it to some key to paste image on your clipboard:
{
"key": "ctrl+alt+v",
"command": "extension.pasteImage",
"when": "editorTextFocus"
},
Then set the extension settings as follows:
This way, the extension is going to paste simply the path from current working directory, like /images/bfs/2023-07-13-10-58-22.png into ImageBlock component.
Lecture notes goes to docs folder by default. But, you can create new folder in the root, such as projects, labs, etc. First, create an entry point: intro.md (or any other name, just match it when declaring it in docusaurus config later) inside the new folder.
Now update docusaurus.config.js.
Step 1: register it under @docusaurus/plugin-content-docs:
plugins: [
[
"@docusaurus/plugin-content-docs",
{
id: "projects",
path: "projects",
routeBasePath: "projects",
sidebarPath: require.resolve("./sidebars.js"),
},
],
[
"@docusaurus/plugin-content-docs",
{
id: "your-folder-name",
path: "your-folder-name",
routeBasePath: "your-folder-name",
sidebarPath: require.resolve("./sidebars.js"),
},
],
Step 2: under themes, register it as docsRouteBasePath:
themes: [
[
require.resolve("@easyops-cn/docusaurus-search-local"),
{
docsRouteBasePath: ["projects", "notes", "about", "your-folder-name..."],
},
],
Step 3: update the navbar to include your new folder:
navbar: {
hideOnScroll: true,
title: "10.020",
logo: {
alt: "DDW Logo",
src: "img/home-logo.svg",
},
items: [
{
type: "search",
position: "right",
},
{
to: "/about/intro",
label: "About",
position: "left",
activeBaseRegex: `/about/`,
},
{
to: "/your-folder-name/intro",
label: "Navbar-Label",
position: "left",
activeBaseRegex: `/your-folder-name/`,
},
...
]
...
}

