Display Git Version in Angular UI via Build-Time Injection

This commit is contained in:
adityachandelgit
2025-04-15 23:44:34 -06:00
committed by Aditya Chandel
parent 29eb9d305d
commit 1c5ebea70f
5 changed files with 58 additions and 24 deletions
@@ -8,6 +8,7 @@ import {map} from 'rxjs/operators';
import {ShelfService} from '../../../book/service/shelf.service';
import {BookService} from '../../../book/service/book.service';
import {LibraryShelfMenuService} from '../../../book/service/library-shelf-menu.service';
import {version} from '../../../../environments/version';
@Component({
selector: 'app-menu',
@@ -24,6 +25,8 @@ export class AppMenuComponent implements OnInit {
private bookService = inject(BookService);
private libraryShelfMenuService = inject(LibraryShelfMenuService);
protected readonly version = version;
ngOnInit(): void {
this.libraryMenu$ = this.libraryService.libraryState$.pipe(
@@ -86,4 +89,12 @@ export class AppMenuComponent implements OnInit {
);
}
getVersionUrl(version: string): string {
if (version.startsWith('v')) {
return `https://github.com/adityachandelgit/BookLore/releases/tag/${version}`;
} else {
return `https://github.com/adityachandelgit/BookLore/commit/${version}`;
}
}
}