Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: global custom container header #3044

Merged
merged 1 commit into from
Oct 7, 2023
Merged

feat: global custom container header #3044

merged 1 commit into from
Oct 7, 2023

Conversation

djdjz7
Copy link
Contributor

@djdjz7 djdjz7 commented Oct 3, 2023

As mentioned in #3041 , this comment adds global custom container header entry.
Usage:

// config.ts
export default defineConfig({
// ...
  markdown: {
    math: true,
    container: {
      tipLabel: "提示",
      warningLabel: "警告",
      dangerLabel: "危险",
      infoLabel: "信息",
      detailsLabel: "详细信息"
    }
  },
// ...
})

@brc-dd brc-dd merged commit bdb0800 into vuejs:main Oct 7, 2023
2 checks passed
@pberto
Copy link

pberto commented Oct 13, 2023

Hi @brc-dd, @djdjz7

I'd like to suggest some improvements here.

The default behavior of custom boxes is that if you type:

:::info
blah blah
:::

A custom box with the default label INFO (or with the "custom default label" provided by this very new feature in config.ts) will be rendered.

Now, I just tried to use this feature and instead of a custom label text use an icon, this works too:

image
  markdown: {
    math: true,
    container: {
      infoLabel: '<iconify-icon icon="jam:info" />'
    }
  }

But what I believe we should really have is both behaviors, that is being able to use a custom label icon but still be able to append words for the title in markdown to obtain:

image

pseudo md code:

:::info info
blah blah
:::

:::danger Windows Threading
blah blah
:::

Currently the only way to obtain this is doing the following (which is ugly):

:::info <iconify-icon icon="jam:info" /> Info 
blah blah
:::

:::danger <iconify-icon icon="jam:triangle-danger" /> Windows Threading 
blah blah
:::

So to recap this feature should be designed this way:

// ...
  markdown: {
    math: true,
    container: {
      infoLabel: "信息", // default is INFO when not specified
      infoIcon": "ⓘ" // default is empty string when not specified
    }
  },
// ...

This will allow to produce:

:::info --> INFO (where the default INFO can be overridden in config)
:::info MyInfo --> MyInfo (where the default INFO is overridden with MyInfo inline)
:::info --> (where ⓘ was defined in config)
:::info Myinfo --> ⓘ MyInfo (where ⓘ was defined in config and the default INFO is overridden with MyInfo inline)

Last but not least I believe when an icon is specified text should be indented this way (I am trying to find where this could be defined btw...)

image

@brc-dd
Copy link
Member

brc-dd commented Oct 13, 2023

Visual indicators should be added via CSS not markdown.

@brc-dd
Copy link
Member

brc-dd commented Oct 13, 2023

@pberto
Copy link

pberto commented Oct 13, 2023

Ok , I solved it with css.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants