Skip to content

Commit

Permalink
Merge pull request #40 from doroudi:doroudi/issue35
Browse files Browse the repository at this point in the history
feat: ✨ Update title base on page title  #35
  • Loading branch information
doroudi authored Dec 1, 2023
2 parents 41afd4f + 78cd753 commit d665c90
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 0 additions & 10 deletions src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,19 @@ declare module 'vue' {
Navbar: typeof import('./components/Navbar.vue')['default']
NBadge: typeof import('naive-ui')['NBadge']
NButton: typeof import('naive-ui')['NButton']
NColorPicker: typeof import('naive-ui')['NColorPicker']
NConfigProvider: typeof import('naive-ui')['NConfigProvider']
NDataTable: typeof import('naive-ui')['NDataTable']
NDialogProvider: typeof import('naive-ui')['NDialogProvider']
NDrawer: typeof import('naive-ui')['NDrawer']
NDrawerContent: typeof import('naive-ui')['NDrawerContent']
NForm: typeof import('naive-ui')['NForm']
NFormItem: typeof import('naive-ui')['NFormItem']
NIcon: typeof import('naive-ui')['NIcon']
NInput: typeof import('naive-ui')['NInput']
NLayout: typeof import('naive-ui')['NLayout']
NLayoutContent: typeof import('naive-ui')['NLayoutContent']
NLayoutSider: typeof import('naive-ui')['NLayoutSider']
NMenu: typeof import('naive-ui')['NMenu']
NMessageProvider: typeof import('naive-ui')['NMessageProvider']
NModal: typeof import('naive-ui')['NModal']
NNotificationProvider: typeof import('naive-ui')['NNotificationProvider']
NPageHeader: typeof import('naive-ui')['NPageHeader']
NPopselect: typeof import('naive-ui')['NPopselect']
NSpace: typeof import('naive-ui')['NSpace']
NTreeSelect: typeof import('naive-ui')['NTreeSelect']
NUpload: typeof import('naive-ui')['NUpload']
ProductManagement: typeof import('./components/Products/ProductManagement.vue')['default']
ProductsManagement: typeof import('./components/Products/ProductsManagement.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
Expand Down
10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import generatedRoutes from '~pages'
import '@unocss/reset/tailwind-compat.css'
import 'uno.css'
import './styles/main.scss'
import i18n from './modules/i18n'

Check failure on line 9 in src/main.ts

View workflow job for this annotation

GitHub Actions / lint

`./modules/i18n` import should occur before import of `~pages`

const routes = setupLayouts(generatedRoutes)

Expand All @@ -27,8 +28,15 @@ app.use(router)
Object.values(import.meta.glob<{ install: AppModule }>('./modules/*.ts', { eager: true }))
.forEach(i => i.install?.(app, router))

// @ts-expect-error "Type instantiation is excessively deep and possibly infinite.ts(2589)"
const { t } = i18n.global
let title = t('title')

router.beforeEach((to, from, next) => {
// TODO: implement route guards
if (to.meta.title)
title = `${to.meta.title} - ${title}`

document.title = title
next()
})
enableMocking().then(() => app.mount('#app'))
14 changes: 8 additions & 6 deletions src/modules/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ const messages = Object.fromEntries(
}),
)

export const install: AppModule = (app) => {
const i18n = createI18n({
legacy: false,
locale: 'en',
messages,
})
const i18n = createI18n({
legacy: false,
locale: 'en',
messages,
})

export const install: AppModule = (app) => {
app.use(i18n)
}

export default i18n

0 comments on commit d665c90

Please sign in to comment.