fix: hide non-published entries
Some checks failed
.NET / Build & Test (push) Failing after 44s

This commit is contained in:
Oliver Booth 2024-04-26 17:23:53 +01:00
parent 238f519e0c
commit 05638e5deb
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
2 changed files with 15 additions and 5 deletions

View File

@ -1,7 +1,7 @@
@page "/tutorial/{**slug}" @page "/tutorial/{**slug}"
@using Humanizer @using Humanizer
@using Microsoft.AspNetCore.Mvc.TagHelpers @using Microsoft.AspNetCore.Mvc.TagHelpers
@using OliverBooth.Data.Blog @using OliverBooth.Data
@using OliverBooth.Data.Web @using OliverBooth.Data.Web
@using OliverBooth.Services @using OliverBooth.Services
@inject ITutorialService TutorialService @inject ITutorialService TutorialService
@ -64,7 +64,9 @@
<div class="row"> <div class="row">
<div class="col-sm-12 col-md-6"> <div class="col-sm-12 col-md-6">
@if (article.PreviousPart is { } previousPartId && TutorialService.TryGetArticle(previousPartId, out ITutorialArticle? previousPart)) @if (article.PreviousPart is { } previousPartId &&
TutorialService.TryGetArticle(previousPartId, out ITutorialArticle? previousPart) &&
previousPart.Visibility == Visibility.Published)
{ {
<small>Previous Part</small> <small>Previous Part</small>
<p class="lead"> <p class="lead">
@ -75,7 +77,9 @@
} }
</div> </div>
<div class="col-sm-12 col-md-6" style="text-align: right;"> <div class="col-sm-12 col-md-6" style="text-align: right;">
@if (article.NextPart is { } nextPartId && TutorialService.TryGetArticle(nextPartId, out ITutorialArticle? nextPart)) @if (article.NextPart is { } nextPartId &&
TutorialService.TryGetArticle(nextPartId, out ITutorialArticle? nextPart) &&
nextPart.Visibility == Visibility.Published)
{ {
<small>Next Part</small> <small>Next Part</small>
<p class="lead"> <p class="lead">

View File

@ -1,5 +1,6 @@
@page "/tutorials/{**slug}" @page "/tutorials/{**slug}"
@using System.Text @using System.Text
@using OliverBooth.Data
@using OliverBooth.Data.Web @using OliverBooth.Data.Web
@using OliverBooth.Services @using OliverBooth.Services
@model Index @model Index
@ -31,11 +32,16 @@
} }
<h1 class="display-4">@(currentFolder?.Title ?? "Tutorials")</h1> <h1 class="display-4">@(currentFolder?.Title ?? "Tutorials")</h1>
@foreach (ITutorialFolder[] folders in TutorialService.GetFolders(currentFolder).Chunk(2)) @foreach (ITutorialFolder[] folders in TutorialService.GetFolders(currentFolder, Visibility.Published).Chunk(2))
{ {
<div class="card-group row" style="margin-top: 20px;"> <div class="card-group row" style="margin-top: 20px;">
@foreach (ITutorialFolder folder in folders) @foreach (ITutorialFolder folder in folders)
{ {
if (folder.Visibility != Visibility.Published)
{
continue;
}
<div class="col-xs-1 col-md-6 col-lg-6 d-flex align-items-stretch"> <div class="col-xs-1 col-md-6 col-lg-6 d-flex align-items-stretch">
<div class="project-card"> <div class="project-card">
<div class="project-image"> <div class="project-image">
@ -54,7 +60,7 @@
@if (currentFolder is not null) @if (currentFolder is not null)
{ {
foreach (ITutorialArticle[] articles in TutorialService.GetArticles(currentFolder).Chunk(2)) foreach (ITutorialArticle[] articles in TutorialService.GetArticles(currentFolder, Visibility.Published).Chunk(2))
{ {
<div class="card-group row" style="margin-top: 20px;"> <div class="card-group row" style="margin-top: 20px;">
@foreach (ITutorialArticle article in articles) @foreach (ITutorialArticle article in articles)