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
10 changes: 10 additions & 0 deletions website/src/lib/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,13 @@ export function loadChangelog(): ChangelogRelease[] {
const md = readFileSync(file, 'utf8');
return parseChangelog(md);
}

let cachedVersion: string | null = null;

export function latestVersion(): string {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUGGESTION: latestVersion() re-reads and re-parses CHANGELOG.md on every call

loadChangelog() is invoked unconditionally on each call, re-reading and re-parsing CHANGELOG.md. With both index.astro and install.astro now calling latestVersion() (and /changelog likely calling loadChangelog() directly), each page build re-parses the file independently — and SSR mode would re-parse on every request. Memoize the result at module scope (e.g. a top-level let cached: string | null = null with lazy init) so the file is read and parsed once per process.


Reply with @kilocode-bot fix it to have Kilo Code address this issue.

if (cachedVersion) return cachedVersion;
const latest = loadChangelog().find((r) => r.isLatest);
if (!latest?.version) throw new Error('CHANGELOG.md has no stable release entry');
cachedVersion = latest.version;
return cachedVersion;
}
8 changes: 7 additions & 1 deletion website/src/lib/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,15 @@ export const synapseTheme: ThemeRegistration = {

const highlighter = await createHighlighter({
themes: [synapseTheme],
langs: ['java'],
langs: ['java', 'groovy', 'kotlin', 'properties'],
})

export function highlightJava(code: string): string {
return highlighter.codeToHtml(code, { lang: 'java', theme: synapseTheme })
}

export type SnippetLang = 'java' | 'groovy' | 'kotlin' | 'properties';

export function highlightCode(code: string, lang: SnippetLang): string {
return highlighter.codeToHtml(code, { lang, theme: synapseTheme })
}
3 changes: 2 additions & 1 deletion website/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import BaseLayout from '~/components/layout/BaseLayout.astro';

import { highlightJava } from '@/lib/highlight';
import { QUICKSTART_CODE, PUBSUB_CODE, HARDWARE_CODE } from '@/lib/code-samples';
import { latestVersion } from '@/lib/changelog';

import { Badge } from '@/components/ui/badge';
import {
Expand Down Expand Up @@ -103,7 +104,7 @@ const pools = [

const REPO = 'https://github.com/IamCoder18/synapse';

const VERSION = '0.4.0';
const VERSION = latestVersion();
const DESCRIPTION =
'A tiny, annotation-driven pub/sub bus for FTC robot code. 40 KB. Zero dependencies. One hardware thread.';

Expand Down
Loading
Loading