Skip to content

Commit 035901a

Browse files
committed
Refactor ObjectDocs starter template structure and update initialization scripts
1 parent 1bc7a1a commit 035901a

File tree

6 files changed

+33
-51
lines changed

6 files changed

+33
-51
lines changed

examples/starter/README.md

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,22 @@ This starter template serves multiple purposes:
2323
```
2424
examples/starter/
2525
├── content/
26-
│ ├── package.json # npm scripts (auto-created by init)
27-
│ ├── .fumadocs/ # Site engine (created by init command, gitignored)
26+
│ ├── package.json # Project configuration and scripts
27+
│ ├── .fumadocs/ # Site engine (created by init command, gitignored)
2828
│ ├── docs.site.json # Global site configuration
29+
│ ├── public/ # Static assets (logos, images)
2930
│ └── docs/
3031
│ ├── meta.json # Sidebar navigation structure
3132
│ ├── index.mdx # Home page
3233
│ ├── getting-started.mdx
3334
│ └── configuration.mdx
34-
├── public/ # Static assets (logos, images)
35-
├── package.json # Uses @objectdocs/cli from workspace
36-
└── README.md # This file
35+
└── README.md # This file
3736
```
3837

3938
**Key Points:**
40-
- All documentation files are in `content/`
41-
- `content/package.json` is auto-created by `objectdocs init`
39+
- All project files are in `content/`
40+
- `content/package.json` manages dependencies and scripts
4241
- `content/.fumadocs/` is gitignored and not committed
43-
- Root directory remains clean
4442

4543
## 🚀 Getting Started
4644

@@ -51,44 +49,35 @@ examples/starter/
5149

5250
### Installation
5351

54-
1. Navigate to the starter directory:
52+
1. Navigate to the content directory:
5553

5654
```bash
57-
cd examples/starter
55+
cd examples/starter/content
5856
```
5957

60-
2. Install the CLI:
58+
2. Install dependencies:
6159

6260
```bash
6361
pnpm install
6462
```
6563

66-
This will install `@objectdocs/cli` from the workspace.
67-
6864
3. Initialize ObjectDocs:
6965

7066
```bash
7167
pnpm objectdocs init
7268
```
7369

7470
This command will:
75-
- Create `content/package.json` with necessary scripts
76-
- Copy the `@objectdocs/site` engine to `content/.fumadocs`
77-
- Install dependencies in `content/.fumadocs/node_modules`
71+
- Copy the `@objectdocs/site` engine to `.fumadocs`
72+
- Install dependencies in `.fumadocs/node_modules`
7873
- Prepare your project for development
7974

8075
### Development
8176

8277
Start the development server:
8378

8479
```bash
85-
cd content && npm run dev
86-
```
87-
88-
Or if you have a root-level script configured:
89-
90-
```bash
91-
pnpm dev
80+
npm run dev
9281
```
9382

9483
The site will be available at [http://localhost:7777](http://localhost:7777).
@@ -98,29 +87,17 @@ The site will be available at [http://localhost:7777](http://localhost:7777).
9887
Build the project for production:
9988

10089
```bash
101-
cd content && npm run build
90+
npm run build
10291
```
10392

104-
Or with root-level script:
105-
106-
```bash
107-
pnpm build
108-
```
109-
110-
This will generate the production build in the `content/.fumadocs/.next` directory.
93+
This will generate the production build in the `.fumadocs/.next` directory.
11194

11295
### Production Server
11396

11497
Start the production server:
11598

11699
```bash
117-
cd content && npm run start
118-
```
119-
120-
Or with root-level script:
121-
122-
```bash
123-
pnpm start
100+
npm run start
124101
```
125102

126103
## 🌐 Deploying to Vercel
@@ -133,18 +110,18 @@ pnpm start
133110
npm i -g vercel
134111
```
135112

136-
2. Deploy from the examples/starter directory:
113+
2. Deploy from the content directory:
137114

138115
```bash
139-
cd examples/starter
116+
cd examples/starter/content
140117
vercel
141118
```
142119

143120
### Method 2: Using GitHub Integration
144121

145122
1. Push this starter to your GitHub repository
146123
2. Import the project in Vercel
147-
3. Set the **Root Directory** to `examples/starter`
124+
3. Set the **Root Directory** to `examples/starter/content`
148125
4. Vercel will auto-detect Next.js settings
149126

150127
### Vercel Configuration
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"description": "Starter template for creating documentation sites with ObjectDocs",
66
"scripts": {
7-
"dev": "cd content && npm run dev",
8-
"build": "cd content && npm run build",
9-
"start": "cd content && npm run start"
7+
"dev": "cd .fumadocs && npm run dev",
8+
"build": "cd .fumadocs && npm run build",
9+
"start": "cd .fumadocs && npm run start"
1010
},
1111
"devDependencies": {
1212
"@objectdocs/cli": "workspace:*"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ if [ ! -f "package.json" ] || ! grep -q "@objectdocs/cli" package.json; then
2222
fi
2323

2424
echo "Step 1: Checking package.json configuration..."
25-
if grep -q '"dev": "objectdocs dev"' package.json; then
25+
if grep -q '"dev": "cd .fumadocs && npm run dev"' package.json; then
2626
echo -e "${GREEN}${NC} Dev script configured correctly"
2727
else
2828
echo -e "${RED}${NC} Dev script missing or incorrect"
2929
exit 1
3030
fi
3131

32-
if grep -q '"build": "objectdocs build"' package.json; then
32+
if grep -q '"build": "cd .fumadocs && npm run build"' package.json; then
3333
echo -e "${GREEN}${NC} Build script configured correctly"
3434
else
3535
echo -e "${RED}${NC} Build script missing or incorrect"
@@ -46,14 +46,14 @@ fi
4646
echo ""
4747
echo "Step 2: Checking content structure..."
4848

49-
if [ -d "content/docs" ]; then
49+
if [ -d "docs" ]; then
5050
echo -e "${GREEN}${NC} Content directory exists"
5151
else
5252
echo -e "${RED}${NC} Content directory missing"
5353
exit 1
5454
fi
5555

56-
if [ -f "content/docs.site.json" ]; then
56+
if [ -f "docs.site.json" ]; then
5757
echo -e "${GREEN}${NC} Site configuration exists"
5858
else
5959
echo -e "${RED}${NC} Site configuration missing"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "https://openapi.vercel.sh/vercel.json",
33
"buildCommand": "pnpm build",
44
"devCommand": "pnpm dev",
5-
"installCommand": "pnpm install",
5+
"installCommand": "pnpm install && pnpm objectdocs init",
66
"framework": "nextjs",
7-
"outputDirectory": ".next"
7+
"outputDirectory": ".fumadocs/.next"
88
}

packages/cli/src/commands/init.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ export function registerInitCommand(cli) {
2222
.action(async (options) => {
2323
console.log('Initializing ObjectDocs...\n');
2424

25-
const contentDir = path.resolve(process.cwd(), 'content');
25+
let contentDir = path.resolve(process.cwd(), 'content');
26+
// Support running from inside 'content' directory
27+
if (!fs.existsSync(contentDir) && fs.existsSync(path.resolve(process.cwd(), 'docs'))) {
28+
contentDir = process.cwd();
29+
}
30+
2631
const targetDir = path.resolve(contentDir, '.fumadocs');
2732
const contentPackageJsonPath = path.resolve(contentDir, 'package.json');
2833

0 commit comments

Comments
 (0)