Skip to content

AI-native design editor. Open-source Figma alternative.

Move demo to /demo route, add @unhead/vue for title management

Danila Poyarkov6ec8fc518bbf
diff --git a/README.md b/README.md
index a158a5373..f7efe33fc 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Open-source, AI-native design editor. Figma-compatible, AI-first, fully local.
> **Status:** Active development. Not ready for production use.
-**[Try it online →](https://app.openpencil.dev)** · [Download](https://github.com/open-pencil/open-pencil/releases/latest) · [Documentation](https://openpencil.dev)
+**[Try it online →](https://app.openpencil.dev/demo)** · [Download](https://github.com/open-pencil/open-pencil/releases/latest) · [Documentation](https://openpencil.dev)
> **What's next**
>
diff --git a/bun.lock b/bun.lock
index 23b2f49ff..8712f8446 100644
--- a/bun.lock
+++ b/bun.lock
@@ -17,6 +17,7 @@
"@tauri-apps/plugin-dialog": "^2.6.0",
"@tauri-apps/plugin-fs": "^2.4.5",
"@tauri-apps/plugin-opener": "^2",
+ "@unhead/vue": "^2.1.10",
"@vueuse/core": "^14.2.1",
"ai": "^6.0.105",
"canvaskit-wasm": "^0.40.0",
@@ -997,6 +998,8 @@
"@ungap/structured-clone": ["@ungap/[email protected]", "", {}, "sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g=="],
+ "@unhead/vue": ["@unhead/[email protected]", "", { "dependencies": { "hookable": "^6.0.1", "unhead": "2.1.10" }, "peerDependencies": { "vue": ">=3.5.18" } }, "sha512-VP78Onh2HNezLPfhYjfHqn4dxlcQsE6PJgTTs61NksO/thvilNswtgBq0N0MWCLtn43N5akEPGW2y2zxM3PWgQ=="],
+
"@valibot/to-json-schema": ["@valibot/[email protected]", "", { "peerDependencies": { "valibot": "^1.2.0" } }, "sha512-GE7DmSr1C2UCWPiV0upRH6mv0cCPsqYGs819fb6srCS1tWhyXrkGGe+zxUiwzn/L1BOfADH4sNjY/YHCuP8phQ=="],
"@vercel/oidc": ["@vercel/[email protected]", "", {}, "sha512-Fw28YZpRnA3cAHHDlkt7xQHiJ0fcL+NRcIqsocZQUSmbzeIKRpwttJjik5ZGanXP+vlA4SbTg+AbA3bP363l+w=="],
@@ -1451,7 +1454,7 @@
"hono": ["[email protected]", "", {}, "sha512-SFsVSjp8sj5UumXOOFlkZOG6XS9SJDKw0TbwFeV+AJ8xlST8kxK5Z/5EYa111UY8732lK2S/xB653ceuaoGwpg=="],
- "hookable": ["[email protected]", "", {}, "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ=="],
+ "hookable": ["[email protected]", "", {}, "sha512-uKGyY8BuzN/a5gvzvA+3FVWo0+wUjgtfSdnmjtrOVwQCZPHpHDH2WRO3VZSOeluYrHoDCiXFffZXs8Dj1ULWtw=="],
"html-void-elements": ["[email protected]", "", {}, "sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg=="],
@@ -2227,6 +2230,8 @@
"undici-types": ["[email protected]", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],
+ "unhead": ["[email protected]", "", { "dependencies": { "hookable": "^6.0.1" } }, "sha512-We8l9uNF8zz6U8lfQaVG70+R/QBfQx1oPIgXin4BtZnK2IQpz6yazQ0qjMNVBDw2ADgF2ea58BtvSK+XX5AS7g=="],
+
"unicode-canonical-property-names-ecmascript": ["[email protected]", "", {}, "sha512-dA8WbNeb2a6oQzAQ55YlT5vQAWGV9WXOsi3SskE3bcCdM0P4SDd+24zS/OCacdRq5BkdsRj9q3Pg6YyQoxIGqg=="],
"unicode-match-property-ecmascript": ["[email protected]", "", { "dependencies": { "unicode-canonical-property-names-ecmascript": "^2.0.0", "unicode-property-aliases-ecmascript": "^2.0.0" } }, "sha512-5kaZCrbp5mmbz5ulBkDkbY0SsPOjKqVS35VpL9ulMPfSl0J0Xsm+9Evphv9CoIZFwre7aJoa94AY6seMKGVN5Q=="],
@@ -2449,6 +2454,8 @@
"@tailwindcss/oxide-wasm32-wasi/tslib": ["[email protected]", "", { "bundled": true }, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
+ "@vue/devtools-kit/hookable": ["[email protected]", "", {}, "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ=="],
+
"@vueuse/integrations/@vueuse/core": ["@vueuse/[email protected]", "", { "dependencies": { "@types/web-bluetooth": "^0.0.21", "@vueuse/metadata": "12.8.2", "@vueuse/shared": "12.8.2", "vue": "^3.5.13" } }, "sha512-HbvCmZdzAu3VGi/pWYm5Ut+Kd9mn1ZHnn4L5G8kOQTPs/IwIAmJoBrmYk2ckLArgMXZj0AW3n5CAejLUO+PhdQ=="],
"@vueuse/integrations/@vueuse/shared": ["@vueuse/[email protected]", "", { "dependencies": { "vue": "^3.5.13" } }, "sha512-dznP38YzxZoNloI0qpEfpkms8knDtaoQ6Y/sfS0L7Yki4zh40LFHEhur0odJC6xTHG5dxWVPiUWBXn+wCG2s5w=="],
@@ -2569,6 +2576,8 @@
"vitepress/@vue/devtools-api/@vue/devtools-kit/@vue/devtools-shared": ["@vue/[email protected]", "", { "dependencies": { "rfdc": "^1.4.1" } }, "sha512-iWAb0v2WYf0QWmxCGy0seZNDPdO3Sp5+u78ORnyeonS6MT4PC7VPrryX2BpMJrwlDeaZ6BD4vP4XKjK0SZqaeA=="],
+ "vitepress/@vue/devtools-api/@vue/devtools-kit/hookable": ["[email protected]", "", {}, "sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ=="],
+
"vitepress/@vue/devtools-api/@vue/devtools-kit/perfect-debounce": ["[email protected]", "", {}, "sha512-xCy9V055GLEqoFaHoC1SoLIaLmWctgCUaBaWxDZ7/Zx4CTyX7cJQLJOok/orfjZAh9kEYpjJa4d0KcJmCbctZA=="],
"vitepress/vite/esbuild/@esbuild/aix-ppc64": ["@esbuild/[email protected]", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ=="],
diff --git a/package.json b/package.json
index ca526a301..b098424bf 100644
--- a/package.json
+++ b/package.json
@@ -42,6 +42,7 @@
"@tauri-apps/plugin-dialog": "^2.6.0",
"@tauri-apps/plugin-fs": "^2.4.5",
"@tauri-apps/plugin-opener": "^2",
+ "@unhead/vue": "^2.1.10",
"@vueuse/core": "^14.2.1",
"ai": "^6.0.105",
"canvaskit-wasm": "^0.40.0",
diff --git a/packages/docs/index.md b/packages/docs/index.md
index aff97a167..5f0d54417 100644
--- a/packages/docs/index.md
+++ b/packages/docs/index.md
@@ -9,7 +9,7 @@ hero:
actions:
- theme: brand
text: Try Online
- link: https://app.openpencil.dev
+ link: https://app.openpencil.dev/demo
- theme: alt
text: Download
link: https://github.com/open-pencil/open-pencil/releases/latest
diff --git a/src/App.vue b/src/App.vue
index db52a9dfb..c0fac150e 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -1,9 +1,12 @@
<script setup lang="ts">
import { onMounted } from 'vue'
+import { useHead } from '@unhead/vue'
import AppToast from '@/components/AppToast.vue'
import { toast } from '@/composables/use-toast'
+useHead({ titleTemplate: (title) => title ? `${title} — OpenPencil` : 'OpenPencil' })
+
onMounted(() => {
toast.setupGlobalErrorHandler()
})
diff --git a/src/env.d.ts b/src/env.d.ts
index 4a9769c46..a7c1d3bb4 100644
--- a/src/env.d.ts
+++ b/src/env.d.ts
@@ -7,3 +7,5 @@ declare module '*.vue' {
const component: DefineComponent<object, object, unknown>
export default component
}
+
+
diff --git a/src/main.ts b/src/main.ts
index 226f3b1c6..27c8f90af 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,4 +1,5 @@
import { createApp } from 'vue'
+import { createHead } from '@unhead/vue/client'
import './app.css'
import { IS_TAURI } from '@/constants'
@@ -8,7 +9,8 @@ import App from './App.vue'
import router from './router'
preloadFonts()
-createApp(App).use(router).mount('#app')
+const head = createHead()
+createApp(App).use(router).use(head).mount('#app')
if (!IS_TAURI) {
import('virtual:pwa-register').then(({ registerSW }) => {
diff --git a/src/router.d.ts b/src/router.d.ts
new file mode 100644
index 000000000..486a602ec
--- /dev/null
+++ b/src/router.d.ts
@@ -0,0 +1,7 @@
+import 'vue-router'
+
+declare module 'vue-router' {
+ interface RouteMeta {
+ demo?: boolean
+ }
+}
diff --git a/src/router.ts b/src/router.ts
index c722e8306..6d1c2ac86 100644
--- a/src/router.ts
+++ b/src/router.ts
@@ -6,6 +6,7 @@ const router = createRouter({
history: createWebHistory(),
routes: [
{ path: '/', component: EditorView },
+ { path: '/demo', component: EditorView, meta: { demo: true } },
{ path: '/share/:roomId', component: EditorView }
]
})
diff --git a/src/views/EditorView.vue b/src/views/EditorView.vue
index 9ed06f3ee..cc0e3f04d 100644
--- a/src/views/EditorView.vue
+++ b/src/views/EditorView.vue
@@ -2,6 +2,7 @@
import { provide } from 'vue'
import { useBreakpoints, useEventListener, useUrlSearchParams } from '@vueuse/core'
import { useRoute, useRouter } from 'vue-router'
+import { useHead } from '@unhead/vue'
import { SplitterGroup, SplitterPanel, SplitterResizeHandle } from 'reka-ui'
import { useKeyboard } from '@/composables/use-keyboard'
@@ -45,10 +46,12 @@ useEventListener(
const params = useUrlSearchParams('history')
const showChrome = !('no-chrome' in params)
-if (!('test' in params)) {
+if (route.meta.demo && !('test' in params)) {
createDemoShapes(firstTab.store)
}
+useHead({ title: route.meta.demo ? 'Demo' : undefined })
+
const pendingRoomId = (route.params.roomId as string) || null
function onShare() {