0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-12-10 11:05:19 +01:00
2025-12-05 20:01:56 -08:00

29 lines
805 B
JavaScript

const TEXT_COLOR = '#f6e05e';
const BACKGROUND_COLOR = '#1a202c';
async function render(container, fileUrl) {
container.innerHTML = '';
const message = document.createElement('div');
message.className = 'ui tiny message';
message.textContent = 'Rendered by example-highlight-txt plugin';
container.append(message);
const response = await fetch(fileUrl);
if (!response.ok) {
throw new Error(`Failed to download file (${response.status})`);
}
const text = await response.text();
const pre = document.createElement('pre');
pre.style.backgroundColor = BACKGROUND_COLOR;
pre.style.color = TEXT_COLOR;
pre.style.padding = '1rem';
pre.style.borderRadius = '0.5rem';
pre.style.overflow = 'auto';
pre.textContent = text;
container.append(pre);
}
export default {render};