Skip to content

Commit

Permalink
Merge pull request #568 from holistics/upgrade/homepage-to-docusaurus
Browse files Browse the repository at this point in the history
Docs - Migrate dbml homepage to docusaurus
  • Loading branch information
huyleminh01 authored May 6, 2024
2 parents 57885a9 + f357384 commit 2e479bb
Show file tree
Hide file tree
Showing 27 changed files with 10,547 additions and 24 deletions.
46 changes: 23 additions & 23 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
name: build docs
name: Build DBML docs

on:
push:
branches: [ master ]
paths:
- 'dbml-homepage/**'
pull_request:
branches: [ master ]
types: [opened, synchronize]
branches:
- master
paths:
- 'dbml-homepage/**'
- 'dbml-docs/**'

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-22.04
defaults:
run:
working-directory: dbml-homepage

strategy:
matrix:
node-version: [16.x]
working-directory: dbml-docs

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build docs page
run: yarn build
- name: Checkout source code
uses: actions/checkout@v4

- name: Setup Node environment
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: yarn
cache-dependency-path: ./dbml-docs/yarn.lock

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build source code
run: yarn build
54 changes: 54 additions & 0 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Deploy DBML docs to Github Pages

on: workflow_dispatch

jobs:
build:
name: Build Docusaurus
runs-on: ubuntu-22.04
defaults:
run:
working-directory: dbml-docs

steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Setup Node environment
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: yarn
cache-dependency-path: ./dbml-docs/yarn.lock

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build source code
run: yarn build

- name: Upload build artifact
uses: actions/upload-pages-artifact@v3
with:
path: dbml-docs/build

deploy:
name: Deploy to GitHub Pages
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

runs-on: ubuntu-22.04

steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: CI
name: Run packages unit test
on:
push:
branches: [ master ]
paths-ignore:
- 'dbml-homepage/**'
- 'dbml-docs/**'
pull_request:
branches: [ master ]
types: [opened, synchronize]
paths-ignore:
- 'dbml-homepage/**'
- 'dbml-docs/**'
jobs:
build:
runs-on: ubuntu-22.04
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ Example of a database definition of a simple blogging site:
* [d365fo-entity-schema: Generate DBML from Dynamics 365 Finance and Operations ](https://github.com/noakesey/d365fo-entity-schema)
* [DB2Code: Generate DBML from Maven](https://github.com/alberlau/DB2Code)
* [dbml-java: A DBML parser written on Java 17 by Nils Wende](https://github.com/nilswende/dbml-java)
* [SchemaToDbml: A gem that generates DBML from Rails schema.rb by Ricardo Ribeiro](https://github.com/ricardojcribeiro/schema_to_dbml)
* [Snowflake DBML Generator by Ryan Rozich](https://github.com/ryanrozich/snowflake-dbml-generator)
22 changes: 22 additions & 0 deletions dbml-docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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*

.vercel
6 changes: 6 additions & 0 deletions dbml-docs/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.docusaurus
node_modules/
static/
*.json
*.md
.prettierrc
25 changes: 25 additions & 0 deletions dbml-docs/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"arrowParens": "always",
"printWidth": 120,
"semi": true,
"singleAttributePerLine": false,
"singleQuote": true,
"trailingComma": "es5",
"useTabs": false,
"tabWidth": 2,
"overrides": [
{
"files": "*.css",
"options": {
"parser": "css"
}
},
{
"files": "*.scss",
"options": {
"parser": "scss"
}
}
],
"endOfLine": "lf"
}
55 changes: 55 additions & 0 deletions dbml-docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# DBML Docs

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

### Installation

```bash
yarn
```

### Local Development

```bash
yarn dev
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Commit

Before commit your code, please run this command to make the code prettier.

```bash
yarn format
```

### Build

```bash
yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Preview local build

Please ensure you run the build command before running the following command

```bash
yarn serve
```

### Deployment

This page is deployed to Github Pages.

To deploy this site, please manually trigger ***Deploy DBML docs to Github Pages*** action.

For more details, please read [Manually running a workflow](https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow).

### Document searching function

We are currently using [docusaurus-lunr-search](https://www.npmjs.com/package/docusaurus-lunr-search) package.

This package only works on production environment, so if you want to test this feature, please serve the application on your local machine. Refer to the ***Preview local build*** section.
3 changes: 3 additions & 0 deletions dbml-docs/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
46 changes: 46 additions & 0 deletions dbml-docs/configs/navbar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Navbar } from '@docusaurus/theme-common';

const NavbarConfigs: Navbar = {
title: 'DBML',
hideOnScroll: false,
logo: {
alt: 'DBML logo',
src: 'img/dbml-logo.png',
},
items: [
{
type: 'docSidebar',
sidebarId: 'docs',
position: 'left',
label: 'Docs',
},
{
type: 'dropdown',
label: 'dbx',
position: 'right',
className: 'dbx-dropdown',
items: [
{
label: 'dbdiagram - Database Diagram As Code',
href: 'https://dbdiagram.io/?utm_source=dbml',
},
{
label: 'dbdocs - Database Docs As Code',
href: 'https://dbdocs.io/?utm_source=dbml',
},
{
label: 'Holistics.io - BI Reporting As Code',
href: 'https://www.holistics.io/?utm_source=dbml&utm_medium=topnav&utm_campaign=landing',
},
],
},
{
href: 'https://github.com/holistics/dbml',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
],
};

export default NavbarConfigs;
18 changes: 18 additions & 0 deletions dbml-docs/configs/sidebars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// https://docusaurus.io/docs/sidebar
import { SidebarsConfig } from '@docusaurus/plugin-content-docs';

/**
* Creating a sidebar enables you to:
- create an ordered group of docs
- render a sidebar for each doc of that group
- provide next/previous navigation
The sidebars can be generated from the filesystem, or explicitly defined here.
Create as many sidebars as you want.
*/
const SidebarConfigs: SidebarsConfig = {
docs: ['home', 'syntax', 'cli', 'js-module'],
};

export default SidebarConfigs;
Loading

0 comments on commit 2e479bb

Please sign in to comment.