Skip to content

reactive theme #22

@amery

Description

@amery

hi, I'm fairly new to this world the following snippet will likely make you sick, but I'm trying to render (client-side) an xml file on an app using @nuxt/ui, unfortunately I haven't been able to change the theme following a toggle of useColorMode()

const colorMode = useColorMode();

const url = '/api/config.xml';
const xml = ref('');

const { data:content, pending, refresh, error } = await useAPI<string>(url, {
  server: false,
  headers: {
    'Accept': 'application/xml',
  }
});

watch(content, (value) => {
  console.log(xml, value);
  xml.value = (value !== null) ? value : '';
});

const theme = computed(() => colorMode.value === 'dark' ? 'vitesse-dark' : 'vitesse-light');

const prettyXML = await useHighlighted(xml, {
  lang: 'xml',
  theme,
});

I'm even doubting the code itself is reactive on refresh.

any suggestion?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions