GLM 5.2 Benchmark: Tidy & Bugfix #35
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "cleanup/site-build-audit"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Testing GLM 5.2 by having it attempt to tidy and clean the custom SSG.
The site had two independent frontmatter parsers that disagreed: - create-post-object.ts split on '---' and required >=3 parts (threw 'Missing metadata' otherwise), then parsed each line by splitting on the first ':' via regex — which silently truncated any value containing a colon. - marked.ts had a preprocess hook that split on '---' again, swallowed the frontmatter, and rejoined the rest. This corrupted posts that contained '---' inside fenced code blocks (e.g. jsx-clientside.md, which documents a markdown example), and logged a spurious 'Unexpected split length' warning whenever mdToHtml was called on synthesized content with no frontmatter (buildAll's index page). Replace both with a single parseFrontmatter() in utils/frontmatter.ts that: - respects fenced code blocks when locating delimiters - accepts '--- ' (trailing whitespace) delimiters - splits each entry on the first colon only, preserving colons in values - returns null with no closing delimiter, so callers decide create-post-object now passes the parsed body (not the raw file content) to renderTemplate, and marked.ts's preprocess hook is gone. Also drop two pre-existing unused-parameter warnings ('info' in the highlight callback, 'title' in the link renderer) surfaced in the file this commit touches.index.ts ran 'await build()' at module top level. watch.ts imports { build } from './index' and then calls 'await build()' itself, so every 'pnpm dev' start built the whole site twice — once as an import side effect, once explicitly. Gate the auto-build behind a main-module check (realpathSync of argv[1] vs import.meta.url, tolerating a missing argv[1] so 'node -e' imports don't crash). The guard fires only when index.ts is the entry point; watch.ts's own build() call is now the single build on dev.Replace ad-hoc string manipulation with node:path primitives: - create-post-object.ts: basename() instead of path.split(separators).pop(), and relative(cwd, dirname(path)) instead of path.replace(cwd+'/','').replace(fileName,''). The old replace chain mangled relativeFolder when the filename appeared earlier in the path (e.g. posts/posts/foo.md). Folder is '' for root-level posts and 'sub/dir/' otherwise, matching the previous trailing-slash contract that all.ts/rss.ts rely on. - all.ts, posts.ts: switch .replace('md','html') and .replace('.md','') to a single anchored /\.md$/ -> '.html' regex. The un-anchored string replace corrupted filenames containing 'md' before the extension (e.g. cmd.md -> chtml.md). rss.ts already used the anchored form. Output is byte-identical to the previous commit apart from the build timestamp.@ -17,1 +19,3 @@await build();// Only run when invoked directly (e.g. `node build/index.ts`), not when// imported by watch.ts — otherwise every `dev` start builds twice.const entryPath = process.argv[1];This feels really gross - is it overkill?
@ -0,0 +4,4 @@}/*** Parse YAML-ish frontmatter delimited by `---` lines.Remove all these gross LLM-esque comments 🤮
@ -33,4 +32,2 @@marked.use({hooks: {preprocess(content: string): string {It seems dangerous to completely remove this? Why was it originally here?
It was lmao. Commit
e678a36188reverts thisOverall needs a formatting pass - code is quite cramped
In the previous commit I removed marked.ts's preprocess hook and relied on create-post-object.ts to strip frontmatter before calling mdToHtml. That works for current callers, but it leaves mdToHtml brittle: if any future caller passes a raw post file, the frontmatter is rendered as a visible horizontal rule + heading. Put the safety net back, but implement it with the shared parseFrontmatter() utility instead of the old split('---') hack. This means: - raw post content still has frontmatter stripped before markdown parsing - content with no frontmatter passes through unchanged (no spurious 'Unexpected split length' warning) - '---' inside fenced code blocks is no longer mistaken for a delimiter Output remains byte-identical to the previous commit apart from the build timestamp.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.