vitepress-theme-element-plus 1.4.0 → 1.4.1

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.
@@ -108,10 +108,6 @@ const pageName = computed(() =>
108
108
  }
109
109
 
110
110
  @media (min-width: 1440px) {
111
- .VPDoc.has-aside {
112
- padding: 64px 48px 48px 64px;
113
- }
114
-
115
111
  .VPDoc.has-aside {
116
112
  padding: 64px 0 48px 64px;
117
113
  }
@@ -134,6 +130,12 @@ const pageName = computed(() =>
134
130
  }
135
131
  }
136
132
 
133
+ @media (min-width: 1440px) and (max-width: 1679px) {
134
+ .VPDoc.has-aside.has-mobile-preview {
135
+ padding-right: 32px;
136
+ }
137
+ }
138
+
137
139
  @media (min-width: 1440px) {
138
140
  .VPDoc:not(.has-sidebar) .content {
139
141
  max-width: 784px;
@@ -41,7 +41,7 @@ const linkUnderline = computed(() => {
41
41
  .footer {
42
42
  background-color: var(--vp-c-bg-soft);
43
43
  box-sizing: border-box;
44
- padding: 42px 64px 64px;
44
+ padding: 0px 64px 64px;
45
45
 
46
46
  &.is-home {
47
47
  background-color: var(--bg-color);
@@ -60,6 +60,7 @@ const linkUnderline = computed(() => {
60
60
  display: inline-block;
61
61
  vertical-align: top;
62
62
  margin-right: 130px;
63
+ margin-top: 42px;
63
64
  width: 200px;
64
65
 
65
66
  h4 {
@@ -1,9 +1,10 @@
1
1
  <script setup lang="ts">
2
+ import type { SiteData } from 'vitepress'
2
3
  import { useData, useRoute } from 'vitepress'
3
4
  import { computed, ref, watch } from 'vue'
4
5
  import { resolveMobilePreviewId } from '../mobile-preview'
5
6
 
6
- const { frontmatter, isDark, theme } = useData()
7
+ const { frontmatter, isDark, site, theme } = useData()
7
8
  const route = useRoute()
8
9
  const frameRef = ref<HTMLIFrameElement>()
9
10
  const previewConfig = computed(() => theme.value.mobilePreview ?? {})
@@ -25,7 +26,7 @@ const previewHref = computed(() => {
25
26
  theme: isDark.value ? 'dark' : 'light',
26
27
  })
27
28
 
28
- return `${resolveLocalePreviewPath(route.path, previewPath)}?${search.toString()}`
29
+ return `${resolveLocalePreviewPath(route.path, previewPath, site.value)}?${search.toString()}`
29
30
  })
30
31
 
31
32
  const frameStyle = computed(() => ({
@@ -37,17 +38,35 @@ function normalizePreviewPath(value: unknown): string {
37
38
  if (typeof value !== 'string' || !value.trim())
38
39
  return 'preview/'
39
40
 
40
- return value
41
- .trim()
41
+ const trimmedValue = value.trim()
42
+ const normalizedPath = trimmedValue
42
43
  .replace(/^\/+/, '')
43
44
  .replace(/\/?$/, '/')
45
+
46
+ return trimmedValue.startsWith('/')
47
+ ? `/${normalizedPath}`
48
+ : normalizedPath
49
+ }
50
+
51
+ function normalizeLocalePrefix(value: string): string {
52
+ return `/${value.replace(/^\/+|\/+$/g, '')}/`
53
+ }
54
+
55
+ function getLocalePrefix(path: string, siteData: SiteData): string {
56
+ const localePrefixes = Object.keys(siteData.locales ?? {})
57
+ .filter(locale => locale !== 'root')
58
+ .map(normalizeLocalePrefix)
59
+ .sort((left, right) => right.length - left.length)
60
+
61
+ return localePrefixes.find(prefix => path.startsWith(prefix)) ?? '/'
44
62
  }
45
63
 
46
- function resolveLocalePreviewPath(path: string, previewPath: string): string {
47
- const matchedLocale = path.match(/^\/([^/]+)\//)
48
- const localePrefix = matchedLocale ? `/${matchedLocale[1]}/` : '/'
64
+ function resolveLocalePreviewPath(path: string, previewPath: string, siteData: SiteData): string {
65
+ if (previewPath.startsWith('/'))
66
+ return previewPath
49
67
 
50
- return `${localePrefix}${previewPath}`
68
+ const localePrefix = getLocalePrefix(path, siteData)
69
+ return new URL(previewPath, `https://mobile-preview.local${localePrefix}`).pathname
51
70
  }
52
71
 
53
72
  function syncTheme(): void {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitepress-theme-element-plus",
3
3
  "type": "module",
4
- "version": "1.4.0",
4
+ "version": "1.4.1",
5
5
  "description": "A VitePress theme for Element Plus",
6
6
  "author": "Hezhengxu",
7
7
  "license": "MIT",