Skip to content

Commit

Permalink
sort by sticky blogposts
Browse files Browse the repository at this point in the history
  • Loading branch information
ortwic committed Apr 11, 2024
1 parent 9d73b1a commit 2c590c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app/models/blog.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface BlogPost {
status: 'published' | 'beta' | 'draft';
publish_date: Date;
created_on: Date;
reviewed: boolean;
sticky: boolean;
}

type BlogContent = MarkdownContent
Expand Down
5 changes: 3 additions & 2 deletions src/app/services/blog.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { orderBy, where } from '@angular/fire/firestore';
import { Observable, of } from 'rxjs';
import { Observable, map, of } from 'rxjs';
import { FirestoreService } from './firestore.service';
import { BlogPost } from '../models/blog.model';

Expand All @@ -17,6 +17,7 @@ export class BlogService extends FirestoreService {

constructor() {
super('blog');
this.data$ = super.getDocumentStream(...this.constraints);
this.data$ = super.getDocumentStream<BlogPost>(...this.constraints)
.pipe(map(arr => arr.sort((a) => a.sticky ? -1 : 1)));
}
}

0 comments on commit 2c590c7

Please sign in to comment.