1.5 KiB
Example Frontend Render Plugin
This directory contains a minimal render plugin that highlights .txt files
with a custom color scheme. Use it as a starting point for your own plugins or
as a quick way to validate the dynamic plugin system locally.
Files
manifest.json— metadata (including the requiredschemaVersion) consumed by Gitea when installing a pluginrender.js— an ES module that exports arender(container, fileUrl)function; it downloads the source file and renders it in a styled<pre>
By default plugins may only fetch the file that is currently being rendered.
If your plugin needs to contact Gitea APIs or any external services, list their
domains under the permissions array in manifest.json. Requests to hosts that
are not declared there will be blocked by the runtime.
Build & Install
-
Create a zip archive that contains both files:
cd contrib/render-plugins/example zip -r ../example-highlight-txt.zip manifest.json render.js -
In the Gitea web UI, visit
Site Administration → Render Plugins, uploadexample-highlight-txt.zip, and enable it. -
Open any
.txtfile in a repository; the viewer will display the content in the custom colors to confirm the plugin is active.
Feel free to modify render.js to experiment with the API. The plugin runs in
the browser, so only standard Web APIs are available (no bundler is required
as long as the file stays a plain ES module).