fix(changelog): resolve embedded notes by semver core (#373)

Whats New and the post-update modal required an exact ## [version] header,
so prerelease package versions (rc, dev) often had no matching section.
Match on major.minor.patch first; if several sections share the core,
prefer a plain X.Y.Z heading when present.
This commit is contained in:
cucadmuh
2026-04-30 01:36:57 +03:00
committed by GitHub
parent 1d569f6282
commit ef45b726ad
3 changed files with 73 additions and 19 deletions
+3 -10
View File
@@ -4,6 +4,7 @@ import { useNavigate } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { version } from '../../package.json';
import changelogRaw from '../../CHANGELOG.md?raw';
import { findChangelogReleaseEntry } from '../utils/changelogReleaseMatch';
import { renderChangelogBody } from '../utils/changelogMarkdown';
export default function WhatsNew() {
@@ -15,15 +16,7 @@ export default function WhatsNew() {
else navigate('/');
};
const entry = useMemo(() => {
const blocks = changelogRaw.split(/\n(?=## \[)/).filter((b: string) => b.startsWith('## ['));
const block = blocks.find((b: string) => b.startsWith(`## [${version}]`));
if (!block) return null;
const lines = block.split('\n');
const match = lines[0].match(/## \[([^\]]+)\](?:\s*-\s*(.+))?/);
const body = lines.slice(1).join('\n').trim();
return { version: match?.[1] ?? version, date: match?.[2] ?? '', body };
}, []);
const entry = useMemo(() => findChangelogReleaseEntry(changelogRaw, version), []);
return (
<div className="whats-new">
@@ -33,7 +26,7 @@ export default function WhatsNew() {
<div>
<h1 className="whats-new__title">{t('whatsNew.title')}</h1>
<div className="whats-new__subtitle">
v{entry?.version ?? version}
v{version}
{entry?.date && <span className="whats-new__date"> · {entry.date}</span>}
</div>
</div>