Skip to content

Commit

Permalink
fix:部分文档因修改语言导致的路径错误
Browse files Browse the repository at this point in the history
  • Loading branch information
AyalaKaguya committed Dec 16, 2023
1 parent cf2eb5c commit acc658d
Show file tree
Hide file tree
Showing 77 changed files with 4,678 additions and 79 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ theme_eject/
.temp

# yarn
yarn-error.log
yarn-error.log

# Ignore tmep code
default-theme/
4 changes: 1 addition & 3 deletions src/.vuepress/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export default defineClientConfig({
app.use(store)
},
setup() { },
layouts: {

},
layouts: { },
rootComponents: [],
})
2 changes: 1 addition & 1 deletion src/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default defineUserConfig({
],

// 主题配置
theme: mduiTheme({
theme: defaultTheme({
// 基本配置
logo: "/icons/logo.ico",
repo: "easybangumiorg/easybangumi",
Expand Down
119 changes: 119 additions & 0 deletions src/.vuepress/theme/components/AutoLink.vue
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>
25 changes: 25 additions & 0 deletions src/.vuepress/theme/components/DropdownTransition.vue
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>
15 changes: 15 additions & 0 deletions src/.vuepress/theme/components/Home.vue
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>
5 changes: 5 additions & 0 deletions src/.vuepress/theme/components/HomeContent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<template>
<div class="theme-default-content">
<Content />
</div>
</template>
23 changes: 23 additions & 0 deletions src/.vuepress/theme/components/HomeFeatures.vue
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>
17 changes: 17 additions & 0 deletions src/.vuepress/theme/components/HomeFooter.vue
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>
98 changes: 98 additions & 0 deletions src/.vuepress/theme/components/HomeHero.vue
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>
Loading

0 comments on commit acc658d

Please sign in to comment.