mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
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:
+3
-10
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user