Skip to content

Commit

Permalink
docs: migrate docs from website
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsocha committed Nov 20, 2023
1 parent 675fb09 commit 918795e
Show file tree
Hide file tree
Showing 25 changed files with 2,100 additions and 1 deletion.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ dist/
**/build/
.gradle/
run/
node_modules/
12 changes: 11 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Build with Docker
- name: Build docs
run: cd docs && ./build.sh

- name: Deploy docs
#if: github.ref == 'refs/heads/master'
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: docs/dist

- name: Build mod
run: ./build.sh


- name: Set deployment variables
id: variables
uses: actions/[email protected]
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ run/
tools/.cached-pages/
tools/.debug/
.env
node_modules/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Originally created in 2015, the Lucky Block is a mod for Minecraft which has sin
<img src="img/luckyblock_3d.png" width="180px" align="right" vspace="20px">

- [Download Lucky Block](https://www.curseforge.com/minecraft/mc-mods/lucky-block)
- [Docs](https://alexsocha.github.io/luckyblock)
- [Minecraft Forum](https://www.minecraftforum.net/forums/mapping-and-modding-java-edition/minecraft-mods/1292247-lucky-block-mod-drops-items-spawns-mobs-structures)
- [Planet Minecraft](https://www.planetminecraft.com/mod/lucky-block/)

Expand Down
8 changes: 8 additions & 0 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:10-alpine as build
WORKDIR /app

COPY package*.json .
RUN npm ci

COPY . .
RUN npm run build
3 changes: 3 additions & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
docker build . -t luckyblock-docs
container_id=$(docker create luckyblock-docs)
docker cp $container_id:/app/dist/. ./dist/
51 changes: 51 additions & 0 deletions docs/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import * as R from 'ramda';
import * as glob from 'glob';
import * as fs from 'fs';
import * as path from 'path';
import * as mkdirp from 'mkdirp';
import * as jsyaml from 'js-yaml';
import * as handlebars from 'handlebars';
import { promisify } from 'util';

const baseDir = __dirname;
const distDir = path.join(__dirname, 'dist');
const globAsync = promisify(glob);

const readData = async (): Promise<{}> => {
return await R.reduce(
async (acc, filePath) => {
const contents = await fs.promises.readFile(filePath, 'utf-8');
const data = jsyaml.safeLoad(contents) as object;
return { ...(await acc), ...data };
},
{},
await globAsync(path.join(baseDir, 'src/data/*.yaml'))
);
};

const render = async () => {
const hbs = handlebars.create();

// read yaml data
const data = await readData();

// register partials
await R.forEach(async (filePath) => {
const fileName = path.basename(filePath, '.html');
hbs.registerPartial(fileName, await fs.promises.readFile(filePath, 'utf-8'));
}, await globAsync(path.join(baseDir, 'src/partials/*.html')));

// render handlebars templates
await R.forEach(async (filePath) => {
const contents = await fs.promises.readFile(filePath, 'utf-8');
const rendered = hbs.compile(contents)(data);

const distFilePath = path.join(distDir, path.relative('src', filePath));
await mkdirp(path.dirname(distFilePath));
await fs.promises.writeFile(distFilePath, rendered, 'utf-8');
}, await globAsync(path.join(baseDir, 'src/*.md')));

await fs.promises.copyFile('src/index.html', path.join(distDir, 'index.html'))
};

render();
Loading

0 comments on commit 918795e

Please sign in to comment.