@life-and-dev/mdsite 0.0.4 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,28 +23,28 @@
23
23
  "test": "vitest"
24
24
  },
25
25
  "dependencies": {
26
- "@nuxt/content": "^3.8.0",
27
- "@types/node": "^24.10.0",
28
- "better-sqlite3": "^12.4.1",
29
- "fs-extra": "^11.3.2",
26
+ "@nuxt/content": "^3.14.0",
27
+ "@types/node": "^26.0.1",
28
+ "better-sqlite3": "^12.11.1",
29
+ "fs-extra": "^11.3.5",
30
30
  "gray-matter": "^4.0.3",
31
- "mermaid": "^11.12.2",
32
- "nuxt": "^4.2.1",
33
- "typescript": "^5.9.3",
34
- "vue": "^3.5.24",
35
- "vue-router": "^4.6.3",
36
- "vue-tsc": "^3.1.3",
37
- "vuetify-nuxt-module": "^0.19.2",
38
- "yaml": "^2.8.1"
31
+ "mermaid": "^11.16.0",
32
+ "nuxt": "^4.4.8",
33
+ "typescript": "^6.0.3",
34
+ "vue": "^3.5.39",
35
+ "vue-router": "^5.1.0",
36
+ "vue-tsc": "^3.3.5",
37
+ "vuetify-nuxt-module": "^1.0.0-rc.1",
38
+ "yaml": "^2.9.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@playwright/test": "^1.56.1",
41
+ "@playwright/test": "^1.61.1",
42
42
  "@types/fs-extra": "^11.0.4",
43
- "@vitest/ui": "^4.0.8",
44
- "playwright": "^1.56.1",
45
- "remark-github-blockquote-alert": "^2.0.1",
46
- "sharp": "^0.34.5",
47
- "tsx": "^4.20.6",
48
- "vitest": "^4.0.8"
43
+ "@vitest/ui": "^4.1.9",
44
+ "playwright": "^1.61.1",
45
+ "remark-github-blockquote-alert": "^2.1.0",
46
+ "sharp": "^0.35.2",
47
+ "tsx": "^4.22.4",
48
+ "vitest": "^4.1.9"
49
49
  }
50
50
  }
@@ -0,0 +1,22 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { withBasePath } from '../utils/base-url'
3
+
4
+ describe('withBasePath', () => {
5
+ it('keeps root base URLs unchanged', () => {
6
+ expect(withBasePath('/_navigation.json', '/')).toBe('/_navigation.json')
7
+ })
8
+
9
+ it('prefixes internal URLs with configured app base URL', () => {
10
+ expect(withBasePath('/_search-index.json', '/mdsite/')).toBe('/mdsite/_search-index.json')
11
+ expect(withBasePath('/about', '/mdsite')).toBe('/mdsite/about')
12
+ })
13
+
14
+ it('does not prefix URLs that already include the base URL', () => {
15
+ expect(withBasePath('/mdsite/about', '/mdsite/')).toBe('/mdsite/about')
16
+ })
17
+
18
+ it('leaves external and hash URLs unchanged', () => {
19
+ expect(withBasePath('https://example.com/icon.png', '/mdsite/')).toBe('https://example.com/icon.png')
20
+ expect(withBasePath('#section', '/mdsite/')).toBe('#section')
21
+ })
22
+ })
@@ -143,12 +143,12 @@ export async function generateWebManifest(name: string) {
143
143
  short_name: name,
144
144
  icons: [
145
145
  {
146
- src: '/icon-192.png',
146
+ src: 'icon-192.png',
147
147
  sizes: '192x192',
148
148
  type: 'image/png'
149
149
  },
150
150
  {
151
- src: '/icon-512.png',
151
+ src: 'icon-512.png',
152
152
  sizes: '512x512',
153
153
  type: 'image/png'
154
154
  }
@@ -161,6 +161,40 @@ describe('renderer hooks orchestration', () => {
161
161
  expect(process.env.NUXT_CONTENT_PATH).toBe(path.join('/renderer', 'legacy-docs'))
162
162
  })
163
163
 
164
+ it('supports the checked-in legacy renderer config keys', () => {
165
+ resolveMdsiteConfigPathMock.mockReturnValue(undefined)
166
+ existsSyncMock.mockImplementation((target: string) => (
167
+ target === '/renderer/content.config.yml' || target === '/content/docs'
168
+ ))
169
+ parseYamlMock.mockReturnValue({
170
+ contentPath: '/content/docs',
171
+ contentGitRepo: 'https://example.test/docs.git',
172
+ siteCanonical: 'https://example.test',
173
+ siteName: 'Legacy Site',
174
+ })
175
+ loadMdsiteConfigSyncMock.mockReturnValue({
176
+ config: { site: { name: 'Legacy Site' } },
177
+ configPath: '/renderer/.mdsite-compat.yml',
178
+ contentDir: '/content/docs',
179
+ })
180
+
181
+ prepareRendererRuntime('/renderer')
182
+
183
+ expect(stringifyYamlMock).toHaveBeenCalledWith(expect.objectContaining({
184
+ server: expect.objectContaining({
185
+ repo: 'https://example.test/docs.git',
186
+ }),
187
+ site: expect.objectContaining({
188
+ canonical: 'https://example.test',
189
+ name: 'Legacy Site',
190
+ }),
191
+ }))
192
+ expect(loadMdsiteConfigSyncMock).toHaveBeenCalledWith({
193
+ configPath: '/renderer/.mdsite-compat.yml',
194
+ contentPath: '/content/docs',
195
+ })
196
+ })
197
+
164
198
  it('exits when no renderer config can be resolved', () => {
165
199
  const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
166
200
  const processExitSpy = vi.spyOn(process, 'exit').mockImplementation((code?: number) => {
@@ -109,7 +109,8 @@ function ensureLegacyCompatibilityConfig(rootDir: string): string | undefined {
109
109
  }
110
110
 
111
111
  const legacyConfig = YAML.parse(fs.readFileSync(legacyConfigPath, 'utf8')) ?? {}
112
- const contentDir = path.resolve(rootDir, legacyConfig.content?.path || legacyConfig.content?.git?.path || 'docs')
112
+ const legacyContentPath = legacyConfig.content?.path || legacyConfig.content?.git?.path || legacyConfig.contentPath || 'docs'
113
+ const contentDir = path.resolve(rootDir, legacyContentPath)
113
114
  const compatibilityConfigPath = path.join(rootDir, '.mdsite-compat.yml')
114
115
  const compatibilityConfig = {
115
116
  favicon: '',
@@ -121,11 +122,11 @@ function ensureLegacyCompatibilityConfig(rootDir: string): string | undefined {
121
122
  server: {
122
123
  output: '.output',
123
124
  path: '.mdsite',
124
- repo: legacyConfig.content?.git?.repo || ''
125
+ repo: legacyConfig.content?.git?.repo || legacyConfig.contentGitRepo || ''
125
126
  },
126
127
  site: {
127
- canonical: legacyConfig.site?.canonical || '',
128
- name: legacyConfig.site?.name || path.basename(contentDir) || 'Site'
128
+ canonical: legacyConfig.site?.canonical || legacyConfig.siteCanonical || '',
129
+ name: legacyConfig.site?.name || legacyConfig.siteName || path.basename(contentDir) || 'Site'
129
130
  },
130
131
  themes: legacyConfig.themes || {}
131
132
  }
@@ -0,0 +1,25 @@
1
+ export function withBasePath(pathname: string, baseURL = '/'): string {
2
+ if (isExternalOrHash(pathname)) return pathname
3
+
4
+ const normalizedBase = normalizeBaseURL(baseURL)
5
+ const normalizedPath = pathname.startsWith('/') ? pathname : `/${pathname}`
6
+
7
+ if (normalizedBase === '/') return normalizedPath
8
+ if (normalizedPath === normalizedBase.slice(0, -1) || normalizedPath.startsWith(normalizedBase)) return normalizedPath
9
+
10
+ return `${normalizedBase.slice(0, -1)}${normalizedPath}`
11
+ }
12
+
13
+ function normalizeBaseURL(baseURL: string): string {
14
+ if (!baseURL || baseURL === '/') return '/'
15
+
16
+ const withLeadingSlash = baseURL.startsWith('/') ? baseURL : `/${baseURL}`
17
+ return withLeadingSlash.endsWith('/') ? withLeadingSlash : `${withLeadingSlash}/`
18
+ }
19
+
20
+ function isExternalOrHash(pathname: string): boolean {
21
+ return pathname.startsWith('http://') ||
22
+ pathname.startsWith('https://') ||
23
+ pathname.startsWith('//') ||
24
+ pathname.startsWith('#')
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@life-and-dev/mdsite",
3
- "version": "0.0.4",
3
+ "version": "0.0.12",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "description": "Local-first CLI that orchestrates mdsite-nuxt",
@@ -24,6 +24,7 @@
24
24
  "scripts": {
25
25
  "build": "tsc -p tsconfig.json",
26
26
  "install-alias": "node scripts/mdsite-dev-alias.js install",
27
+ "release:version": "node scripts/release-version.mjs",
27
28
  "uninstall-alias": "node scripts/mdsite-dev-alias.js uninstall",
28
29
  "typecheck": "tsc -p tsconfig.json --noEmit",
29
30
  "test": "vitest run",
@@ -31,11 +32,11 @@
31
32
  "prepublishOnly": "npm test && npm run typecheck && npm run build && npm run verify:package"
32
33
  },
33
34
  "dependencies": {
34
- "yaml": "^2.8.1"
35
+ "yaml": "^2.9.0"
35
36
  },
36
37
  "devDependencies": {
37
- "@types/node": "^24.10.0",
38
- "typescript": "^5.9.3",
39
- "vitest": "^4.0.8"
38
+ "@types/node": "^26.0.1",
39
+ "typescript": "^6.0.3",
40
+ "vitest": "^4.1.9"
40
41
  }
41
42
  }