Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
@page "/post/{Slug}"
@inject HttpClient Http
@inject NavigationManager NavigationManager
@using System.Text.Json.Serialization
@using Models
@if (postDetails != null && == null)
<section class="text-gray-700 body-font">
<div class="container mx-auto flex px-5 pb-24 items-center justify-center flex-col">
<h1 class="title-font sm:text-4xl text-3xl mb-4 font-medium text-gray-900"></h1>
<img class=" mb-10 object-cover object-center rounded" alt="hero" src="">
<div class=" w-full">
<div class="mb-8 leading-relaxed">@((MarkupString)</div>
<div class="p-2 w-full">
<button class="flex mx-auto text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-none hover:bg-indigo-600 rounded text-lg" @onclick="NavigateToIndexComponent">Back</button>
@code {
[Parameter] public string Slug { get; set; }
private PostDetail postDetails = new PostDetail();
protected override async Task OnInitializedAsync()
var url = $"{Slug}?pretty=true&hide_metafields=true";
postDetails = await Http.GetFromJsonAsync<PostDetail>(url.Replace("{Slug}", Slug)); = + "?w=720&h=600";
private void NavigateToIndexComponent()
public class PostDetail
public Post post { get; set; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment