vitepress 1.0.0-draft.1 → 1.0.0-draft.4

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.
Files changed (46) hide show
  1. package/dist/client/app/composables/head.js +2 -2
  2. package/dist/client/app/data.js +2 -4
  3. package/dist/client/index.d.ts +8 -0
  4. package/dist/client/shared.js +22 -0
  5. package/dist/client/theme-default/Layout.vue +18 -1
  6. package/dist/client/theme-default/components/VPBackdrop.vue +1 -1
  7. package/dist/client/theme-default/components/VPBox.vue +59 -0
  8. package/dist/client/theme-default/components/VPButton.vue +123 -0
  9. package/dist/client/theme-default/components/VPContent.vue +34 -10
  10. package/dist/client/theme-default/components/{VPContentDoc.vue → VPDoc.vue} +66 -42
  11. package/dist/client/theme-default/components/{VPContentDocFooter.vue → VPDocFooter.vue} +3 -2
  12. package/dist/client/theme-default/components/{VPContentDocOutline.vue → VPDocOutline.vue} +14 -3
  13. package/dist/client/theme-default/components/VPFooter.vue +53 -0
  14. package/dist/client/theme-default/components/VPHero.vue +144 -0
  15. package/dist/client/theme-default/components/VPHome.vue +33 -0
  16. package/dist/client/theme-default/components/VPHomeFeatures.vue +96 -0
  17. package/dist/client/theme-default/components/VPHomeHero.vue +17 -0
  18. package/dist/client/theme-default/components/VPHomeSponsors.vue +93 -0
  19. package/dist/client/theme-default/components/VPNavBar.vue +2 -1
  20. package/dist/client/theme-default/components/VPNavBarAppearance.vue +4 -1
  21. package/dist/client/theme-default/components/VPNavBarExtra.vue +2 -2
  22. package/dist/client/theme-default/components/VPNavBarSearch.vue +3 -3
  23. package/dist/client/theme-default/components/VPNavBarTitle.vue +26 -13
  24. package/dist/client/theme-default/components/VPNavScreenAppearance.vue +4 -1
  25. package/dist/client/theme-default/components/VPPage.vue +5 -0
  26. package/dist/client/theme-default/components/VPSidebar.vue +2 -2
  27. package/dist/client/theme-default/components/VPSponsors.vue +77 -0
  28. package/dist/client/theme-default/components/VPSponsorsGrid.vue +32 -0
  29. package/dist/client/theme-default/components/VPSwitchAppearance.vue +3 -3
  30. package/dist/client/theme-default/components/icons/VPIconHeart.vue +5 -0
  31. package/dist/client/theme-default/composables/outline.js +12 -20
  32. package/dist/client/theme-default/composables/sponsor-grid.js +92 -0
  33. package/dist/client/theme-default/index.js +6 -1
  34. package/dist/client/theme-default/styles/base.css +3 -0
  35. package/dist/client/theme-default/styles/components/custom-block.css +90 -0
  36. package/dist/client/theme-default/styles/{vp-doc.css → components/vp-doc.css} +63 -11
  37. package/dist/client/theme-default/styles/components/vp-sponsor.css +86 -0
  38. package/dist/client/theme-default/styles/vars.css +150 -29
  39. package/dist/client/theme-default/support/utils.js +19 -0
  40. package/dist/node/cli.js +1 -1
  41. package/dist/node/index.d.ts +22 -1
  42. package/dist/node/index.js +1 -1
  43. package/dist/node/{serve-428d4610.js → serve-b3182d88.js} +50 -8
  44. package/package.json +2 -1
  45. package/types/default-theme.d.ts +12 -0
  46. package/types/shared.d.ts +14 -6
@@ -0,0 +1,53 @@
1
+ <script setup lang="ts">
2
+ import { useData } from 'vitepress'
3
+ import { useSidebar } from '../composables/sidebar'
4
+
5
+ const { theme } = useData()
6
+ const { hasSidebar } = useSidebar()
7
+ </script>
8
+
9
+ <template>
10
+ <footer v-if="theme.footer" class="VPFooter" :class="{ 'has-sidebar': hasSidebar }">
11
+ <div class="container">
12
+ <p class="message">{{ theme.footer.message }}</p>
13
+ <p class="copyright">{{ theme.footer.copyright }}</p>
14
+ </div>
15
+ </footer>
16
+ </template>
17
+
18
+ <style scoped>
19
+ .VPFooter {
20
+ position: relative;
21
+ z-index: var(--vp-z-index-footer);
22
+ border-top: 1px solid var(--vp-c-divider-light);
23
+ padding: 32px 24px;
24
+ background-color: var(--vp-c-bg-content);
25
+ }
26
+
27
+ .VPFooter.has-sidebar {
28
+ display: none;
29
+ }
30
+
31
+ @media (min-width: 768px) {
32
+ .VPFooter {
33
+ padding: 32px;
34
+ }
35
+ }
36
+
37
+ .container {
38
+ margin: 0 auto;
39
+ max-width: var(--vp-layout-max-width);
40
+ text-align: center;
41
+ }
42
+
43
+ .message,
44
+ .copyright {
45
+ line-height: 24px;
46
+ font-size: 14px;
47
+ font-weight: 500;
48
+ color: var(--vp-c-text-2);
49
+ }
50
+
51
+ .message { order: 2; }
52
+ .copyright { order: 1; }
53
+ </style>
@@ -0,0 +1,144 @@
1
+ <script setup lang="ts">
2
+ import VPButton from './VPButton.vue'
3
+
4
+ interface HeroAction {
5
+ theme?: 'brand' | 'alt'
6
+ text: string
7
+ link: string
8
+ }
9
+
10
+ defineProps<{
11
+ name?: string
12
+ text: string
13
+ tagline?: string
14
+ actions?: HeroAction[]
15
+ }>()
16
+ </script>
17
+
18
+ <template>
19
+ <div class="VPHero">
20
+ <div class="container">
21
+ <p v-if="name" class="name"><span class="clip">{{ name }}</span></p>
22
+ <h1 v-if="text" class="text">{{ text }}</h1>
23
+ <p v-if="tagline" class="tagline">{{ tagline }}</p>
24
+
25
+ <div v-if="actions" class="actions">
26
+ <div v-for="action in actions" :key="action.link" class="action">
27
+ <VPButton
28
+ tag="a"
29
+ size="big"
30
+ :theme="action.theme"
31
+ :text="action.text"
32
+ :href="action.link"
33
+ />
34
+ </div>
35
+ </div>
36
+ </div>
37
+ </div>
38
+ </template>
39
+
40
+ <style scoped>
41
+ .VPHero {
42
+ margin-top: calc(var(--vp-nav-height) * -1);
43
+ padding: calc(var(--vp-nav-height) + 48px) 24px 48px;
44
+ }
45
+
46
+ @media (min-width: 640px) {
47
+ .VPHero {
48
+ padding: calc(var(--vp-nav-height) + 80px) 48px 64px;
49
+ }
50
+ }
51
+
52
+ .container {
53
+ margin: 0 auto;
54
+ max-width: 960px;
55
+ }
56
+
57
+ .name,
58
+ .text {
59
+ line-height: 40px;
60
+ font-size: 32px;
61
+ font-weight: 700;
62
+ }
63
+
64
+ .name {
65
+ padding-bottom: 4px;
66
+ color: var(--vp-home-hero-name-color);
67
+ }
68
+
69
+ .clip {
70
+ background: var(--vp-home-hero-name-background);
71
+ -webkit-text-fill-color: var(--vp-home-hero-name-color);
72
+ -webkit-background-clip: text;
73
+ }
74
+
75
+ @media (min-width: 640px) {
76
+ .name,
77
+ .text {
78
+ max-width: 640px;
79
+ line-height: 56px;
80
+ font-size: 48px;
81
+ }
82
+
83
+ .name {
84
+ padding-bottom: 6px;
85
+ }
86
+ }
87
+
88
+ @media (min-width: 960px) {
89
+ .name,
90
+ .text {
91
+ max-width: 720px;
92
+ line-height: 64px;
93
+ font-size: 56px;
94
+ }
95
+
96
+ .name {
97
+ padding-bottom: 6px;
98
+ }
99
+ }
100
+
101
+ .tagline {
102
+ padding-top: 16px;
103
+ line-height: 28px;
104
+ font-size: 18px;
105
+ font-weight: 500;
106
+ color: var(--vp-c-text-2);
107
+ }
108
+
109
+ @media (min-width: 640px) {
110
+ .tagline {
111
+ padding-top: 24px;
112
+ max-width: 540px;
113
+ line-height: 32px;
114
+ font-size: 20px;
115
+ }
116
+ }
117
+
118
+ @media (min-width: 960px) {
119
+ .tagline {
120
+ padding-top: 24px;
121
+ max-width: 640px;
122
+ line-height: 36px;
123
+ font-size: 24px;
124
+ }
125
+ }
126
+
127
+ .actions {
128
+ display: flex;
129
+ flex-wrap: wrap;
130
+ margin: -8px;
131
+ padding-top: 24px;
132
+ }
133
+
134
+ @media (min-width: 640px) {
135
+ .actions {
136
+ padding-top: 32px;
137
+ }
138
+ }
139
+
140
+ .action {
141
+ flex-shrink: 0;
142
+ padding: 8px;
143
+ }
144
+ </style>
@@ -0,0 +1,33 @@
1
+ <script setup lang="ts">
2
+ import VPHomeHero from './VPHomeHero.vue'
3
+ import VPHomeFeatures from './VPHomeFeatures.vue'
4
+ </script>
5
+
6
+ <template>
7
+ <div class="VPHome">
8
+ <slot name="home-hero-before" />
9
+ <VPHomeHero />
10
+ <slot name="home-hero-after" />
11
+
12
+ <slot name="home-features-before" />
13
+ <VPHomeFeatures />
14
+ <slot name="home-features-after" />
15
+ </div>
16
+ </template>
17
+
18
+ <style scoped>
19
+ .VPHome {
20
+ padding-bottom: 96px;
21
+ }
22
+
23
+ .VPHome :deep(.VPHomeSponsors) {
24
+ margin-top: 112px;
25
+ margin-bottom: -128px;
26
+ }
27
+
28
+ @media (min-width: 768px) {
29
+ .VPHome {
30
+ padding-bottom: 128px;
31
+ }
32
+ }
33
+ </style>
@@ -0,0 +1,96 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import { useData } from 'vitepress'
4
+ import VPBox from './VPBox.vue'
5
+
6
+ const { frontmatter: fm } = useData()
7
+
8
+ const grid = computed(() => {
9
+ const length = fm.value.features?.length
10
+
11
+ if (!length) {
12
+ return
13
+ }
14
+
15
+ if (length === 2) {
16
+ return 'grid-2'
17
+ } else if (length === 3) {
18
+ return 'grid-3'
19
+ } else if (length % 3 === 0) {
20
+ return 'grid-6'
21
+ } else if (length % 2 === 0) {
22
+ return 'grid-4'
23
+ }
24
+ })
25
+ </script>
26
+
27
+ <template>
28
+ <div v-if="fm.features" class="VPHomeFeatures">
29
+ <div class="container">
30
+ <div class="items">
31
+ <div v-for="feature in fm.features" :key="feature.title" class="item" :class="[grid]">
32
+ <VPBox
33
+ :icon="feature.icon"
34
+ :title="feature.title"
35
+ :details="feature.details"
36
+ />
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </template>
42
+
43
+ <style scoped>
44
+ .VPHomeFeatures {
45
+ padding: 0 24px;
46
+ }
47
+
48
+ @media (min-width: 640px) {
49
+ .VPHomeFeatures {
50
+ padding: 0 48px;
51
+ }
52
+ }
53
+
54
+ .container {
55
+ margin: 0 auto;
56
+ max-width: 960px;
57
+ }
58
+
59
+ .items {
60
+ display: flex;
61
+ flex-wrap: wrap;
62
+ margin: -8px;
63
+ }
64
+
65
+ .item {
66
+ padding: 8px;
67
+ width: 100%;
68
+ }
69
+
70
+ @media (min-width: 640px) {
71
+ .item.grid-2,
72
+ .item.grid-4,
73
+ .item.grid-6 {
74
+ width: calc(100% / 2);
75
+ }
76
+ }
77
+
78
+ @media (min-width: 768px) {
79
+ .item.grid-2,
80
+ .item.grid-4 {
81
+ width: calc(100% / 2);
82
+ }
83
+
84
+ .item.grid-3,
85
+ .item.grid-6 {
86
+ width: calc(100% / 3);
87
+ }
88
+ }
89
+
90
+ @media (min-width: 960px) {
91
+ .item.grid-4 {
92
+ width: calc(100% / 4);
93
+ }
94
+ }
95
+
96
+ </style>
@@ -0,0 +1,17 @@
1
+ <script setup lang="ts">
2
+ import { useData } from 'vitepress'
3
+ import VPHero from './VPHero.vue'
4
+
5
+ const { frontmatter: fm } = useData()
6
+ </script>
7
+
8
+ <template>
9
+ <div v-if="fm.hero" class="VPHomeHero">
10
+ <VPHero
11
+ :name="fm.hero.name"
12
+ :text="fm.hero.text"
13
+ :tagline="fm.hero.tagline"
14
+ :actions="fm.hero.actions"
15
+ />
16
+ </div>
17
+ </template>
@@ -0,0 +1,93 @@
1
+ <script setup lang="ts">
2
+ import VPIconHeart from './icons/VPIconHeart.vue'
3
+ import VPButton from './VPButton.vue'
4
+ import VPSponsors from './VPSponsors.vue'
5
+
6
+ interface Sponsors {
7
+ tier: string
8
+ size?: 'medium' | 'big'
9
+ items: Sponsor[]
10
+ }
11
+
12
+ interface Sponsor {
13
+ name: string
14
+ img: string
15
+ url: string
16
+ }
17
+
18
+ defineProps<{
19
+ message?: string
20
+ actionText?: string
21
+ actionLink?: string
22
+ data: Sponsors[]
23
+ }>()
24
+ </script>
25
+
26
+ <template>
27
+ <section class="VPHomeSponsors">
28
+ <div class="container">
29
+ <div class="header">
30
+ <div class="love"><VPIconHeart class="icon" /></div>
31
+ <h2 v-if="message" class="message">{{ message }}</h2>
32
+ </div>
33
+
34
+ <div class="sponsors">
35
+ <VPSponsors :data="data" />
36
+ </div>
37
+
38
+ <div v-if="actionLink" class="action">
39
+ <VPButton
40
+ theme="sponsor"
41
+ :text="actionText ?? 'Become a sponsor'"
42
+ :href="actionLink"
43
+ />
44
+ </div>
45
+ </div>
46
+ </section>
47
+ </template>
48
+
49
+ <style scoped>
50
+ .VPHomeSponsors {
51
+ border-top: 1px solid var(--vp-c-divider-light);
52
+ padding: 88px 24px 96px;
53
+ background-color: var(--vp-c-bg-content);
54
+ }
55
+
56
+ .container {
57
+ margin: 0 auto;
58
+ max-width: 960px;
59
+ }
60
+
61
+ .love {
62
+ margin: 0 auto;
63
+ width: 28px;
64
+ height: 28px;
65
+ color: var(--vp-c-text-3);
66
+ }
67
+
68
+ .icon {
69
+ width: 28px;
70
+ height: 28px;
71
+ fill: currentColor;
72
+ }
73
+
74
+ .message {
75
+ margin: 0 auto;
76
+ padding-top: 10px;
77
+ max-width: 320px;
78
+ text-align: center;
79
+ line-height: 24px;
80
+ font-size: 16px;
81
+ font-weight: 500;
82
+ color: var(--vp-c-text-2);
83
+ }
84
+
85
+ .sponsors {
86
+ padding-top: 32px;
87
+ }
88
+
89
+ .action {
90
+ padding-top: 40px;
91
+ text-align: center;
92
+ }
93
+ </style>
@@ -66,7 +66,7 @@ defineEmits<{
66
66
  display: flex;
67
67
  justify-content: space-between;
68
68
  margin: 0 auto;
69
- max-width: var(--vp-layout-max-width);
69
+ max-width: calc(var(--vp-layout-max-width) - 64px);
70
70
  }
71
71
 
72
72
  .content {
@@ -84,6 +84,7 @@ defineEmits<{
84
84
 
85
85
  .menu + .translations::before,
86
86
  .menu + .appearance::before,
87
+ .menu + .social-links::before,
87
88
  .translations + .appearance::before,
88
89
  .appearance + .social-links::before {
89
90
  margin-right: 8px;
@@ -1,9 +1,12 @@
1
1
  <script lang="ts" setup>
2
+ import { useData } from 'vitepress'
2
3
  import VPSwitchAppearance from './VPSwitchAppearance.vue'
4
+
5
+ const { site } = useData()
3
6
  </script>
4
7
 
5
8
  <template>
6
- <div class="VPNavBarAppearance">
9
+ <div v-if="site.appearance" class="VPNavBarAppearance">
7
10
  <VPSwitchAppearance />
8
11
  </div>
9
12
  </template>
@@ -4,7 +4,7 @@ import VPFlyout from './VPFlyout.vue'
4
4
  import VPSwitchAppearance from './VPSwitchAppearance.vue'
5
5
  import VPSocialLinks from './VPSocialLinks.vue'
6
6
 
7
- const { theme } = useData()
7
+ const { site, theme } = useData()
8
8
  </script>
9
9
 
10
10
  <template>
@@ -23,7 +23,7 @@ const { theme } = useData()
23
23
  </div>
24
24
  </div>
25
25
 
26
- <div class="group">
26
+ <div v-if="site.appearance" class="group">
27
27
  <div class="item">
28
28
  <p class="label">Appearance</p>
29
29
  <div class="appearance-action">
@@ -3,9 +3,9 @@ import '@docsearch/css'
3
3
  import { useData } from 'vitepress'
4
4
  import { defineAsyncComponent, ref, onMounted, onUnmounted } from 'vue'
5
5
 
6
- const VPAlgoliaSearchBox = defineAsyncComponent(
7
- () => import('./VPAlgoliaSearchBox.vue')
8
- )
6
+ const VPAlgoliaSearchBox = defineAsyncComponent(() => {
7
+ return import('./VPAlgoliaSearchBox.vue')
8
+ })
9
9
 
10
10
  const { theme } = useData()
11
11
 
@@ -1,39 +1,52 @@
1
1
  <script setup lang="ts">
2
2
  import { useData } from 'vitepress'
3
+ import { useSidebar } from '../composables/sidebar'
3
4
 
4
5
  const { site, theme } = useData()
6
+ const { hasSidebar } = useSidebar()
5
7
  </script>
6
8
 
7
9
  <template>
8
- <a class="VPNavBarTitle" href="/">
9
- <img v-if="theme.logo" class="logo" :src="theme.logo" :alt="site.title">
10
- {{ site.title }}
11
- </a>
10
+ <div class="VPNavBarTitle" :class="{ 'has-sidebar': hasSidebar }">
11
+ <a class="title" href="/">
12
+ <img v-if="theme.logo" class="logo" :src="theme.logo" :alt="site.title">
13
+ {{ site.title }}
14
+ </a>
15
+ </div>
12
16
  </template>
13
17
 
14
18
  <style scoped>
15
19
  .VPNavBarTitle {
20
+ flex-shrink: 0;
21
+ }
22
+
23
+ @media (min-width: 960px) {
24
+ .VPNavBarTitle.has-sidebar {
25
+ margin-right: 32px;
26
+ width: calc(var(--vp-sidebar-width) - 64px);
27
+ border-bottom: 1px solid var(--vp-c-divider-light);
28
+ background-color: var(--vp-c-bg-sidebar);
29
+ }
30
+ }
31
+
32
+ .title {
16
33
  display: flex;
17
34
  align-items: center;
18
- height: var(--vp-nav-height-mobile);
35
+ width: 100%;
36
+ height: var(--vp-nav-height);
19
37
  font-size: 16px;
20
38
  font-weight: 600;
21
39
  color: var(--vp-c-text-1);
22
- transition: background-color 0.5s, opacity 0.25s;
40
+ transition: opacity 0.25s;
23
41
  }
24
42
 
25
- .VPNavBarTitle:hover {
43
+ .title:hover {
26
44
  opacity: 0.6;
27
45
  }
28
46
 
29
47
  @media (min-width: 960px) {
30
- .VPNavBarTitle {
48
+ .title {
31
49
  flex-shrink: 0;
32
- margin-right: 32px;
33
- border-bottom: 1px solid var(--vp-c-divider-light);
34
- width: calc(var(--vp-sidebar-width) - 64px);
35
- height: var(--vp-nav-height-desktop);
36
- background-color: var(--vp-c-bg-sidebar);
37
50
  }
38
51
  }
39
52
 
@@ -1,9 +1,12 @@
1
1
  <script lang="ts" setup>
2
+ import { useData } from 'vitepress'
2
3
  import VPSwitchAppearance from './VPSwitchAppearance.vue'
4
+
5
+ const { site } = useData()
3
6
  </script>
4
7
 
5
8
  <template>
6
- <div class="VPNavScreenAppearance">
9
+ <div v-if="site.appearance" class="VPNavScreenAppearance">
7
10
  <p class="text">Appearance</p>
8
11
  <VPSwitchAppearance />
9
12
  </div>
@@ -0,0 +1,5 @@
1
+ <template>
2
+ <div class="VPPage">
3
+ <Content />
4
+ </div>
5
+ </template>
@@ -91,8 +91,8 @@ watchPostEffect(async () => {
91
91
 
92
92
  @media (min-width: 1440px) {
93
93
  .VPSidebar {
94
- padding-left: calc((100% - var(--vp-layout-max-width)) / 2);
95
- width: calc((100% - var(--vp-layout-max-width)) / 2 + var(--vp-sidebar-width) - 32px);
94
+ padding-left: calc((100% - (var(--vp-layout-max-width) - 64px)) / 2);
95
+ width: calc((100% - (var(--vp-layout-max-width) - 64px)) / 2 + var(--vp-sidebar-width) - 32px);
96
96
  }
97
97
  }
98
98
 
@@ -0,0 +1,77 @@
1
+ <script setup lang="ts">
2
+ import { computed } from 'vue'
3
+ import VPSponsorsGrid from './VPSponsorsGrid.vue'
4
+
5
+ interface Sponsors {
6
+ tier?: string
7
+ size?: 'small' | 'medium' | 'big'
8
+ items: Sponsor[]
9
+ }
10
+
11
+ interface Sponsor {
12
+ name: string
13
+ img: string
14
+ url: string
15
+ }
16
+
17
+ const props = defineProps<{
18
+ tier?: string
19
+ size?: 'small' | 'medium' | 'big'
20
+ data: Sposors[] | Sponsor[]
21
+ }>()
22
+
23
+ const sponsors = computed(() => {
24
+ const isSponsors = props.data.some((s: any) => s.items)
25
+
26
+ if (isSponsors) {
27
+ return props.data
28
+ }
29
+
30
+ return [{
31
+ tier: props.tier,
32
+ size: props.size,
33
+ items: props.data
34
+ }]
35
+ })
36
+ </script>
37
+
38
+ <template>
39
+ <div class="VPSponsors">
40
+ <section v-for="(sponsor, index) in sponsors" :key="index" class="section">
41
+ <h3 v-if="sponsor.tier" class="tier">{{ sponsor.tier }}</h3>
42
+ <VPSponsorsGrid :size="sponsor.size" :data="sponsor.items" />
43
+ </section>
44
+ </div>
45
+ </template>
46
+
47
+ <style scoped>
48
+ .VPSponsors {
49
+ border-radius: 16px;
50
+ overflow: hidden;
51
+ }
52
+
53
+ .section + .section {
54
+ margin-top: 4px;
55
+ }
56
+
57
+ .tier {
58
+ margin-bottom: 4px;
59
+ padding: 13px 0 11px;
60
+ text-align: center;
61
+ letter-spacing: 1px;
62
+ line-height: 24px;
63
+ width: 100%;
64
+ font-size: 14px;
65
+ font-weight: 600;
66
+ color: var(--vp-c-text-2);
67
+ background-color: var(--vp-c-white-soft);
68
+ }
69
+
70
+ .dark .tier {
71
+ background-color: var(--vp-c-black-mute);
72
+ }
73
+
74
+ .VPSponsorsGrid + .tier {
75
+ margin-top: 4px;
76
+ }
77
+ </style>