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

Document and define ProseCodeInline's props #2116

Closed
texastoland opened this issue Jun 23, 2023 · 11 comments
Closed

Document and define ProseCodeInline's props #2116

texastoland opened this issue Jun 23, 2023 · 11 comments
Labels
enhancement New feature or request

Comments

@texastoland
Copy link

texastoland commented Jun 23, 2023

Is your feature request related to a problem? Please describe

https://github.com/nuxt/content/blob/main/src/runtime/components/Prose/ProseCodeInline.vue doesen't document or define props.

Describe the solution you'd like

  • Define props to help when creating a custom version
  • Standardize on either lang or language like ProseCode
  • Accept meta like ProseCode
    (ProseCode uses a special syntax but ProseCodeInline doesn't need it)
  • Document props

Additional context

Where language is read for Shiki:

(node: any) => (node?.tag === 'code' && node?.props.code) || (node?.tag === 'code-inline' && (node.props?.lang || node.props?.language)),

@texastoland texastoland added the enhancement New feature or request label Jun 23, 2023
@helltraitor
Copy link

As I can assume, there is no standards except. You already can use highlighting for inline code and meta for this too!

Let this is your markdown

Something interested text with `inlineFunction({ awesome: true })`{lang=ts key=value}

It works out of the box.

Moreover, you can modify / assert passed properties via mapping data type
https://github.com/helltraitor/helltraitor.github.io/blob/nuxt/pages/posts/%5B...slug%5D.vue

In my case, I receive and pass the data as is. But I definitely will use assertions (like I post models that cause explicit 500 error):
I don't like when I don't know which properties passes.

In case if you still have issues with out-of-the-box highlighting, I can text you back

This is my content settings
https://github.com/helltraitor/helltraitor.github.io/blob/nuxt/nuxt.config.ts

@texastoland
Copy link
Author

My issue is primarily about documentation and props for discoverability. Good point about meta though. I removed that bullet 👍🏼

@nobkd
Copy link
Contributor

nobkd commented Jun 25, 2023

The syntax used for the meta and lang here is the normal syntax for props in MDC. It's the implementation for ProseCode differs from the normal implementation.

Also, lang for ProseCodeInline is documented, but probably a bit hard to find: https://content.nuxtjs.org/api/components/prose#prosecodeinline


But I agree, that it would be probably best to standardize either lang or language and define props in the component file

@texastoland
Copy link
Author

texastoland commented Jun 25, 2023

It's the implementation for ProseCode differs from the normal implementation.

Good point about meta though. I removed that bullet 👍🏼

it would be probably best to standardize either lang or language

In documentation and props yes but the implementation should remain flexible.

and define props in the component file

Exactly. My goal is to help people overriding it. I got lost in the source to figure out why the documentation shows language for 1 but lang the other while ProseCodeInnline doesn't even declare props. Just want to make it more approachable!

I'm brand new to Nuxt in general. I love it but the docs often feel sparse.

Copy link
Member

atinux commented Jun 26, 2023

If you see an improvement, please feel free to open a PR @texastoland 😊

@texastoland
Copy link
Author

texastoland commented Jun 26, 2023

May I standardize on language for both components in the docs and props (but not internal implementation)?

@nobkd
Copy link
Contributor

nobkd commented Jun 26, 2023

I'd prefer lang as it's shorter.
I know, that both would still be possible, but the implementation, that is known, is used.
Personally, I wouldn't want to write language= every time I add a language to an inline code.

But I can also see, that language is the more descriptive name.

@texastoland
Copy link
Author

texastoland commented Jun 26, 2023

I prefer lang too even though language has better DX. I'll add both as aliases to one another and document that lang overrides language if both are present. PR coming.

@nobkd
Copy link
Contributor

nobkd commented Jul 27, 2023

@texastoland do you still plan to open a PR?

@texastoland
Copy link
Author

Yeah sorry I'll get it ASAP 🙏🏼

@texastoland
Copy link
Author

Closing for now but I'll grab it next time I use this API 🤘🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants