Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/vue/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
import SpeedHighlight from 'SpeedHighlight.vue'

import { ref } from 'vue'

const myCode = ref(`printf('Hello World!\n');`)
const myLang = ref('c')
</script>

<template>
<p>Here is a the example code:</p>
<SpeedHighlight :content="myCode" :lang="myLang" />
</template>
20 changes: 20 additions & 0 deletions examples/vue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# VueJs 3.x Example of a Speed Highlight Component

## Install

```console
$ pnpm i @speed-highlight/core
```

## SpeedHighlight.vue

This is a simple component that wraps `speed-highlight` and makes it easier to use in your Vue app.
It takes two props: `content` & `lang` - and you can include it in your pages like this:

```vue
<SpeedHighlight content="printf('Hello World!\n');" lang="c" />
```

## App.vue

Simplified example page/parent, to show how you include `<SpeedHighlight />` on a page.
17 changes: 17 additions & 0 deletions examples/vue/SppedHighlight.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<script lang="ts" setup>
import { defineProps, ref, onMounted } from 'vue'
import { highlightText } from '@speed-highlight/core'
import '@speed-highlight/core/dist/themes/default.css'

const { content = '', lang = 'c' } = defineProps<{ content: string; lang: string }>()

const highlightedCode = ref('')

onMounted(async () => {
highlightedCode.value = await highlightText(content, lang)
})
</script>

<template>
<div :class="`shj-lang-${lang}`" v-html="highlightedCode"></div>
</template>