Skip to content

Commit 762b1a1

Browse files
committed
chore: move to /_studio and add .route option
1 parent 0263856 commit 762b1a1

File tree

13 files changed

+84
-282
lines changed

13 files changed

+84
-282
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@
2929
"main": "./dist/module/module.mjs",
3030
"scripts": {
3131
"prepack": "nuxt-module-build build src/module; vite build src/app",
32-
"dev": "npm run dev:prepare && STUDIO_DEV_SERVER=http://localhost:5151 nuxi dev playground/docus",
33-
"dev:minimal": "npm run dev:prepare && STUDIO_DEV_SERVER=http://localhost:5151 nuxt dev playground/minimal",
32+
"dev": "pnpm run dev:prepare && STUDIO_DEV_SERVER=http://localhost:5151 nuxi dev playground/docus",
33+
"dev:minimal": "pnpm run dev:prepare && STUDIO_DEV_SERVER=http://localhost:5151 nuxt dev playground/minimal",
3434
"dev:app": "vite src/app --port 5151",
3535
"dev:build": "nuxi build playground/docus",
3636
"dev:prepare": "nuxt-module-build build --stub src/module && nuxt-module-build prepare src/module && nuxi prepare playground/docus",
37-
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
37+
"release": "pnpm run lint && pnpm run test && pnpm run prepack && changelogen --release && npm publish && git push --follow-tags",
3838
"lint": "eslint .",
3939
"typecheck": "nuxt typecheck",
40-
"verify": "npm run lint && npm run typecheck && npm run test",
40+
"verify": "pnpm run lint && pnpm run typecheck && pnpm run test",
4141
"test": "vitest run",
4242
"test:watch": "vitest watch",
4343
"test:types": "vue-tsc --noEmit && cd playground/docus && vue-tsc --noEmit"

playground/docus/nuxt.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export default defineNuxtConfig({
22
extends: ['docus'],
33
modules: [
4-
'nuxt-studio',
54
'@nuxt/ui',
65
'@nuxt/content',
6+
'nuxt-studio',
77
],
88
devtools: { enabled: true },
99
content: {
@@ -12,7 +12,7 @@ export default defineNuxtConfig({
1212
},
1313
},
1414
compatibilityDate: '2025-08-26',
15-
contentStudio: {
15+
studio: {
1616
repository: {
1717
owner: 'nuxt-content',
1818
repo: 'studio',

playground/docus/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
"build": "nuxt build --extends docus"
77
},
88
"dependencies": {
9-
"docus": "^5.2.0",
9+
"docus": "^5.2.1",
1010
"better-sqlite3": "^12.4.1",
1111
"nuxt": "latest",
1212
"@nuxt/content": "latest",
13-
"@nuxt/ui": "4.0.1",
13+
"@nuxt/ui": "4.1.0",
1414
"nuxt-studio": "workspace:*"
1515
}
1616
}

pnpm-lock.yaml

Lines changed: 53 additions & 259 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/module/src/module.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ import type { ViteDevServer } from 'vite'
88
import { getAssetsStorageDevTemplate, getAssetsStorageTemplate } from './templates'
99

1010
interface ModuleOptions {
11+
/**
12+
* The route to access the studio login page.
13+
* @default '/_studio'
14+
*/
15+
route?: string
1116
development?: {
1217
sync?: boolean
1318
}
@@ -39,7 +44,7 @@ const logger = useLogger('nuxt-studio')
3944
export default defineNuxtModule<ModuleOptions>({
4045
meta: {
4146
name: 'nuxt-studio',
42-
configKey: 'contentStudio',
47+
configKey: 'studio',
4348
},
4449
defaults: {
4550
development: {
@@ -50,6 +55,7 @@ export default defineNuxtModule<ModuleOptions>({
5055
const resolver = createResolver(import.meta.url)
5156
const runtime = (...args: string[]) => resolver.resolve('./runtime', ...args)
5257
options = defu(options, {
58+
route: '/_studio',
5359
repository: {
5460
provider: 'github',
5561
branch: 'main',
@@ -80,7 +86,8 @@ export default defineNuxtModule<ModuleOptions>({
8086
nuxt.options.experimental = nuxt.options.experimental || {}
8187
nuxt.options.experimental.checkOutdatedBuildInterval = 1000 * 30
8288

83-
nuxt.options.runtimeConfig.public.contentStudio = {
89+
nuxt.options.runtimeConfig.public.studio = {
90+
route: options.route!,
8491
development: {
8592
sync: Boolean(options.development!.sync),
8693
server: process.env.STUDIO_DEV_SERVER,
@@ -89,7 +96,7 @@ export default defineNuxtModule<ModuleOptions>({
8996
repository: options.repository,
9097
}
9198

92-
nuxt.options.runtimeConfig.contentStudio = {
99+
nuxt.options.runtimeConfig.studio = {
93100
auth: {
94101
sessionSecret: createHash('md5').update([
95102
options.auth?.github?.clientId,
@@ -187,7 +194,7 @@ export default defineNuxtModule<ModuleOptions>({
187194
route: '/__nuxt_content/studio/auth/session',
188195
handler: runtime('./server/routes/auth/session.delete'),
189196
})
190-
addServerHandler({ route: '/__nuxt_content/studio', handler: runtime('./server/routes/admin') })
197+
addServerHandler({ route: options.route as string, handler: runtime('./server/routes/admin') })
191198
// Register meta route for studio
192199
addServerHandler({ route: '/__nuxt_content/studio/meta', handler: runtime('./server/routes/meta') })
193200
addServerHandler({ route: '/sw.js', handler: runtime('./server/routes/sw') })

src/module/src/runtime/host.dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { debounce } from 'perfect-debounce'
1111
export function useStudioHost(user: StudioUser, repository: Repository) {
1212
const host = useStudioHostBase(user, repository)
1313

14-
if (!useRuntimeConfig().public.contentStudio.development.sync) {
14+
if (!useRuntimeConfig().public.studio.development.sync) {
1515
return host
1616
}
1717

src/module/src/runtime/plugins/studio.client.dev.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ export default defineNuxtPlugin(() => {
1616

1717
// Initialize host
1818
const host = await import('../host.dev').then(m => m.useStudioHost);
19-
(window as unknown as { useStudioHost: UseStudioHost }).useStudioHost = () => host(user, config.public.contentStudio.repository as unknown as Repository)
19+
(window as unknown as { useStudioHost: UseStudioHost }).useStudioHost = () => host(user, config.public.studio.repository as unknown as Repository)
2020

2121
const el = document.createElement('script')
22-
el.src = `${config.public.contentStudio?.development?.server}/src/main.ts`
22+
el.src = `${config.public.studio?.development?.server}/src/main.ts`
2323
el.type = 'module'
2424
document.body.appendChild(el)
2525

src/module/src/runtime/plugins/studio.client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default defineNuxtPlugin(() => {
88
const config = useRuntimeConfig()
99
// Initialize host
1010
const host = await import('../host').then(m => m.useStudioHost);
11-
(window as unknown as { useStudioHost: UseStudioHost }).useStudioHost = () => host(user, config.public.contentStudio.repository as unknown as Repository)
11+
(window as unknown as { useStudioHost: UseStudioHost }).useStudioHost = () => host(user, config.public.studio.repository as unknown as Repository)
1212

1313
await import('nuxt-studio/app')
1414
document.body.appendChild(document.createElement('nuxt-studio'))

src/module/src/runtime/server/routes/auth/github.get.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ interface RequestAccessTokenOptions {
8080
}
8181

8282
export default eventHandler(async (event: H3Event) => {
83-
const config = defu(useRuntimeConfig(event).contentStudio?.auth?.github, {
83+
const config = defu(useRuntimeConfig(event).studio?.auth?.github, {
8484
clientId: process.env.STUDIO_GITHUB_CLIENT_ID,
8585
clientSecret: process.env.STUDIO_GITHUB_CLIENT_SECRET,
8686
authorizationURL: 'https://github.com/login/oauth/authorize',
@@ -194,7 +194,7 @@ export default eventHandler(async (event: H3Event) => {
194194
// Success
195195
const session = await useSession(event, {
196196
name: 'content-studio-session',
197-
password: useRuntimeConfig(event).contentStudio?.auth?.sessionSecret,
197+
password: useRuntimeConfig(event).studio?.auth?.sessionSecret,
198198
})
199199

200200
await session.update(defu({

src/module/src/runtime/server/routes/auth/session.delete.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRuntimeConfig } from '#imports'
44
export default eventHandler(async (event) => {
55
const session = await useSession(event, {
66
name: 'content-studio-session',
7-
password: useRuntimeConfig(event).contentStudio?.auth?.sessionSecret,
7+
password: useRuntimeConfig(event).studio?.auth?.sessionSecret,
88
})
99

1010
await session.clear()

0 commit comments

Comments
 (0)