Skip to content

Commit 394df4d

Browse files
committed
Add custom metadata example
1 parent 412800a commit 394df4d

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

MyApp/_pages/releases/v8_08.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,4 +335,42 @@ preferable if you never need to access the underlying `JsonElement`:
335335
```csharp
336336
var obj = JSON.parse(json);
337337
obj.PrintDump();
338-
```
338+
```
339+
340+
## Custom Metadata Examples
341+
342+
You can now customize the Example Objects used in the metadata pages with the new `CreateExampleObjectFn` property on the `MetadataFeature` plugin which you can customize like:
343+
344+
```csharp
345+
services.ConfigurePlugin<MetadataFeature>(feature => {
346+
feature.CreateExampleObjectFn = type => {
347+
if (type == typeof(CreateJob))
348+
{
349+
return new CreateJob {
350+
Title = "Example Job",
351+
Company = "Acme",
352+
Description = "Job Description",
353+
SalaryRangeLower = 50_000,
354+
SalaryRangeUpper = 100_000,
355+
};
356+
}
357+
if (type == typeof(Job))
358+
{
359+
return new Job {
360+
Id = 1,
361+
Description = "Job Description",
362+
Company = "Acme",
363+
SalaryRangeLower = 50_000,
364+
SalaryRangeUpper = 100_000,
365+
CreatedBy = "Admin",
366+
CreatedDate = DateTime.UtcNow.Date,
367+
};
368+
}
369+
return null; // default behavior
370+
};
371+
});
372+
```
373+
374+
This will use these example objects in the [metadata pages](/metadata-page) instead of the default auto-generated examples.
375+
376+
![](/img/pages/release-notes/v8.8/metadata-example-object.webp)
Binary file not shown.

0 commit comments

Comments
 (0)