Skip to content

Commit

Permalink
docs: update docs & typo
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyuweitarek committed Oct 28, 2024
1 parent 4bdc4a6 commit 30af2c5
Show file tree
Hide file tree
Showing 10 changed files with 405 additions and 70 deletions.
60 changes: 36 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,46 +5,58 @@ This repository contains source code of the Tarek's personal website, which is b
> [!IMPORTANT]
> This website originally comes from [Paweł Kosiec's awesome personal website](https://github.com/pkosiec/website). You can read more details in Paweł Kosiec's README. Appreciate his kind sharing and contribution!
## Installation
### Prerequisites

Choose one of the following:
1. Clone the repository

- Install on your computer using [npm](https://docs.npmjs.com/cli/install):
2. Install Docker and Docker Compose

```bash
$ npm install
```
Please ensure that your device has successfully installed [Docker Desktop](https://www.docker.com/products/docker-desktop) or runnable [Docker Engine](https://docs.docker.com/engine/install/), and that your environment supports the `docker compose` command.

- Install with Docker, and develop in container:
```bash
$ docker --version
Docker version 26.1.1, build 4cf5afa

$ docker compose version
Docker Compose version v2.27.0-desktop.2
```

You can find more details in the [Dev-Guide](./docs/Dev-Guide/index.mdx).
### Development

- On local machine
1. Launch the dev container

```bash
$ docker compose --profile dev up --build -d
$ docker compose --profile dev up -d
```

- Attach on container, in container terminal
2. Access container shell

```bash
$ npm install
```
$ docker exec -it dev-web /bin/bash
### Local Development
# Output
root@ae3a7ef54878:/opt/website
```

Run following command in the terminal, based on the environment you choose, local machine or container:
3. Run the website in the container shell:

```
$ npm start
```
```bash
$ npm start
```
You can see the website in the browser with the address. `http://localhost:3006`.

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
4. View production build locally with:

### Build
**Build the website:**

```
$ npm run build
```

**Check website just built in `./build`**

```
$ npm run build
```
```bash
$ npm run serve -- --host 0.0.0.0 --port 3006 --no-open
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.
5. Renew Algolia DocSearch Index. See more in [dev-guide documents](./docs/Dev-Guide/renew-algolia-docsearch-index.mdx).
4 changes: 2 additions & 2 deletions algolia/dev-algolia-config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"index_name": "dev_personal_website",
"start_urls": ["https://1f2e-42-73-214-202.ngrok-free.app"],
"sitemap_urls": ["https://1f2e-42-73-214-202.ngrok-free.app/sitemap.xml"],
"start_urls": ["https://d63d-36-226-104-66.ngrok-free.app"],
"sitemap_urls": ["https://d63d-36-226-104-66.ngrok-free.app/sitemap.xml"],
"sitemap_alternate_links": true,
"stop_urls": ["/tests"],
"selectors": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
id: experiment-tips-reproducibility-and-randomness
title: "Experiment Tips: Reproducibility and Randomness"
title: "Experiment Tips - Reproducibility and Randomness"
hide_title: true
sidebar_position: 4
tags: ["pytorch", "computer-science"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: simulate-a-neuron-with-pytorch
title: Simulate a neuron with PyTorch
hide_title: true
sidebar_position: 3
tags: ["pytorch", "implementation", "deep-learning", "computer-science"]
tags: ["pytorch", "deep-learning", "implementation", "computer-science"]
draft: false
last_update:
date: 12/2/2022
Expand Down
195 changes: 195 additions & 0 deletions docs/Dev-Guide/add-new-category.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---
id: add-new-category
title: Add a new category
hide_title: true
sidebar_position: 3
tags: ["dev-guide"]
last_update:
date: 10/24/2024
author: Tarek Liu
unlisted: true
---

:::warning
Watch out naming format!

If new category named \"New Category\", then:

- \<new-category-folder-name\>: \"NewCategory\"
- \<new-category-tag\>: \"new-category\"
- \<new-category-tag-brief\>: \"nc\"
- \<new-category-tag-label\>: \"New Category\"
:::

1. Create a new folder under `docs` folder, like `docs/NewCategory`.

2. Add a category tag in `docs/tags.yml` file.

- Make sure the tag name is not duplicated.

- Tag name should be lowercase and separated by `-`.

e.g. ComputerScience => computer-science

3. Make new category be searchable in "Category Search Page".

- Edit `src\data\notes.tsx` and register your note into object.

1. Add tag

```
export type TagType =
(Add new category tags here)
| <new-category-tag-name>
```
2. Edit tag info
```
export const Tags: { [type in TagType]: Tag } = {
<new-category-tag-name>: {
label: translate({ message: "<new-category-tag-label>" }),
description: translate({
message: "<new-category-tag-description>",
id: "tagsearch.tag.<new-category-tag-name>.description",
}),
color: "<new-category-tag-color>", -> hex code
},
};
```
4. Add new category `index.mdx` in `docs/<NewCategory>` folder.
**`index.mdx`**
```
---
id: <new-category-tag>
title: <new-category-tag-label>
tags: ["manual", <new-category-tag-label>]
hide_title: true
hide_table_of_contents: true
displayed_sidebar: <new-category-tag-brief>Sidebar
sidebar_position: 2 -> Check current sidebar position
last_update:
date: 6/24/2024 -> MM/DD/YYYY, Check current date
author: Tarek Liu -> Your name
---
import TagSearchNotes from "@site/src/components/tagsearch/index";
<TagSearchNotes
title="<new-category-tag-label>"
description="<new-category-tag-description>"
/>
```
5. Add new category's sidebar in `sidebars.js`.
New category's sidebar name is `<new-category-tag-brief>Sidebar`, e.g. `ncSidebar`. Items obj name would be like `ncItems`.
- Add new category into home sidebar
**`sidebars.js`**
```
const homeItems = [
{
type: 'category',
label: '<new-category-tag-label>',
className: '<new-category-tag>',
link: {
type: 'generated-index',
slug: '<new-category-tag-folder-name>?tags=<new-category-tag>&operator=AND',
},
collapsed: true,
items: [
{
type: "autogenerated",
dirName: "<new-category-tag-folder-name>",
}
],
},
]
```
- Add new category into note category sidebar
**`sidebars.js`**
```
const ncItems = [
{
type: 'link',
href: '/docs/note',
label: 'Back to Home',
},
{
type: 'link',
href: '/docs/<new-category-tag-folder-name>?tags=<new-category-tag>&operator=AND',
label: 'Search',
},
{
type: "autogenerated",
dirName: "<new-category-tag-folder-name>"
}
]
```
```
const sidebars = {
homeSidebar: homeItems,
ncSidebar: ncItems --> Edit here!
};
```
6. (Optional) Customize `autogenerated` sidebar items
At **`docusaurus.config.ts`**
```
presets: [
[
{
docs: {
sidebarItemsGenerator: async function sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
const sidebarItems = await defaultSidebarItemsGenerator(args);
return skipIndex(sidebarItems);
},
}
}
]
]
```
Function `skipIndex` controls whether to skip some pages.
```
const skipRenderNoteIDs = [
"Psychology/psychology",
"ComputerScience/computer-science",
]
const retainLabels = [
"Search",
"Back to Home"
];
function skipIndex(items) {
if (typeof items !== "undefined"){
return items.filter(({ type, id, label }) => {
return (type === 'doc' && !skipRenderNoteIDs.includes(id))
|| retainLabels.includes(label);
});
}
return [];
}
```
Loading

0 comments on commit 30af2c5

Please sign in to comment.