Skip to content

Commit 8b9199d

Browse files
committed
updated instructions to create markdown page
1 parent 17da273 commit 8b9199d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

hub/powertoys/command-palette/using-markdown-content.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ So far, we've only shown how to display a list of commands in a **ListPage**. Ho
1717

1818
[IContentPage](./microsoft-commandpalette-extensions/icontentpage.md) (and its toolkit implementation, [ContentPage](microsoft-commandpalette-extensions-toolkit/contentpage.md)) is the base for displaying all types of rich content in the Command Palette. To display markdown content, you can use the [MarkdownContent](microsoft-commandpalette-extensions-toolkit/markdowncontent.md) class.
1919

20-
1. In your <ExtensionName>Page.cs, replace content with:
20+
1. In the `Pages` directory, add a new class
21+
1. Name the class `MarkdownPage.cs`
22+
1. Update the file to:
2123

2224
```csharp
23-
internal sealed partial class <ExtensionName>Page : ContentPage
25+
using Microsoft.CommandPalette.Extensions;
26+
using Microsoft.CommandPalette.Extensions.Toolkit;
27+
using System.Text.Json.Nodes;
28+
29+
internal sealed partial class MarkdownPage : ContentPage
2430
{
25-
public <ExtensionName>Page()
31+
public MarkdownPage()
2632
{
2733
Icon = new("\uE8A5"); // Document icon
2834
Title = "Markdown page";
@@ -38,12 +44,27 @@ internal sealed partial class <ExtensionName>Page : ContentPage
3844
}
3945
```
4046

47+
1. Open <ExtensionName>CommandsProvider.cs
48+
1. Replace the `CommandItem`s for the `MarkdownPage`:
49+
50+
```diff
51+
public <ExtensionName>CommandsProvider()
52+
{
53+
DisplayName = "My sample extension";
54+
Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.png");
55+
_commands = [
56+
+ new CommandItem(new MarkdownPage()) { Title = DisplayName },
57+
];
58+
}
59+
60+
```
61+
4162
1. Deploy your extension
4263
1. In command palette, `Reload`
4364

4465
In this example, a new `ContentPage` that displays a simple markdown string is created. The 'MarkdownContent' class takes a string of markdown content and renders it in the Command Palette.
4566

46-
![Screenshot of extension using ContentPage](../../images/command-palette/markdown.png)
67+
![Screenshot of extension using ContentPage for markdown](../../images/command-palette/markdown.png)
4768

4869
You can also add multiple blocks of content to a page. For example, you can add two blocks of markdown content.
4970

0 commit comments

Comments
 (0)