Skip to content

Commit

Permalink
🃏 Add card documentation and alias to link/url (#1521)
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanc1 committed Sep 9, 2024
1 parent c758f1b commit 0a516e5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-cougars-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"myst-ext-card": patch
---

Add documentation and an alias for url/link in cards.
12 changes: 9 additions & 3 deletions packages/myst-ext-card/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@ export const cardDirective: DirectiveSpec = {
alias: ['grid-item-card'],
arg: {
type: 'myst',
doc: 'The title of the card, usually shown as bolded text at the top of the card.',
},
options: {
link: {
url: {
type: String,
alias: ['link'],
doc: 'Turns the card into a link, can be internal or external.',
},
header: {
type: 'myst',
doc: 'Adds a header to the card.',
},
footer: {
type: 'myst',
doc: 'Adds a footer to the card.',
},
// // https://sphinx-design.readthedocs.io/en/furo-theme/cards.html#card-options
// width
Expand Down Expand Up @@ -48,9 +53,10 @@ export const cardDirective: DirectiveSpec = {
body: {
type: 'myst',
required: true,
doc: 'Main body content of the card.',
},
run(data: DirectiveData): GenericNode[] {
const { link, header, footer } = data.options || {};
const { url, header, footer } = data.options || {};
let headerChildren: GenericNode[];
let bodyChildren: GenericNode[];
let footerChildren: GenericNode[];
Expand Down Expand Up @@ -89,7 +95,7 @@ export const cardDirective: DirectiveSpec = {
return [
{
type: 'card',
url: link as string | undefined,
url: url as string | undefined,
children,
},
];
Expand Down

0 comments on commit 0a516e5

Please sign in to comment.