Skip to content

Visualize Your Ideas With Code

feat(docs): improve the release blog (#410)

Jacobf56bbdb4a95e
diff --git a/package.json b/package.json
index 95dc3025..b621929f 100644
--- a/package.json
+++ b/package.json
@@ -22,6 +22,7 @@
"player:build": "npm run build -w packages/player",
"docs:start": "npm run start -w packages/docs",
"docs:build": "npm run build -w packages/docs",
+ "docs:blog": "npm run blog -w packages/docs",
"vite-plugin:build": "npm run build -w packages/vite-plugin",
"vite-plugin:watch": "npm run watch -w packages/vite-plugin",
"e2e:test": "npm run test -w packages/e2e",
diff --git a/packages/docs/blog/2023-02-20-version-2.5.0.mdx b/packages/docs/blog/2023-02-20-version-2.5.0.mdx
index ed75d13a..38453637 100644
--- a/packages/docs/blog/2023-02-20-version-2.5.0.mdx
+++ b/packages/docs/blog/2023-02-20-version-2.5.0.mdx
@@ -4,37 +4,54 @@ title: Motion Canvas v2.5.0
authors: aarthificial
---
-### Features
+import IssueGroup from '@site/src/components/Release/IssueGroup';
+import Issue from '@site/src/components/Release/Issue';
+import Link from '@docusaurus/Link';
-- New [`spring`](/docs/tweening#spring-function) interpolation.
- ([#356](https://github.com/motion-canvas/motion-canvas/issues/356))
- ([1463b15](https://github.com/motion-canvas/motion-canvas/commit/1463b1592e22fad9d8298c11270e2099119e2229))
-- [`closed`](/api/2d/components/Circle#closed) property lets you make wedges
- using `Circle`s.
- ([#378](https://github.com/motion-canvas/motion-canvas/issues/378))
- ([62a9605](https://github.com/motion-canvas/motion-canvas/commit/62a9605d4c54e7bf2d2d44d47bf769f5b27378a5))
-- New [`fadeTransition`](/docs/transitions#fadetransition)
- ([#384](https://github.com/motion-canvas/motion-canvas/issues/384))
- ([a248785](https://github.com/motion-canvas/motion-canvas/commit/a248785e87d1c6ebc08581f4fda6be428a89824c))
-- The [`range`](/api/core/utils#range) function now accepts an additional `step`
- parameter. ([#373](https://github.com/motion-canvas/motion-canvas/issues/373))
- ([923209a](https://github.com/motion-canvas/motion-canvas/commit/923209a4106c8e7f570853dcc47a10e65e0d04d8))
-- `View2D` now extends `Rect` allowing you to change the background color of a
- scene using the `fill` property.
- ([#379](https://github.com/motion-canvas/motion-canvas/issues/379))
- ([93db5fc](https://github.com/motion-canvas/motion-canvas/commit/93db5fc41617c0902e85fda90fbfc930c2b4634b))
-
-### Bug Fixes
-
-- support `Color` to `null` tweening
- ([#387](https://github.com/motion-canvas/motion-canvas/issues/387))
- ([02e9f22](https://github.com/motion-canvas/motion-canvas/commit/02e9f22027a1c3a85ffcc259aeca913318fb6f54))
-- **2d:** fix signal initialization
- ([#382](https://github.com/motion-canvas/motion-canvas/issues/382))
- ([ea36e79](https://github.com/motion-canvas/motion-canvas/commit/ea36e791a20bfd1b491ffa9917be686c51bc3899))
-- **2d:** handle floating point errors in acos
- ([#381](https://github.com/motion-canvas/motion-canvas/issues/381))
- ([5bca8fd](https://github.com/motion-canvas/motion-canvas/commit/5bca8fd0bbdcf28f2793c124b7d6b0afd560c4b8))
-- plug memory leaks
- ([#385](https://github.com/motion-canvas/motion-canvas/issues/385))
- ([de0af00](https://github.com/motion-canvas/motion-canvas/commit/de0af00a7d2e019e2a933791c62b7901755be7b0))
+<IssueGroup type={'feat'}>
+ <Issue user={'gustavneustadt'} pr={356}>
+ New{' '}
+ <Link to="/docs/tweening#spring-function">
+ <code>spring</code>
+ </Link>{' '}
+ interpolation.
+ </Issue>
+ <Issue user={'aarthificial'} pr={378}>
+ <Link to="/api/2d/components/Circle#closed">
+ <code>closed</code>
+ </Link>{' '}
+ property lets you make wedges using <code>Circle</code>s.
+ </Issue>
+ <Issue user={'DanielBreiner'} pr={384}>
+ New{' '}
+ <Link to="/docs/transitions#fadetransition">
+ <code>fadeTransition</code>
+ </Link>
+ .
+ </Issue>
+ <Issue user={'ksassnowski'} pr={373}>
+ The{' '}
+ <Link to="/api/core/utils#range">
+ <code>range</code>
+ </Link>{' '}
+ function now accepts an additional <code>step</code> parameter.
+ </Issue>
+ <Issue user={'dariasc'} pr={379}>
+ <code>View2D</code> now extends <code>Rect</code> allowing you to change the
+ background color of a scene using the <code>fill</code> property.
+ </Issue>
+</IssueGroup>
+<IssueGroup type={'fix'}>
+ <Issue user={'aarthificial'} pr={387}>
+ Support <code>Color</code> to <code>null</code> tweening.
+ </Issue>
+ <Issue user={'aarthificial'} pr={385}>
+ Plug memory leaks.
+ </Issue>
+ <Issue user={'aarthificial'} pr={382}>
+ Fix signal initialization.
+ </Issue>
+ <Issue user={'aarthificial'} pr={381}>
+ Handle floating point errors in acos.
+ </Issue>
+</IssueGroup>
diff --git a/packages/docs/docusaurus.config.js b/packages/docs/docusaurus.config.js
index 238ce57d..45235a18 100644
--- a/packages/docs/docusaurus.config.js
+++ b/packages/docs/docusaurus.config.js
@@ -103,7 +103,6 @@ const config = {
appId: 'Q6Z7BJ83RF',
apiKey: '825d6a74e138e6e1378e9669b22720f0',
indexName: 'motion-canvasio',
- contextualSearch: false,
},
prism: {
theme: require('./config/lightCodeTheme'),
diff --git a/packages/docs/package.json b/packages/docs/package.json
index 499616a6..0692072d 100644
--- a/packages/docs/package.json
+++ b/packages/docs/package.json
@@ -10,6 +10,7 @@
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
+ "blog": "node ./release-blog-generator.js",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc"
diff --git a/packages/docs/release-blog-generator.js b/packages/docs/release-blog-generator.js
new file mode 100644
index 00000000..5097bace
--- /dev/null
+++ b/packages/docs/release-blog-generator.js
@@ -0,0 +1,90 @@
+/**
+ * Automatically generate a new blog entry for the current release.
+ */
+
+const {exec} = require('child_process');
+const fs = require('fs');
+
+const COMMIT_REGEX = /^(\w+)(?:\(.+\))?!?: (.+) \(#(\d+)\)/;
+
+function runBash(command) {
+ return new Promise((resolve, reject) =>
+ exec(command, (error, stdout) => {
+ if (error) reject(error);
+ resolve(stdout);
+ }),
+ );
+}
+
+async function gitLog(from, to) {
+ const log = await runBash(`git log --pretty=format:%s ${from}...${to}`);
+ return log.split('\n');
+}
+
+async function gitTags() {
+ const tags = await runBash('git tag');
+ return tags.trim().split('\n').reverse();
+}
+
+function getDate() {
+ const date = new Date();
+ const year = date.getFullYear();
+ const month = String(date.getMonth() + 1).padStart(2, '0');
+ const day = String(date.getDate()).padStart(2, '0');
+
+ return `${year}-${month}-${day}`;
+}
+
+function Issue({user, pr, header}) {
+ return ` <Issue user={'${user}'} pr={${pr}}>
+ ${header}
+ </Issue>`;
+}
+
+function IssueGroup([type, issues]) {
+ return `<IssueGroup type={'${type}'}>
+${issues.map(Issue).join('\n')}
+</IssueGroup>`;
+}
+
+(async () => {
+ const tags = await gitTags();
+ const logs = await gitLog(tags[0], tags[1]);
+ const types = {
+ feat: [],
+ fix: [],
+ };
+ for (const log of logs) {
+ const match = COMMIT_REGEX.exec(log);
+ if (!match) continue;
+ const [, type, header, pr] = match;
+ if (!(type in types)) continue;
+
+ const response = await fetch(
+ `https://api.github.com/repos/motion-canvas/motion-canvas/pulls/${pr}`,
+ );
+ const prData = await response.json();
+ types[type].push({
+ user: prData.user?.login ?? 'unknown',
+ header,
+ pr,
+ });
+ }
+
+ const version = tags[0].substring(1);
+
+ await fs.promises.writeFile(
+ `blog/${getDate()}-version-${version}.mdx`,
+ `---
+slug: version-${version}
+title: Motion Canvas v${version}
+authors: aarthificial
+---
+
+import IssueGroup from '@site/src/components/Release/IssueGroup';
+import Issue from '@site/src/components/Release/Issue';
+
+${Object.entries(types).map(IssueGroup).join('\n')}`,
+ 'utf8',
+ );
+})();
diff --git a/packages/docs/src/components/Release/Contributor.tsx b/packages/docs/src/components/Release/Contributor.tsx
new file mode 100644
index 00000000..72ccead9
--- /dev/null
+++ b/packages/docs/src/components/Release/Contributor.tsx
@@ -0,0 +1,25 @@
+import React from 'react';
+import styles from './styles.module.css';
+
+export interface ContributorProps {
+ name: string;
+}
+
+export default function Contributor({name}: ContributorProps) {
+ return (
+ <a
+ className={styles.contributor}
+ title={name}
+ href={`https://github.com/${name}`}
+ target="_blank"
+ >
+ <img
+ loading="lazy"
+ src={`https://github.com/${name}.png`}
+ width={20}
+ height={20}
+ alt={`${name}'s avatar`}
+ />
+ </a>
+ );
+}
diff --git a/packages/docs/src/components/Release/Issue.tsx b/packages/docs/src/components/Release/Issue.tsx
new file mode 100644
index 00000000..a0f07688
--- /dev/null
+++ b/packages/docs/src/components/Release/Issue.tsx
@@ -0,0 +1,20 @@
+import styles from '@site/src/components/Release/styles.module.css';
+import React, {ReactNode} from 'react';
+import Contributor from '@site/src/components/Release/Contributor';
+import PullRequest from '@site/src/components/Release/PullRequest';
+
+export interface IssueProps {
+ user: string;
+ pr: number;
+ children: ReactNode | ReactNode[];
+}
+
+export default function Issue({user, pr, children}: IssueProps) {
+ return (
+ <li className={styles.element}>
+ <Contributor name={user} />
+ {children}
+ <PullRequest id={pr} />
+ </li>
+ );
+}
diff --git a/packages/docs/src/components/Release/IssueGroup.tsx b/packages/docs/src/components/Release/IssueGroup.tsx
new file mode 100644
index 00000000..a95c7b72
--- /dev/null
+++ b/packages/docs/src/components/Release/IssueGroup.tsx
@@ -0,0 +1,21 @@
+import styles from '@site/src/components/Release/styles.module.css';
+import React, {ReactNode} from 'react';
+
+export interface IssueGroupProps {
+ type: 'feat' | 'fix';
+ children: ReactNode | ReactNode[];
+}
+
+const titles = {
+ feat: 'New features',
+ fix: 'Fixed bugs',
+};
+
+export default function IssueGroup({type, children}: IssueGroupProps) {
+ return (
+ <>
+ <h3>{titles[type]}</h3>
+ <ul className={styles.group}>{children}</ul>
+ </>
+ );
+}
diff --git a/packages/docs/src/components/Release/PullRequest.tsx b/packages/docs/src/components/Release/PullRequest.tsx
new file mode 100644
index 00000000..09433603
--- /dev/null
+++ b/packages/docs/src/components/Release/PullRequest.tsx
@@ -0,0 +1,19 @@
+import React from 'react';
+import styles from './styles.module.css';
+
+export interface PullRequestProps {
+ id: number;
+}
+
+export default function PullRequest({id}: PullRequestProps) {
+ return (
+ <a
+ className={styles.pr}
+ title={`Pull request #${id}`}
+ href={`https://github.com/motion-canvas/motion-canvas/pull/${id}`}
+ target="_blank"
+ >
+ <small>#{id}</small>
+ </a>
+ );
+}
diff --git a/packages/docs/src/components/Release/styles.module.css b/packages/docs/src/components/Release/styles.module.css
new file mode 100644
index 00000000..ecc4e52e
--- /dev/null
+++ b/packages/docs/src/components/Release/styles.module.css
@@ -0,0 +1,24 @@
+.contributor {
+ display: inline-flex;
+ background-color: var(--ifm-background-surface-color);
+ vertical-align: middle;
+ margin-left: calc(-20px - 0.6rem);
+ margin-right: 0.6rem;
+ border-radius: 50%;
+ overflow: hidden;
+}
+
+.pr {
+ display: inline-flex;
+ background-color: var(--ifm-background-surface-color);
+ border-radius: 10px;
+ vertical-align: middle;
+ line-height: 20px;
+ padding: 0 0.5rem;
+ margin-left: 0.25rem;
+}
+
+.element {
+ list-style: none;
+ margin-bottom: 0.5rem;
+}