-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cf2eb5c
commit acc658d
Showing
77 changed files
with
4,678 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,7 @@ theme_eject/ | |
.temp | ||
|
||
# yarn | ||
yarn-error.log | ||
yarn-error.log | ||
|
||
# Ignore tmep code | ||
default-theme/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<script lang="ts"> | ||
/* eslint-disable import/first, import/no-duplicates, import/order */ | ||
import { defineComponent } from 'vue' | ||
export default defineComponent({ | ||
inheritAttrs: false, | ||
}) | ||
/* eslint-enable import/order */ | ||
</script> | ||
|
||
<script setup lang="ts"> | ||
import { useSiteData } from '@vuepress/client' | ||
import { isLinkHttp, isLinkWithProtocol } from '@vuepress/shared' | ||
import { computed, toRefs } from 'vue' | ||
import type { PropType } from 'vue' | ||
import { useRoute } from 'vue-router' | ||
import type { NavLink } from '../shared/index.js' | ||
const props = defineProps({ | ||
item: { | ||
type: Object as PropType<NavLink>, | ||
required: true, | ||
}, | ||
}) | ||
defineSlots<{ | ||
before?: (props: Record<never, never>) => any | ||
after?: (props: Record<never, never>) => any | ||
}>() | ||
const route = useRoute() | ||
const site = useSiteData() | ||
const { item } = toRefs(props) | ||
// if the link has http protocol | ||
const hasHttpProtocol = computed(() => isLinkHttp(item.value.link)) | ||
// if the link has non-http protocol | ||
const hasNonHttpProtocol = computed( | ||
() => !hasHttpProtocol.value && isLinkWithProtocol(item.value.link), | ||
) | ||
// resolve the `target` attr | ||
const linkTarget = computed(() => { | ||
if (hasNonHttpProtocol.value) return undefined | ||
if (item.value.target) return item.value.target | ||
if (hasHttpProtocol.value) return '_blank' | ||
return undefined | ||
}) | ||
// if the `target` attr is '_blank' | ||
const isBlankTarget = computed(() => linkTarget.value === '_blank') | ||
// is `<RouterLink>` or not | ||
const isRouterLink = computed( | ||
() => | ||
!hasHttpProtocol.value && !hasNonHttpProtocol.value && !isBlankTarget.value, | ||
) | ||
// resolve the `rel` attr | ||
const linkRel = computed(() => { | ||
if (hasNonHttpProtocol.value) return undefined | ||
if (item.value.rel) return item.value.rel | ||
if (isBlankTarget.value) return 'noopener noreferrer' | ||
return undefined | ||
}) | ||
// resolve the `aria-label` attr | ||
const linkAriaLabel = computed(() => item.value.ariaLabel || item.value.text) | ||
// should be active when current route is a subpath of this link | ||
const shouldBeActiveInSubpath = computed(() => { | ||
const localeKeys = Object.keys(site.value.locales) | ||
if (localeKeys.length) { | ||
return !localeKeys.some((key) => key === item.value.link) | ||
} | ||
return item.value.link !== '/' | ||
}) | ||
// if this link is active in subpath | ||
const isActiveInSubpath = computed(() => { | ||
if (!shouldBeActiveInSubpath.value) { | ||
return false | ||
} | ||
return route.path.startsWith(item.value.link) | ||
}) | ||
// if this link is active | ||
const isActive = computed(() => { | ||
if (!isRouterLink.value) { | ||
return false | ||
} | ||
if (item.value.activeMatch) { | ||
return new RegExp(item.value.activeMatch).test(route.path) | ||
} | ||
return isActiveInSubpath.value | ||
}) | ||
</script> | ||
|
||
<template> | ||
<RouterLink | ||
v-if="isRouterLink" | ||
:class="{ 'router-link-active': isActive }" | ||
:to="item.link" | ||
:aria-label="linkAriaLabel" | ||
v-bind="$attrs" | ||
> | ||
<slot name="before" /> | ||
{{ item.text }} | ||
<slot name="after" /> | ||
</RouterLink> | ||
<a | ||
v-else | ||
class="external-link" | ||
:href="item.link" | ||
:rel="linkRel" | ||
:target="linkTarget" | ||
:aria-label="linkAriaLabel" | ||
v-bind="$attrs" | ||
> | ||
<slot name="before" /> | ||
{{ item.text }} | ||
<AutoLinkExternalIcon v-if="isBlankTarget" /> | ||
<slot name="after" /> | ||
</a> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<script setup lang="ts"> | ||
defineSlots<{ | ||
default?: (props: Record<never, never>) => any | ||
}>() | ||
const setHeight = (items): void => { | ||
// explicitly set height so that it can be transitioned | ||
items.style.height = items.scrollHeight + 'px' | ||
} | ||
const unsetHeight = (items): void => { | ||
items.style.height = '' | ||
} | ||
</script> | ||
|
||
<template> | ||
<Transition | ||
name="dropdown" | ||
@enter="setHeight" | ||
@after-enter="unsetHeight" | ||
@before-leave="setHeight" | ||
> | ||
<slot /> | ||
</Transition> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script setup lang="ts"> | ||
import HomeContent from './HomeContent.vue' | ||
import HomeFeatures from './HomeFeatures.vue' | ||
import HomeFooter from './HomeFooter.vue' | ||
import HomeHero from './HomeHero.vue' | ||
</script> | ||
|
||
<template> | ||
<main class="home"> | ||
<HomeHero /> | ||
<HomeFeatures /> | ||
<HomeContent /> | ||
<HomeFooter /> | ||
</main> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="theme-default-content"> | ||
<Content /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script setup lang="ts"> | ||
import { usePageFrontmatter } from '@vuepress/client' | ||
import { isArray } from '@vuepress/shared' | ||
import { computed } from 'vue' | ||
import type { DefaultThemeHomePageFrontmatter } from '../shared/index.js' | ||
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>() | ||
const features = computed(() => { | ||
if (isArray(frontmatter.value.features)) { | ||
return frontmatter.value.features | ||
} | ||
return [] | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div v-if="features.length" class="features"> | ||
<div v-for="feature in features" :key="feature.title" class="feature"> | ||
<h2>{{ feature.title }}</h2> | ||
<p>{{ feature.details }}</p> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<script setup lang="ts"> | ||
import { usePageFrontmatter } from '@vuepress/client' | ||
import { computed } from 'vue' | ||
import type { DefaultThemeHomePageFrontmatter } from '../shared/index.js' | ||
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>() | ||
const footer = computed(() => frontmatter.value.footer) | ||
const footerHtml = computed(() => frontmatter.value.footerHtml) | ||
</script> | ||
|
||
<template> | ||
<template v-if="footer"> | ||
<!-- eslint-disable-next-line vue/no-v-html --> | ||
<div v-if="footerHtml" class="footer" v-html="footer" /> | ||
<div v-else class="footer" v-text="footer" /> | ||
</template> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<script setup lang="ts"> | ||
import AutoLink from './AutoLink.vue' | ||
import { | ||
ClientOnly, | ||
usePageFrontmatter, | ||
useSiteLocaleData, | ||
withBase, | ||
} from '@vuepress/client' | ||
import { isArray } from '@vuepress/shared' | ||
import type { FunctionalComponent } from 'vue' | ||
import { computed, h } from 'vue' | ||
import type { DefaultThemeHomePageFrontmatter } from '../shared/index.js' | ||
import { useDarkMode } from '../composables/index.js' | ||
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>() | ||
const siteLocale = useSiteLocaleData() | ||
const isDarkMode = useDarkMode() | ||
const heroImage = computed(() => { | ||
if (isDarkMode.value && frontmatter.value.heroImageDark !== undefined) { | ||
return frontmatter.value.heroImageDark | ||
} | ||
return frontmatter.value.heroImage | ||
}) | ||
const heroAlt = computed( | ||
() => frontmatter.value.heroAlt || heroText.value || 'hero', | ||
) | ||
const heroHeight = computed(() => frontmatter.value.heroHeight || 280) | ||
const heroText = computed(() => { | ||
if (frontmatter.value.heroText === null) { | ||
return null | ||
} | ||
return frontmatter.value.heroText || siteLocale.value.title || 'Hello' | ||
}) | ||
const tagline = computed(() => { | ||
if (frontmatter.value.tagline === null) { | ||
return null | ||
} | ||
return ( | ||
frontmatter.value.tagline || | ||
siteLocale.value.description || | ||
'Welcome to your VuePress site' | ||
) | ||
}) | ||
const actions = computed(() => { | ||
if (!isArray(frontmatter.value.actions)) { | ||
return [] | ||
} | ||
return frontmatter.value.actions.map(({ text, link, type = 'primary' }) => ({ | ||
text, | ||
link, | ||
type, | ||
})) | ||
}) | ||
const HomeHeroImage: FunctionalComponent = () => { | ||
if (!heroImage.value) return null | ||
const img = h('img', { | ||
src: withBase(heroImage.value), | ||
alt: heroAlt.value, | ||
height: heroHeight.value, | ||
}) | ||
if (frontmatter.value.heroImageDark === undefined) { | ||
return img | ||
} | ||
// wrap hero image with <ClientOnly> to avoid ssr-mismatch | ||
// when using a different hero image in dark mode | ||
return h(ClientOnly, () => img) | ||
} | ||
</script> | ||
|
||
<template> | ||
<header class="hero"> | ||
<HomeHeroImage /> | ||
|
||
<h1 v-if="heroText" id="main-title"> | ||
{{ heroText }} | ||
</h1> | ||
|
||
<p v-if="tagline" class="description"> | ||
{{ tagline }} | ||
</p> | ||
|
||
<p v-if="actions.length" class="actions"> | ||
<AutoLink | ||
v-for="action in actions" | ||
:key="action.text" | ||
class="action-button" | ||
:class="[action.type]" | ||
:item="action" | ||
/> | ||
</p> | ||
</header> | ||
</template> |
Oops, something went wrong.