Skip to content

Commit

Permalink
feat(release-notes): add support for release notes as array
Browse files Browse the repository at this point in the history
  • Loading branch information
EdricChan03 committed Nov 13, 2019
1 parent e923f97 commit 7784351
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ <h2 id="version-{{ version }}">
<ng-container *ngIf="isStr(releaseNote) && isUrl(releaseNote)">
<p>See this <a [href]="releaseNote">link</a> for the release notes.</p>
</ng-container>
<ng-container *ngIf="!isStr(releaseNote)">
<ng-container *ngIf="!isStr(releaseNote) && isObj(releaseNote)">
<ng-container *ngIf="isArray(releaseNote.summary)">
<p [innerHTML]="joinReleaseNotes(releaseNote.summary) | markdown"></p>
</ng-container>
<ng-container *ngIf="!isArray(releaseNote.summary) && isUrl(releaseNote.summary)">
<p>See this <a [href]="releaseNote.summary">link</a> for more info.</p>
</ng-container>
</ng-container>
<ng-container *ngIf="!isStr(releaseNote) && isArray(releaseNote)">
<p [innerHTML]="joinReleaseNotes(releaseNote) | markdown"></p>
</ng-container>
</ng-container>
</ng-container>
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,32 +77,23 @@ export class ReleaseNotesComponent implements OnInit {
return notes.join('\n');
}

/**
* Checks if the specified `val` parameter is an array.
* @param val The value to check.
*/
isArray(val: any): boolean {
return Array.isArray(val);
}

/**
* Checks whether the specified `val` parameter is a URL.
* @param val The value to check.
*
* _See https://stackoverflow.com/a/46296668/6782707 for more info._
*/
// See https://stackoverflow.com/a/46296668/6782707 for more info.
isUrl(val: string): boolean {
return /^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+$/.test(val);
}

/**
* Checks whether the specified `val` parameter is a string.
* @param val The value to check.
*/
isStr(val: any): boolean {
return typeof val === 'string';
}

isObj(val: any): boolean {
return typeof val === 'object';
}

ngOnInit() {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type ReleaseNotes = {
summary: string[] | string;
/** A detailed version of the release notes. */
details?: string[] | string;
} | string;
} | string[] | string;

export type ReleaseType = 'stable' | 'beta' | 'nightly';

Expand Down
6 changes: 6 additions & 0 deletions projects/rss-reader/src/assets/release-notes-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,12 @@
{
"type": "string",
"format": "uri"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
},
Expand Down

0 comments on commit 7784351

Please sign in to comment.