Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,132 changes: 5,132 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
},
"devDependencies": {
"@types/node": "^20.10.0",
"@typescript-eslint/eslint-plugin": "^6.13.0",
"@typescript-eslint/parser": "^6.13.0",
"eslint": "^8.55.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^3.1.0",
"typescript": "^5.3.3"
},
Expand Down
159 changes: 159 additions & 0 deletions packages/core/CLI_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# nextjs-htk CLI

The `@hacktoolkit/nextjs-htk` package includes a CLI tool to help standardize project setup and maintain consistency across all nextjs-htk projects.

## Installation

The CLI is automatically available when you install `@hacktoolkit/nextjs-htk`:

```bash
npm install @hacktoolkit/nextjs-htk
```
Comment thread
jontsai marked this conversation as resolved.

## Usage

### Initialize a new project

Copy all standard files (Makefile, scripts, etc.) to your project:

```bash
npx @hacktoolkit/nextjs-htk init
```

Or if you have the package installed locally:

```bash
npm exec htk init
```

### Sync existing project

Update your project with the latest templates from nextjs-htk:

```bash
npx @hacktoolkit/nextjs-htk sync
```

### Sync specific files

Sync only the Makefile:

```bash
npx @hacktoolkit/nextjs-htk sync:makefile
```

Sync only the scripts directory:

```bash
npx @hacktoolkit/nextjs-htk sync:scripts
```

### Force overwrite

By default, the CLI will not overwrite existing files. Use `--force` or `-f` to overwrite:

```bash
npx @hacktoolkit/nextjs-htk init --force
npx @hacktoolkit/nextjs-htk sync:makefile -f
```

### Help

Show all available commands:

```bash
npx @hacktoolkit/nextjs-htk help
```

## What files are synced?

### Makefile
Standard Makefile with common targets:
- `make help` - Show all available targets
- `make install` - Install dependencies
- `make dev` - Start development server
- `make build` - Build for production
- `make deploy` - Build and deploy to GitHub Pages
- `make clean` - Clean build artifacts

### Scripts
- `src/scripts/generate_sitemap.ts` - Generate sitemap.xml during build

## Using shared utilities

The package also exports utilities you can use in your code:

```typescript
import { generateSitemap } from '@hacktoolkit/nextjs-htk/utils'
import type { SitemapConfig } from '@hacktoolkit/nextjs-htk/utils'

const config: SitemapConfig = {
Comment thread
jontsai marked this conversation as resolved.
siteUrl: 'https://example.com',
pages: [
{ name: 'Home', path: '/' },
{ name: 'About', path: '/about/' }
]
}

const sitemap = generateSitemap(config)
```

## Adding to package.json scripts

You can add convenience scripts to your `package.json`:

```json
{
"scripts": {
"htk:init": "htk init",
"htk:sync": "htk sync",
"htk:sync:makefile": "htk sync:makefile"
}
}
```

Then run with:

```bash
npm run htk:init
npm run htk:sync
```

## Integration with build process

The sitemap generation script integrates with your Next.js build:

1. Make sure your `htk.config.ts` is properly configured
2. Add the sitemap generation to your build script in `package.json`:

```json
{
"scripts": {
"build": "next build && tsx src/scripts/generate_sitemap.ts"
}
}
```

3. The sitemap will be automatically generated in your build directory

## Examples

### First time setup

```bash
cd my-nextjs-htk-project
npm install @hacktoolkit/nextjs-htk
npx @hacktoolkit/nextjs-htk init
```

### Update to latest templates

```bash
npx @hacktoolkit/nextjs-htk sync --force
```

### Just update the Makefile

```bash
npx @hacktoolkit/nextjs-htk sync:makefile --force
```
87 changes: 83 additions & 4 deletions packages/core/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# @nextjs-htk/core
# @hacktoolkit/nextjs-htk

Core components, hooks, and utilities for the nextjs-htk framework.

## Installation

```bash
npm install @nextjs-htk/core
npm install @hacktoolkit/nextjs-htk
# or
pnpm add @nextjs-htk/core
pnpm add @hacktoolkit/nextjs-htk
```

## Peer Dependencies
Expand All @@ -17,14 +17,63 @@ This package requires:
- react >= 19.0.0
- react-dom >= 19.0.0

## CLI Tool

The package includes a CLI tool for project standardization and template management.

### Quick Start

```bash
# Initialize a new project with standard files
npx @hacktoolkit/nextjs-htk init

# Sync templates from latest version
npx @hacktoolkit/nextjs-htk sync

# Show all available commands
npx @hacktoolkit/nextjs-htk help
```
Comment thread
jontsai marked this conversation as resolved.

### Available Commands

- **`htk init`** - Initialize new project with Makefile, scripts, and configs
- **`htk sync`** - Update all templates to latest version
- **`htk sync:makefile`** - Sync only the Makefile
- **`htk sync:scripts`** - Sync only the scripts directory

### Force Overwrite

By default, existing files won't be overwritten. Use `--force` or `-f`:

```bash
npx @hacktoolkit/nextjs-htk sync --force
npx @hacktoolkit/nextjs-htk init -f
```

### What Gets Installed

**Makefile** - Standard targets for development and deployment:
- `make dev` - Start development server
- `make build` - Build for production
- `make deploy` - Deploy to GitHub Pages
- `make help` - Show all available targets

**Scripts** - Utility scripts for your project:
- `src/scripts/generate_sitemap.ts` - Auto-generate sitemap.xml

**Next.js Config Template** - React 19 compatible configuration with:
- Webpack alias configuration for single React instance
- Static export settings for GitHub Pages
- Source maps enabled for debugging

## Usage

### Configuration

Create a `htk.config.ts` file:

```typescript
import { defineConfig } from '@nextjs-htk/core'
import { defineConfig } from '@hacktoolkit/nextjs-htk'

export default defineConfig({
site: {
Expand All @@ -44,6 +93,36 @@ export default defineConfig({
})
```

## Utilities

### Sitemap Generator

Generate SEO-friendly sitemaps from your site configuration:

```typescript
import { generateSitemap } from '@hacktoolkit/nextjs-htk/utils'
import type { SitemapConfig } from '@hacktoolkit/nextjs-htk/utils'

Comment thread
jontsai marked this conversation as resolved.
const config: SitemapConfig = {
siteUrl: 'https://example.com',
pages: [
{ name: 'Home', path: '/', showInNav: true },
{ name: 'About', path: '/about/', showInNav: true }
],
additionalPages: [
{
path: '/blog/post-1/',
priority: 0.7,
changefreq: 'weekly'
}
]
}

const sitemap = generateSitemap(config)
```

The generated script (`src/scripts/generate_sitemap.ts`) automatically uses your `htk.config.ts` to generate the sitemap during build.

## Components

Components will be added in upcoming releases:
Expand Down
Loading