Skip to content

docs(readme): draft changes for clarifying options#60

Open
julie-ng wants to merge 2 commits intopi0:mainfrom
julie-ng:patch-1
Open

docs(readme): draft changes for clarifying options#60
julie-ng wants to merge 2 commits intopi0:mainfrom
julie-ng:patch-1

Conversation

@julie-ng
Copy link

@julie-ng julie-ng commented Jan 7, 2026

Suggestions for improving the documentation on how to configure nuxt-shiki based on feedback from #25

@gxres042 - while making suggestions, I realized I don't understand how highlightOptions works. Based on types.ts, it looks like it's just a unwrap boolean? Is that it? If you can provide a reference to a doc, I can suggest something.

Feel free to edit as you see fit.

@gxres042
Copy link
Collaborator

gxres042 commented Jan 8, 2026

@gxres042 - while making suggestions, I realized I don't understand how highlightOptions works. Based on types.ts, it looks like it's just a unwrap boolean? Is that it? If you can provide a reference to a doc, I can suggest something.

type CodeToHastOptions<Languages extends string = string, Themes extends string = string> = CodeToHastOptionsCommon<Languages> & CodeOptionsThemes<Themes> & CodeOptionsMeta;

Hmmm you may set highlight themes via highlightOptions.theme in <Shiki /> component.

```

> [!NOTE]
> Themes can only be configured via the `defaultTheme` option. It is not possible to override themes in the `<Shiki>` component.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I make a mistake...... You can override highlight theme by setting highlightOptions.themes on <Shiki /> component.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? Maybe I am doing it wrong… but I have tried theme and :highlightOptions (as well as :highlight-options), and none of those work for me.

Although I am in my browser's default light mode, with the code above I would expect to see a dark themed code block. But, I still get the light theme.

<Shiki v-if="data" lang="json" :code="JSON.stringify(data, null, 2)" theme="material-theme-palenight" />
<Shiki v-if="data" lang="json" :code="JSON.stringify(data, null, 2)" :highlightOptions="{ theme: 'material-theme-palenight' }" />

What would be the correct syntax if we want to have a custom theme on a per component basis?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<script setup lang="ts">
const code = ref<string>(/* js */ `
// Try editing in the left panel!
console.log('Hello, World!')
`)
const highlightOptions = ref({
  themes: {
    light: 'one-light',
    dark: 'one-dark-pro',
  },
})
</script>

<template>
  <Shiki id="shiki" lang="js" :highlight-options="highlightOptions" :code="code" />
</template>

or

<script setup lang="ts">
const code = ref<string>(/* js */ `
// Try editing in the left panel!
console.log('Hello, World!')
`)
const highlightOptions = ref({
  theme: 'one-dark-pro',
})
</script>

<template>
  <Shiki id="shiki" lang="js" :highlight-options="highlightOptions" :code="code" />
</template>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants