diff --git a/package.json b/package.json index cc1dc096..762fbb67 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "jwt-decode": "^3.1.2", "normalize.css": "^8.0.1", "typescript-cookie": "^1.0.6", + "unhead": "^1.8.3", "vue": "^3.3.4", "vue-i18n": "^9.2.2", "vue-router": "^4.2.4" diff --git a/src/application/i18n/messages/en.json b/src/application/i18n/messages/en.json index f4489736..43c01195 100644 --- a/src/application/i18n/messages/en.json +++ b/src/application/i18n/messages/en.json @@ -1,19 +1,26 @@ { + "appTitle": "NoteX", "auth": { "login": "Login", "logout": "Logout" }, - "settings": { - "title": "Settings", - "changeTheme": "Change theme", - "userEditorTools": "User editor tools" - }, "header": { "buttons": { "home": "Home", "noteSettings": "Settings" } }, + "userSettings": { + "title": "User Settings", + "changeTheme": "Change theme", + "userEditorTools": "User editor tools" + }, + "noteSettings": { + "title": "Note Settings" + }, + "note": { + "new": "New Note" + }, "home": { "title": "Recent Notes" }, diff --git a/src/application/services/useNote.ts b/src/application/services/useNote.ts index c4da3a4d..7496dee6 100644 --- a/src/application/services/useNote.ts +++ b/src/application/services/useNote.ts @@ -60,6 +60,11 @@ interface UseNoteComposableState { * Defines if user can edit note */ canEdit: Ref; + + /** + * Title for bookmarks in the browser + */ + noteTitle: Ref; } interface UseNoteComposableOptions { @@ -92,6 +97,20 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt */ const router = useRouter(); + /** + * Note Title identifier + */ + const limitCharsForNoteTitle = 50; + const noteTitle = computed(() => { + const firstNoteBlock = note.value?.content.blocks[0]; + + if (!firstNoteBlock || !(Boolean(firstNoteBlock.data.text))) { + return 'Note'; + } else { + return firstNoteBlock.data.text.slice(0, limitCharsForNoteTitle); + } + }); + /** * Editing rights for the currently opened note * @@ -188,6 +207,7 @@ export default function (options: UseNoteComposableOptions): UseNoteComposableSt return { note, + noteTitle, canEdit, resolveHostname, save, diff --git a/src/index.ts b/src/index.ts index 9533474f..29d0e7a7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import { createApp } from 'vue'; +import { createHead } from 'unhead'; import App from './App.vue'; import i18n from '@/application/i18n'; import router from '@/application/router/index'; @@ -6,6 +7,7 @@ import '@/presentation/styles/index.pcss'; const app = createApp(App); +app.use(createHead); app.use(router); app.use(i18n); app.mount('#app'); diff --git a/src/presentation/components/theme/ThemeButton.vue b/src/presentation/components/theme/ThemeButton.vue index ada0abf7..d0d6d6eb 100644 --- a/src/presentation/components/theme/ThemeButton.vue +++ b/src/presentation/components/theme/ThemeButton.vue @@ -1,6 +1,6 @@