feat: private posts
Some checks failed
Release / publish (push) Failing after 2m44s

This commit is contained in:
2025-10-17 23:51:19 +02:00
parent 68574ad289
commit 192d95b1bf
5 changed files with 49 additions and 2 deletions

View File

@@ -12,7 +12,7 @@
<section class="grid grid-cols-1 gap-5 m-5">
<article
*ngFor="let post of posts()"
class="p-5 grid grid-cols-5 grid-rows-3 items-start rounded-s bg-white drop-shadow-md hover:drop-shadow-lg"
class="p-5 grid grid-cols-5 grid-rows-3 items-start rounded-s bg-white drop-shadow-md hover:drop-shadow-lg gap-5"
>
<h3 class="text-xl col-span-4">{{ post.title }}</h3>
<p class="col-start-1 col-span-4 row-start-2 row-span-2">
@@ -31,5 +31,14 @@
>
Delete
</app-button>
@if (post.secret !== undefined) {
<app-button
(click)="getPath(post.secret)"
class="col-start-5 row-start-2"
color="yellow"
>
Copy Link
</app-button>
}
</article>
</section>

View File

@@ -17,4 +17,8 @@ export class DashboardComponent {
delete(id: number) {
this.postsService.deletePost(id);
}
getPath(secret: string) {
const url = document.URL.replaceAll('/dashboard', '');
navigator.clipboard.writeText(`${url}/post/secret/${secret}`);
}
}

View File

@@ -1,6 +1,5 @@
import { Component, inject, Input } from '@angular/core';
import { PostsService } from '../../shared/services/posts.service';
import { JsonPipe, NgIf } from '@angular/common';
import { MarkdownComponent } from '../../components/markdown/markdown.component';
@Component({

View File

@@ -0,0 +1,7 @@
<h2 class="text-3xl">{{ post()?.title }}</h2>
<p class="mb-5 italic text-sm">TL;DR; {{ post()?.tldr }}</p>
<app-markdown
class="todo"
[markdown]="post()?.content || 'this post is empty'"
/>

View File

@@ -0,0 +1,28 @@
import {
Component,
inject,
Input,
OnInit,
signal,
WritableSignal,
} from '@angular/core';
import { PostsService } from '../../../shared/services/posts.service';
import { Post } from '../../../shared/interfaces/post';
import { MarkdownComponent } from '../../../components/markdown/markdown.component';
@Component({
selector: 'app-secret-post',
imports: [MarkdownComponent],
templateUrl: './secret-post.component.html',
})
export class SecretPostComponent implements OnInit {
@Input() secret!: string;
private postsService = inject(PostsService);
post: WritableSignal<Post | undefined> = signal(undefined);
ngOnInit(): void {
this.postsService.getPostBySecret(this.secret).subscribe((post) => {
this.post.set(post);
});
}
}