-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
12 changed files
with
734 additions
and
33 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,19 +1,12 @@ | ||
import { usePageData } from '../../' | ||
import { Nav } from '../components/Nav' | ||
import '../styles/base.css' | ||
import '../styles/vars.css' | ||
import 'uno.css' | ||
|
||
export function Layout() { | ||
const pageData = usePageData() | ||
// 获取 pageType | ||
const { pageType } = pageData | ||
// 根据 pageType 分发不同的页面内容 | ||
const getContent = () => { | ||
if (pageType === 'home') { | ||
return <div>Home 页面</div> | ||
} else if (pageType === 'doc') { | ||
return <div>正文页面</div> | ||
} else { | ||
return <div>404 页面</div> | ||
} | ||
} | ||
return <div>{getContent()}</div> | ||
return ( | ||
<div> | ||
<Nav /> | ||
</div> | ||
) | ||
} |
20 changes: 20 additions & 0 deletions
20
src/runtime/theme-default/components/Nav/index.module.scss
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,20 @@ | ||
.link:hover { | ||
color: var(--island-c-brand); | ||
transition: color 0.2s; | ||
} | ||
|
||
.link { | ||
display: block; | ||
font-size: 14px; | ||
font-weight: 500; | ||
} | ||
|
||
.social-link-icon { | ||
display: flex; | ||
fill: currentColor; | ||
transition: color 0.2s; | ||
color: var(--island-c-text-2); | ||
&:hover { | ||
color: var(--island-c-text-1); | ||
} | ||
} |
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,55 @@ | ||
import { usePageData } from '../../../' | ||
import styles from './index.module.scss' | ||
import type { NavItemWithLink } from 'shared/types' | ||
|
||
export function MenuItem(item: NavItemWithLink) { | ||
return ( | ||
<div className="text-sm font-medium mx-3"> | ||
<a href={item.link} className={styles.link}> | ||
{item.text} | ||
</a> | ||
</div> | ||
) | ||
} | ||
|
||
export function Nav() { | ||
const { siteData } = usePageData() | ||
const nav = siteData.themeConfig.nav || [] | ||
return ( | ||
// {/* 视频中包含 relative="~",属于无效代码,需要去掉 */} | ||
<header fixed="~" pos="t-0 l-0" w="full"> | ||
<div | ||
flex="~" | ||
items="center" | ||
justify="between" | ||
// {/* divider-bottom 为自定义规则*/} | ||
className="px-8 h-14 divider-bottom" | ||
> | ||
<div> | ||
<a | ||
href="/" | ||
hover="opacity-60" | ||
className="w-full h-full text-1rem font-semibold flex items-center" | ||
> | ||
Island.js | ||
</a> | ||
</div> | ||
<div flex="~"> | ||
{/* 普通菜单 */} | ||
<div flex="~"> | ||
{nav.map((item) => ( | ||
<MenuItem {...item} key={item.text} /> | ||
))} | ||
</div> | ||
{/* 白天/夜间模式切换 */} | ||
{/* 相关链接 */} | ||
<div className={styles.socialLinkIcon} ml="2"> | ||
<a href="/"> | ||
<div className="i-carbon-logo-github w-5 h-5 fill-current"></div> | ||
</a> | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
) | ||
} |
Oops, something went wrong.