Function: useCopyMarkdown()
ts
function useCopyMarkdown(): object;Defined in: packages/valaxy/client/composables/features/copy-markdown.ts:27
Composable for copying raw Markdown content of the current post. Requires siteConfig.llms.files: true to have .md files available at build output.
The available ref is initially false and becomes true after a HEAD request confirms the .md file exists. This allows themes to conditionally render the copy button only when the llms feature is enabled.
Returns
object
available
ts
available: Ref<boolean, boolean>;copied
ts
copied: Ref<boolean, boolean>;copy()
ts
copy: () => Promise<void>;Returns
Promise<void>
error
ts
error: Ref<string | null, string | null>;loading
ts
loading: Ref<boolean, boolean>;mdUrl
ts
mdUrl: ComputedRef<string>;Example
vue
<script setup>
import { useCopyMarkdown } from 'valaxy'
const { copy, copied, loading, available, error } = useCopyMarkdown()
</script>
<template>
<button v-if="available" @click="copy" :disabled="loading">
{{ copied ? 'Copied!' : 'Copy Markdown' }}
</button>
<span v-if="error" class="text-red">{{ error }}</span>
</template>