Skip to content

Commit

Permalink
Rewrite the docs site to use Astro instead of NextJS
Browse files Browse the repository at this point in the history
This commit also does the following:
- Removes ads
- Adds search
- Adds a new JSON based documentation system
- Removes translations
  • Loading branch information
jaredlll08 committed Jan 6, 2025
1 parent 6968c57 commit 1a217da
Show file tree
Hide file tree
Showing 184 changed files with 15,833 additions and 6,782 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
CROWDIN_TOKEN=
CROWDIN_PROJECT_ID=
TYPESENSE_API_KEY=
17 changes: 0 additions & 17 deletions .eslintrc

This file was deleted.

Binary file removed .github/question.png
Binary file not shown.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build/
translations/en/

# dependencies
/node_modules
node_modules
/.pnp
.pnp.js

Expand All @@ -26,4 +26,5 @@ yarn-error.log*

docs_reverse_lookup.json
.vscode/
.env
.env
dist
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
save-prefix=""
link-workspace-packages=false
save-workspace-protocol=rolling
45 changes: 0 additions & 45 deletions Custom Markdown.md

This file was deleted.

29 changes: 15 additions & 14 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,37 @@
pipeline {
agent any
environment {
CROWDIN_TOKEN = credentials('crowdin-token')
CROWDIN_PROJECT_ID = credentials('crowdin-project-id')
}
TYPESENSE_API_KEY = credentials('TYPESENSE_API_KEY')
}
stages {
stage('Setup') {
steps {
echo 'Setting up npm'
sh 'npm ci'
sh 'cd site && npm ci'
echo 'Setting up pnpm'
sh 'pnpm i'
}
}
stage('Build Docs') {
steps {
echo 'Building docs'
sh 'pnpm build'
}
}
stage('Build') {
stage('Build Site') {
steps {
echo 'Building files'
sh 'npm run-script build'
echo 'Building site'
sh 'pnpm site-build'
}
}
stage('Deploy') {
steps {
echo 'Deploying docker container'
echo 'Deploying files to folder'
dir('site') {
sh "docker-compose up -d --build"
sh "cp -r dist/* /opt/crafttweaker_docs/"
}
}
}
}
options {
disableConcurrentBuilds()
}
triggers {
cron('0 */24 * * *')
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Jared
Copyright (c) 2025 Jared

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
182 changes: 166 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,183 @@
# CraftTweaker-Documentation
Documentation for CraftTweaker

This is the source code for the documentation, you can find the actual site and documentation [here](http://docs.blamejared.com)
This repository contains the documentation for [CraftTweaker](https://github.com/CraftTweaker/CraftTweaker), a Minecraft mod that allows you to customize the game using a scripting language.

This repository is not meant to be used to view the documentation, instead you should visit [docs.blamejared.com](http://docs.blamejared.com).

### Setup:
## Setup:

Requires [npm and nodejs](https://nodejs.org/download/release/v16.18.1/)
Both node and pnpm are required to build the project.
```shell
node: "^>=18.17.1"
pnpm: "^9.12.1"
```

Clone the repository locally and install the dependencies.
```shell
git clone https://github.com/CraftTweaker/CraftTweaker-Documentation
pnpm install
```

This project uses pnpm workspaces, so you should **always run `pnpm install` from the top-level project directory**. Running `pnpm install` in the top-level project root will install dependencies for every package in the repo.

## Project Structure

```text
/
│ 🛈 Contains handwritten documentation files
├── docs/
│ │ 🛈 Contains the versions index, used to define versions and group them on the website.
│ ├── versions.json
│ │ 🛈 Contains the handwritten documentation files for a specific version.
│ └── <version>/
│ │ 🛈 Contains the sidebar structure for the documentation.
│ └── docs.json
│ 🛈 Contains auto-generated documentation files.
├── docs_exported/
│ │ 🛈 Contains the auto-generated documentation files for a specific version.
│ └── <version>/
│ │ 🛈 Contains the auto-generated documentation files for a specific mod.
│ └── <mod>/
│ 🛈 Contains the TypeScript projects that handle building and processing the documentation files into a website.
└── packages/
│ 🛈 Handles merging, processing and exporting the documentation files before they are built into a website.
├── docs-build/
│ 🛈 Contains the model for the json based documentation files, and general utilities used throughout the project.
├── docs-model/
│ 🛈 Handles generating TypeSense search indexes for the website.
├── docs-search/
│ 🛈 Astro based documentation website
├── docs-site/
│ 🛈 Expressive-Code plugin to put a "copy" button in the title of the frame
├── ec-copy-in-frame/
│ 🛈 Expressive-Code plugin to set the default frame title based on the language.
├── ec-default-frame-title/
│ 🛈 Expressive-Code plugin to generate rich example comments.
├── ec-example-comment/
│ 🛈 Expressive-Code plugin to override the language of a code block.
├── ec-language-override/
│ 🛈 Expressive-Code plugin to put rainbow brackets in the code blocks.
├── ec-rainbow-brackets/
│ 🛈 Remark plugin to inject the game version into links.
├── remark-inject-url-version/
│ 🛈 Remark-Rehype plugin that provides renderers for custom markdown directives.
├── remark-rehype-renderers/
│ 🛈 Remark plugin to generate searchable terms for the search index.
├── remark-search/
│ 🛈 Remark plugin to convert tables to responsive html
└── remark-table/
```

## Contributing Documentation

Handwritten documentation files are stored in the `docs` folder. Each version has its own folder, and each folder contains a `docs.json` file that defines the structure of the documentation for that version.

### Adding or Removing Files
If you add or remove a file, please make sure to update the `docs.json` file.

### Previewing Your Changes

To preview your changes as you are working on them, you should first build the documentation files and then start the website.

```shell
pnpm build
pnpm site-dev
```
git submodule init
git submodule update
npm install
cd site/
npm install

You can then navigate to `http://localhost:4321` in your browser to preview the website.

Once the website is running, you can make changes to the files in `./packages/docs-site/src/docs/`. The website will automatically reload when you save a file.
When you are done making changes to the files, you can copy the files you changed back to the top level `./docs` folder.

This process is a bit cumbersome, but right now, it is the best way to preview your changes as you are working on them. We are open to suggestions on how to improve this process.

### Custom Markdown Directives

While most of the docs are written in GitHub Flavoured Markdown, we use the [Remark-Directive](https://github.com/remarkjs/remark-directive) plugin to create some elements that stand out and help the user.

#### Required Mods

To show that a mod is required for certain pages, we use the following syntax:

```markdown
::requiredMod[Create]{builtIn=false modLink=https://www.curseforge.com/minecraft/mc-mods/create requiredMod=CreateTweaker requiredModLink=https://www.curseforge.com/minecraft/mc-mods/createtweaker}

::requiredMod[Immersive Engineering]{builtIn=true}
```

### Build
`builtIn` defines whether the support is added by the mod in question (Like Thermal Series having the support be in their mod), or if an addon mod is required (Like CreateTweaker being required to add support for Create).

`modLink` is a link to the mod's project page.

`requiredMod` is the display name of the required addon.

`requiredModLink` is the link to the required addon's project page.

When rendered on the actual site, this turns into:
![required mods](.github/requiredMod.png)

#### Groups

To group a section of a page together, allowing for it to be collapsed, you can use the following syntax:

```markdown
:::group{name=groupName}
Content
:::
```
npm run build
or
```markdown
:::group{name="Group Name"}
Content
:::
```

### View Results
`name` is the name of the group.

When rendered on the actual site, this turns into:
![groups](.github/group.png)

### Adding a New Version
**This is currently not implemented, to make a new version, copy the files from an older version folder, and update the versions.json file manually**

To add a new version to the site, simply run the following command:

```shell
pnpm new-version
```
cd site
npm run dev
and follow the prompts.

Once the files have been created, please go through and update any version numbers in the new files as needed, and remove any files that are no longer needed.

### Auto-Generated Documentation

The auto-generated documentation files are stored in the `docs_exported` folder. These files are generated by the [CraftTweaker-Annotation-Processors](https://github.com/CraftTweaker/CraftTweaker-Annotation-Processors) project and can be overwritten at random.

If you find an issue with the auto-generated documentation, it needs to be fixed in the java code of the project that has the issue, fixing it on this repository will only be a temporary fix until the next time the auto-generated documentation is updated.

Please see the [CraftTweaker-Annotation-Processors readme file](https://github.com/CraftTweaker/CraftTweaker-Annotation-Processors/blob/main/README.md) on how to set it up for your project.

## Build

The project can be built using the following commands:
```shell
pnpm build
pnpm site-build
```

Look at the url that appears on your console, should contain `localhost`, paste that on the browser.
Ctrl C twice will stop the execution.
The output will be in the `./dist` folder and can be served using any static file server such as nginx.

## Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
|:-----------------------|:----------------------------------------------|
| `pnpm install` | Installs dependencies |
| `pnpm site-dev` | Runs the site in dev mode at `localhost:4321` |
| `pnpm site-build` | Builds the site |
| `pnpm site-preview` | Previews the built site |
| `pnpm site-full` | Builds and previews the site |
| `pnpm search-generate` | Generates the TypeSense search index |
| `pnpm build` | Builds the documentation files |
| `pnpm build-full` | Builds the documentation files and the site |
33 changes: 33 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
"vcs": {
"enabled": false,
"clientKind": "git",
"useIgnoreFile": false
},
"files": {
"ignoreUnknown": false,
"ignore": ["./docs", "./docs_exported", "./packages/*/dist", "dist", "build", "./packages/docs-site/src/docs", "./packages/docs-site/public/**/*"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"formatWithErrors": true
},
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always"
}
}
}
Loading

0 comments on commit 1a217da

Please sign in to comment.