Skip to content

Commit 1f1444e

Browse files
committed
parse markdown in type descriptions
1 parent b2d43ad commit 1f1444e

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

src/pages/docs/[version]/types/[module]/[type].astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const superLink = type.super ? getQMLTypeLink(version.name, type.super) : null;
2828
const details = type.details
2929
? await processMarkdown(version.name, type.details)
3030
: null;
31+
32+
const description = type.description
33+
? await processMarkdown(version.name, type.description)
34+
: null;
3135
---
3236
<DocsLayout title={`${module.name} - ${type.name}`} description={type.description ?? ""} type={type}>
3337
<div class="docs">
@@ -57,7 +61,7 @@ const details = type.details
5761
<code class="type-module" data-pagefind-ignore>import {module.name}</code>
5862
<section class="typedocs-data typedata">
5963
<subheading class="typedocs-subheading">
60-
{details ? <span class="parsedMD" set:html={details}/> : (<span class="toparse">{type.description}</span>)}
64+
{details ? <span class="parsedMD" set:html={details}/> : <span class="parsedMD" set:html={description}/>}
6165
</subheading>
6266
{ Object.keys(type.properties ?? {}).length != 0 && (
6367
<h2>Properties <a href={`/docs/${version.name}/guide/qml-language#properties`}>[?]</a></h2>

src/pages/docs/[version]/types/[module]/index.astro

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ const { version, module } = Astro.props;
1616
const details = module.details
1717
? await processMarkdown(version.name, module.details)
1818
: null;
19+
20+
const types = await Promise.all(module.types.map(async type => ({
21+
description2: type.description ? await processMarkdown(version.name, type.description) : null,
22+
...type
23+
})));
1924
---
2025

2126
<DocsLayout
@@ -28,13 +33,13 @@ const details = module.details
2833
<section>
2934
<span>{module.description}</span>
3035
<div class="root-nav" data-pagefind-ignore>
31-
{module.types.map(type =>
36+
{types.map(type =>
3237
(
3338
<div class="root-nav-entry">
3439
<a class="root-nav-link" href={`/docs/${version.name}/types/${module.name}/${type.name}`}>
3540
{type.name}
3641
</a>
37-
<span class="root-nav-desc">{type.description}</span>
42+
{type.description2 && <span class="root-nav-desc" set:html={type.description2}/>}
3843
</div>
3944
)
4045
)}

src/styles/docs/docs-types.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ html.dark .typevariants {
341341
& .root-nav-desc {
342342
padding-left: 1rem;
343343
border-left: 1px solid hsl(var(--blue) 10% 15% / 0.6);
344+
345+
/* for processMarkdown in desc strs*/
346+
& > p { margin: 0 }
344347
}
345348
}
346349
}

0 commit comments

Comments
 (0)