Post Count #230
Answered
by
girlpunk
AlexHedley
asked this question in
Q&A
Post Count
#230
-
If I wanted to create a custom page to show some stats is there a way to get the total post count? I must be missing something obvious: @(Outputs.FromPipeline(nameof(Content)).Flatten().FilterSources($"posts/*")).Count()
Code
For each Year I have, which works great. @* Years Count *@
@foreach(IGrouping<int, IDocument> group in Outputs
.FromPipeline(nameof(Content))
.Flatten()
.FilterSources($"posts/*")
.GroupBy(x => x.GetDateTime(WebKeys.Published).Year)
.OrderByDescending(x => x.Key))
{
<h1 class="bg-dark text-light p-2">@group.Key <span class="postCount">@group.Count()</span></h1>
} |
Beta Was this translation helpful? Give feedback.
Answered by
girlpunk
Dec 20, 2024
Replies: 1 comment 1 reply
-
Your initial code looks correct, bar an incorrect bracket placement. We can rewrite it as: @(
Outputs.FromPipeline(
nameof(Content)
)
.Flatten()
.FilterSources($"posts/*")
)
.Count() Moving that penultimate closing bracket to after the count call should resolve the issue, like so: @(Outputs.FromPipeline(nameof(Content)).Flatten().FilterSources($"posts/*").Count()) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
AlexHedley
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Your initial code looks correct, bar an incorrect bracket placement. We can rewrite it as:
Moving that penultimate closing bracket to after the count call should resolve the issue, like so: