mirror of
https://github.com/spectreconsole/spectre.console.git
synced 2025-12-27 16:28:00 +01:00
Add initial docs
This commit is contained in:
committed by
Patrik Svensson
parent
decb887b0a
commit
f1912b1d44
34
docs/src/Shortcodes/ChildrenShortcode.cs
Normal file
34
docs/src/Shortcodes/ChildrenShortcode.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using Statiq.Common;
|
||||
using System.Xml.Linq;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user