Skip to content

Motivation

Creating and maintaining a seamless workflow for developing and documenting templ components can be challenging, especially when manual steps are required to generate and preview components. This plugin was created to simplify and improve the process of documenting templ components in VitePress, providing an automated and efficient solution.

The Challenges

templ provides a powerful way to build HTML components with Go, rendering fragments that can be used to compose screens, pages, documents, or apps. In a Go environment, templ works seamlessly, where running templ generate converts *.templ files into Go code, integrating seamlessly into the development workflow. However, using templ in a JavaScript/TypeScript ecosystem, like VitePress, poses challenges in maintaining a smooth development workflow.

VitePress, on the other hand, is a Static Site Generator (SSG) designed for building fast, content-centric websites. It processes Markdown source content, applies themes, and generates static HTML pages. While it excels at creating static sites, integrating the dynamic generation of templ components can be cumbersome without automation.

The Solution

This plugin bridges the gap between templ and VitePress, automating the generation and preview process for templ components. By integrating directly with VitePress, the plugin takes care of templ generation behind the scenes, automatically processing changes to *.templ files and updating the documentation accordingly. This solution brings the power and simplicity of templ from the Go environment to the JavaScript/TypeScript ecosystem in VitePress.

Released under the MIT License.