UNPKG

quasar-ui-example-viewer

Version:

Display Vue code examples with template, script and style parts with optional source and codepen links

35 lines (29 loc) 902 B
export function copyHeading (id) { if (window && window.location && document) { const text = window.location.origin + window.location.pathname + '#' + id var textArea = document.createElement('textarea') textArea.className = 'fixed-top' textArea.value = text document.body.appendChild(textArea) textArea.focus() textArea.select() document.execCommand('copy') document.body.removeChild(textArea) this.$q.notify({ message: 'Anchor has been copied to clipboard.', color: 'white', textColor: 'primary', icon: 'done', position: 'top', timeout: 2000 }) } } export function slugify (str) { return encodeURIComponent(String(str).trim().replace(/\s+/g, '-')) } export function makeUrl (slug) { if (window && window.location) { window.location = window.location.origin + window.location.pathname + '#' + slug } }