🐛 Fix some stupid bugs
This commit is contained in:
@@ -144,7 +144,7 @@
|
||||
|
||||
@if (Model.Post.Categories.Any() || (Model.Post.Tags.Any()))
|
||||
{
|
||||
<div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
@foreach (var category in Model.Post.Categories)
|
||||
{
|
||||
<span class="badge badge-primary">
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
using DysonNetwork.Shared.Models;
|
||||
using DysonNetwork.Shared.Proto;
|
||||
using DysonNetwork.Zone.Publication;
|
||||
// Add this using statement
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using PostType = DysonNetwork.Shared.Proto.PostType;
|
||||
|
||||
namespace DysonNetwork.Zone.Pages.Posts;
|
||||
|
||||
public class DetailsModel(PostService.PostServiceClient postClient, MarkdownConverter markdownConverter) : PageModel
|
||||
public class DetailsModel(
|
||||
PostService.PostServiceClient postClient,
|
||||
MarkdownConverter markdownConverter
|
||||
) : PageModel
|
||||
{
|
||||
[FromRoute] public string Slug { get; set; } = null!;
|
||||
[FromRoute]
|
||||
public string Slug { get; set; } = null!;
|
||||
|
||||
public SnPublicationSite? Site { get; set; }
|
||||
public SnPost? Post { get; set; }
|
||||
@@ -23,8 +25,10 @@ public class DetailsModel(PostService.PostServiceClient postClient, MarkdownConv
|
||||
return NotFound();
|
||||
|
||||
var request = new GetPostRequest { PublisherId = Site!.PublisherId.ToString() };
|
||||
if (Guid.TryParse(Slug, out var guid)) request.Id = guid.ToString();
|
||||
else request.Slug = Slug;
|
||||
if (Guid.TryParse(Slug, out var guid))
|
||||
request.Id = guid.ToString();
|
||||
else
|
||||
request.Slug = Slug;
|
||||
var response = await postClient.GetPostAsync(request);
|
||||
|
||||
if (response == null)
|
||||
@@ -35,10 +39,13 @@ public class DetailsModel(PostService.PostServiceClient postClient, MarkdownConv
|
||||
Post = SnPost.FromProtoValue(response);
|
||||
|
||||
// Convert the markdown content to HTML
|
||||
if (Post != null && !string.IsNullOrEmpty(Post.Content))
|
||||
Post.Content = markdownConverter.ToHtml(Post.Content,
|
||||
softBreaks: Post.Type != DysonNetwork.Shared.Models.PostType.Article);
|
||||
if (Post is not null && !string.IsNullOrEmpty(Post.Content))
|
||||
Post.Content = markdownConverter.ToHtml(
|
||||
Post.Content,
|
||||
softBreaks: Post.Type != DysonNetwork.Shared.Models.PostType.Article
|
||||
);
|
||||
|
||||
return Page();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
|
||||
@if (Model.Categories.Any() || Model.Tags.Any())
|
||||
{
|
||||
<div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
@foreach (var category in Model.Categories)
|
||||
{
|
||||
<span class="badge badge-primary">
|
||||
@@ -86,4 +86,4 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -18,6 +18,7 @@ public class MarkdownConverter
|
||||
var procMarkdown = markdown.Replace("solian://files/", "/drive/files");
|
||||
return string.IsNullOrEmpty(procMarkdown)
|
||||
? string.Empty
|
||||
: Markdown.ToHtml(markdown, softBreaks ? _pipelineSoftBreak : _pipeline);
|
||||
: Markdown.ToHtml(procMarkdown, softBreaks ? _pipelineSoftBreak : _pipeline);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user