mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00

* Adding a dark mode * Adding reference for types to summary pages * Adding API Reference * Adding modifiers to methods/fields/etc * Minimizing files input * Caching a lot of the output pages * Cache only for each execution * Adding API references to existing docs
35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using Statiq.Common;
|
|
using System.Xml.Linq;
|
|
using Docs.Extensions;
|
|
|
|
namespace Docs.Shortcodes
|
|
{
|
|
public class ChildrenShortcode : SyncShortcode
|
|
{
|
|
public override ShortcodeResult Execute(KeyValuePair<string, string>[] args, string content, IDocument document, IExecutionContext context)
|
|
{
|
|
var ul = new XElement("ul", new XAttribute("class", "list-group"));
|
|
|
|
foreach (var child in document.GetChildren().OnlyVisible())
|
|
{
|
|
var li = new XElement("li", new XAttribute("class", "list-group-item"));
|
|
|
|
var link = new XElement("a", new XAttribute("href", child.GetLink()));
|
|
link.Add(child.GetTitle());
|
|
li.Add(link);
|
|
|
|
var description = child.GetDescription();
|
|
if (description.IsNotEmpty())
|
|
{
|
|
li.Add(new XElement("br"));
|
|
li.Add(new XElement("i", description));
|
|
}
|
|
|
|
ul.Add(li);
|
|
}
|
|
|
|
return ul.ToString();
|
|
}
|
|
}
|
|
} |