# MyAIDev Method - Publishing Guide

Comprehensive guide for publishing content across multiple platforms using MyAIDev Method.

## Table of Contents

- [Overview](#overview)
- [Platform Support](#platform-support)
- [Quick Start](#quick-start)
- [Platform-Specific Guides](#platform-specific-guides)
- [Configuration](#configuration)
- [Workflows](#workflows)
- [Troubleshooting](#troubleshooting)

## Overview

MyAIDev Method provides a unified content publishing system that supports:

- **API-Based CMS**: WordPress, PayloadCMS
- **Static Site Generators**: Docusaurus, Mintlify, Astro
- **Deployment**: Coolify self-hosted PaaS

All platforms use a consistent workflow:
1. Create content (manually or via `/content-writer`)
2. Configure platform credentials (`/configure`)
3. Publish content (`/[platform]-publisher`)

## Platform Support

### WordPress
- **Type**: API-based CMS
- **Publishing**: REST API with Gutenberg blocks
- **Auth**: Application Passwords
- **Status**: Draft, Published
- **Features**: Categories, tags, featured images

### PayloadCMS
- **Type**: Headless CMS (API-based)
- **Publishing**: REST API with Lexical rich text
- **Auth**: JWT tokens or API keys
- **Status**: Draft, Published
- **Features**: Custom collections, flexible schemas

### Docusaurus
- **Type**: Static site generator (git-based)
- **Publishing**: File operations + git workflow
- **Content**: Docs, Blog, Pages
- **Features**: Sidebars, versioning, MDX support

### Mintlify
- **Type**: Documentation platform (git-based)
- **Publishing**: File operations + git workflow + mint.json updates
- **Content**: MDX documentation
- **Features**: Automatic navigation, API references, icons

### Astro
- **Type**: Static site generator (git-based)
- **Publishing**: File operations + git workflow
- **Content**: Content collections, Pages
- **Features**: Type-safe frontmatter, image optimization

## Quick Start

### 1. Install Package

```bash
npm install -g myaidev-method
# or
npx myaidev-method@latest init
```

### 2. Configure Platform

```bash
/configure
```

Select your platform and provide credentials.

### 3. Create Content

```bash
/content-writer "How to build a REST API with Node.js"
```

### 4. Publish Content

```bash
# WordPress
/wordpress-publisher "article.md" --status draft

# PayloadCMS
/payloadcms-publisher "article.md" --collection posts

# Docusaurus
/docusaurus-publisher "article.md" --type docs

# Mintlify
/mintlify-publisher "article.md" --nav-section "Guides"

# Astro
/astro-publisher "article.md" --collection blog
```

## Platform-Specific Guides

### WordPress Publishing

**Configuration** (.env):
```
WORDPRESS_URL=https://your-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=xxxx-xxxx-xxxx-xxxx
```

**Basic Publishing**:
```bash
/wordpress-publisher "article.md"
```

**With Options**:
```bash
/wordpress-publisher "article.md" \
  --status published \
  --categories "Technology,Programming" \
  --tags "nodejs,api,rest"
```

**Features**:
- Automatic Gutenberg block conversion
- Featured image upload
- Category and tag management
- Draft and publish workflow

### PayloadCMS Publishing

**Configuration** (.env):
```
PAYLOADCMS_URL=https://cms.your-site.com
PAYLOADCMS_EMAIL=admin@your-site.com
PAYLOADCMS_PASSWORD=your-password
```

**Basic Publishing**:
```bash
/payloadcms-publisher "article.md"
```

**With Options**:
```bash
/payloadcms-publisher "article.md" \
  --collection articles \
  --status published \
  --id 67890
```

**Features**:
- Markdown to Lexical conversion
- Custom collections support
- JWT authentication
- Document updates by ID

### Docusaurus Publishing

**Prerequisites**:
- Docusaurus project with `docusaurus.config.js`
- Git repository initialized

**Configuration** (.env):
```
DOCUSAURUS_PROJECT_PATH=./my-docs
GIT_USER_NAME=Your Name
GIT_USER_EMAIL=your-email@example.com
```

**Publishing to Docs**:
```bash
/docusaurus-publisher "guide.md"
```

**Publishing to Blog**:
```bash
/docusaurus-publisher "post.md" --type blog
```

**Features**:
- Automatic frontmatter transformation
- Sidebar configuration
- Blog date prefixing
- Git commit and push

### Mintlify Publishing

**Prerequisites**:
- Mintlify project with `mint.json`
- Git repository initialized

**Configuration** (.env):
```
MINTLIFY_PROJECT_PATH=./docs
GIT_USER_NAME=Your Name
GIT_USER_EMAIL=your-email@example.com
```

**Basic Publishing**:
```bash
/mintlify-publisher "guide.mdx"
```

**With Navigation**:
```bash
/mintlify-publisher "api-reference.md" \
  --nav-section "API Reference"
```

**Features**:
- Automatic mint.json updates
- Navigation section management
- MDX support
- Icon customization

### Astro Publishing

**Prerequisites**:
- Astro project with `astro.config.mjs`
- Git repository initialized

**Configuration** (.env):
```
ASTRO_PROJECT_PATH=./my-site
GIT_USER_NAME=Your Name
GIT_USER_EMAIL=your-email@example.com
```

**Publishing to Collection**:
```bash
/astro-publisher "article.md" --collection blog
```

**Publishing to Pages**:
```bash
/astro-publisher "about.md" --pages
```

**Features**:
- Content collections support
- Schema validation
- Frontmatter transformation (date → pubDate)
- Draft/published workflow

## Configuration

### Using /configure

Interactive configuration command:

```bash
/configure
```

Prompts for:
1. Platform selection
2. Credentials and URLs
3. Optional settings

### Manual Configuration

Edit `.env` file directly:

```env
# WordPress
WORDPRESS_URL=https://your-wordpress-site.com
WORDPRESS_USERNAME=your-username
WORDPRESS_APP_PASSWORD=your-app-password

# PayloadCMS
PAYLOADCMS_URL=https://your-payloadcms.com
PAYLOADCMS_EMAIL=your-email@example.com
PAYLOADCMS_PASSWORD=your-password

# Git (for static sites)
GIT_USER_NAME=Your Name
GIT_USER_EMAIL=your-email@example.com

# Project Paths (optional)
DOCUSAURUS_PROJECT_PATH=./docs-site
MINTLIFY_PROJECT_PATH=./docs
ASTRO_PROJECT_PATH=./blog
```

## Workflows

### Content Creation → Publishing

```bash
# 1. Create content
/content-writer "Building Scalable APIs"

# 2. Review and edit
# Edit the generated markdown file

# 3. Publish to multiple platforms
/wordpress-publisher "building-scalable-apis.md" --status draft
/docusaurus-publisher "building-scalable-apis.md" --type blog
/payloadcms-publisher "building-scalable-apis.md" --collection articles
```

### Multi-Platform Publishing

Publish the same content to multiple platforms:

```bash
FILE="my-article.md"

# WordPress (for SEO and broad reach)
/wordpress-publisher "$FILE" --status published

# Docusaurus (for technical documentation)
/docusaurus-publisher "$FILE" --type docs

# PayloadCMS (for headless CMS API access)
/payloadcms-publisher "$FILE" --collection articles --status published
```

### Draft → Review → Publish

```bash
# 1. Publish as draft
/wordpress-publisher "article.md" --status draft

# 2. Review on platform
# Review content on WordPress admin

# 3. Update to published
/wordpress-publisher "article.md" --status published --id 12345
```

### Git-Based Deployment

For static sites (Docusaurus, Mintlify, Astro):

```bash
# 1. Publish to staging
/docusaurus-publisher "guide.md" --branch staging

# 2. Review deployment
# Check staging environment

# 3. Publish to production
/docusaurus-publisher "guide.md" --branch main
```

## Script Usage

All publishing operations can also be invoked via npm scripts:

```bash
# PayloadCMS
npm run payloadcms:publish -- --file article.md --status published

# Docusaurus
npm run docusaurus:publish -- --file guide.md --type docs

# Mintlify
npm run mintlify:publish -- --file api-ref.md --nav-section "API"

# Astro
npm run astro:publish -- --file post.md --collection blog
```

## Troubleshooting

### Authentication Failures

**WordPress**:
- Verify Application Password is correct
- Check URL includes `https://`
- Ensure WordPress REST API is enabled

**PayloadCMS**:
- Verify email/password combination
- Check PayloadCMS instance is accessible
- Try using API key instead of password

### Git Errors

**Uncommitted Changes**:
```bash
# Commit or stash existing changes first
git stash
# Then retry publishing
```

**Push Rejected**:
```bash
# Pull latest changes first
cd /path/to/project
git pull --rebase
# Then retry publishing
```

### Frontmatter Issues

**Docusaurus**:
- Ensure `title` field is present
- Check `sidebar_position` is a number

**Astro**:
- Verify `pubDate` is ISO 8601 format
- Check collection schema requirements

**Mintlify**:
- Ensure `title` field is present
- Verify MDX syntax is valid

### Platform Detection

If platform not detected:

```bash
# Specify project path explicitly
/docusaurus-publisher "guide.md" --project /path/to/docs

# Or set in .env
echo "DOCUSAURUS_PROJECT_PATH=/path/to/docs" >> .env
```

## Best Practices

1. **Always start with drafts**: Publish as draft first, review, then publish
2. **Use consistent frontmatter**: Maintain standard frontmatter across content
3. **Test on staging**: Use git branches for staging/production workflow
4. **Version control**: Commit content to git before publishing
5. **Backup regularly**: Keep local copies of all content
6. **Monitor deployments**: Check build status after git push
7. **Validate schemas**: Test frontmatter against platform requirements

## Advanced Topics

### Custom Frontmatter

Each platform accepts different frontmatter fields. Common fields:

```yaml
---
# Universal
title: "Article Title"
description: "Article description"
date: 2025-10-16

# WordPress-specific
categories: ["Tech", "Programming"]
tags: ["nodejs", "api"]
status: draft

# Docusaurus-specific
sidebar_position: 1
sidebar_label: "Custom Label"

# Astro-specific
pubDate: 2025-10-16T00:00:00Z
draft: false
author: "Author Name"

# Mintlify-specific
icon: "rocket"
iconType: "solid"
---
```

### Automated Publishing

Create shell scripts for automated workflows:

```bash
#!/bin/bash
# publish-everywhere.sh

FILE=$1

/wordpress-publisher "$FILE" --status published
/payloadcms-publisher "$FILE" --status published
/docusaurus-publisher "$FILE" --type blog
```

### CI/CD Integration

Integrate with GitHub Actions, GitLab CI, or other CI/CD:

```yaml
# .github/workflows/publish.yml
name: Publish Documentation
on:
  push:
    paths:
      - 'content/**'
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: npm install -g myaidev-method
      - run: /docusaurus-publisher content/*.md
```

## Support

- **Documentation**: See platform-specific docs (WORDPRESS_ADMIN_SCRIPTS.md, etc.)
- **Issues**: https://github.com/myaione/myaidev-method/issues
- **NPM**: https://www.npmjs.com/package/myaidev-method
- **GitHub**: https://github.com/myaione/myaidev-method

## Next Steps

1. Configure your platforms: `/configure`
2. Create test content: `/content-writer "Test Article"`
3. Publish to staging/draft first
4. Review and iterate
5. Publish to production

Happy publishing! 🚀
