mirror of
https://github.com/mue/mue.git
synced 2026-07-16 13:34:03 +02:00
chore: merge main into 8.0
This commit is contained in:
@@ -14,6 +14,34 @@ class Changelog extends PureComponent {
|
||||
this.changelog = createRef();
|
||||
}
|
||||
|
||||
parseMarkdown = (text) => {
|
||||
if (typeof text !== 'string') {
|
||||
throw new Error('Input must be a string');
|
||||
}
|
||||
|
||||
// Replace markdown syntax
|
||||
text = text
|
||||
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
|
||||
.replace(/^## (.*$)/gm, '<span class="title">$1</span>')
|
||||
.replace(
|
||||
/((http|https):\/\/[^\s]+)/g,
|
||||
'<a href="$1" target="_blank" rel="noopener noreferrer">$1</a>',
|
||||
)
|
||||
// resolve @ to github user link
|
||||
.replace(
|
||||
/@([a-zA-Z0-9-_]+)/g,
|
||||
'<a href="https://github.com/$1" target="_blank" class="changelogAt">@$1</a>',
|
||||
);
|
||||
|
||||
// Replace list items
|
||||
text = text.replace(/^\* (.*$)/gm, '<li>$1</li>');
|
||||
|
||||
// Wrap list items in <ul></ul>
|
||||
text = text.replace(/((<li>.*<\/li>\s*)+)/g, '<ul>$1</ul>');
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
async getUpdate() {
|
||||
const releases = await fetch(
|
||||
`https://api.github.com/repos/${variables.constants.ORG_NAME}/${variables.constants.REPO_NAME}/releases`,
|
||||
@@ -22,14 +50,18 @@ class Changelog extends PureComponent {
|
||||
},
|
||||
);
|
||||
|
||||
// get the release which tag_name is the same as the current version
|
||||
const data = await releases.json();
|
||||
const release = data.find((release) => release.tag_name === variables.constants.VERSION);
|
||||
|
||||
if (this.controller.signal.aborted === true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// get the release which tag_name is the same as the current version
|
||||
const data = await releases.json();
|
||||
let release = data.find((release) => release.tag_name === variables.constants.VERSION);
|
||||
|
||||
if (!release) {
|
||||
release = data[0];
|
||||
}
|
||||
|
||||
// request the changelog
|
||||
const res = await fetch(release.url, { signal: this.controller.signal });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user