Files
youtube-generator/src/engine/template-renderer.ts
T
poli0981andClaude Opus 4.6 a763f7c78a feat: Phase 1 MVP scaffold — core engine, i18n, UI, CI/CD
Complete Phase 1 implementation of YTDescGen:
- Project setup: Vite 5 + React 18 + TypeScript strict + Tailwind CSS dark theme
- Config layer: 7 video types, 10 genres, 7 platforms, rig/social fields
- i18n: EN/VI/JA with separate UI and template namespaces + validation script
- Core engine: title-builder, description-builder, tag-generator (pure TS, zero React)
- 42 unit tests covering all engine functions
- Zustand stores: editor + settings with localStorage persistence
- UI: 6 primitives, 11 editor components, 4 output components, 3 layout components
- Pages: Editor (form + quick preview) and Output (title/desc/tags + copy)
- CI/CD: GitHub Actions for lint/typecheck/test/build + GitHub Pages deploy

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 21:46:59 +07:00

45 lines
1.3 KiB
TypeScript

import type { GeneratorInput, GeneratorOutput, TranslationFn, CharLimitWarning } from "./types";
import { buildTitle, checkTitleWarning } from "./title-builder";
import { buildDescription, checkDescriptionWarning } from "./description-builder";
import { generateTags, formatTagString } from "./tag-generator";
import { YT_LIMITS } from "./types";
export function renderAll(input: GeneratorInput, t: TranslationFn): GeneratorOutput {
const title = buildTitle(input, t);
const description = buildDescription(input, t);
const tags = generateTags(input);
const tagString = formatTagString(tags);
const charCounts = {
title: title.length,
description: description.length,
tags: tagString.length,
};
const warnings: CharLimitWarning[] = [];
const titleWarning = checkTitleWarning(title);
if (titleWarning) warnings.push(titleWarning);
const descWarning = checkDescriptionWarning(description);
if (descWarning) warnings.push(descWarning);
if (tagString.length > YT_LIMITS.TAGS_MAX) {
warnings.push({
field: "tags",
current: tagString.length,
limit: YT_LIMITS.TAGS_MAX,
message: `Tags exceed ${YT_LIMITS.TAGS_MAX} characters (${tagString.length}/${YT_LIMITS.TAGS_MAX})`,
});
}
return {
title,
description,
tags,
tagString,
charCounts,
warnings,
};
}