Skip to content

Commit

Permalink
fix: remove hard code image in hero component
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyuan0704 committed Sep 18, 2022
1 parent 647cc47 commit 2bd354f
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 13 deletions.
6 changes: 3 additions & 3 deletions docs/.island/config.ts
Expand Up @@ -2,8 +2,8 @@ import { defineConfig } from '../../dist';

export default defineConfig({
lang: 'en-US',
title: '666',
icon: '/icon.png',
title: 'Island.js',
icon: '/island.png',
themeConfig: {
socialLinks: [
{
Expand Down Expand Up @@ -37,7 +37,7 @@ function getTutorialSidebar() {
]
},
{
text: 'Concepts',
text: 'Architecture',
items: [
{ text: 'SPA vs MPA', link: '/guide/spa-vs-mpa' },
{ text: 'Islands Architecture', link: '/guide/islands-arch' }
Expand Down
3 changes: 3 additions & 0 deletions docs/index.md
Expand Up @@ -5,6 +5,9 @@ hero:
name: Island
text: Vite & Islands Arch Static Site Generator
tagline: Simple, powerful, and performant. Meet the modern SSG framework you've always wanted.
image:
src: /island.png
alt: Island
actions:
- theme: brand
text: Get Started
Expand Down
Binary file removed docs/public/icon.png
Binary file not shown.
File renamed without changes
1 change: 0 additions & 1 deletion src/node/plugin-island/config.ts
Expand Up @@ -34,7 +34,6 @@ export function pluginConfig(
},
config(c) {
return {
root: PACKAGE_ROOT_PATH,
optimizeDeps: {
include: [
'react',
Expand Down
2 changes: 1 addition & 1 deletion src/node/plugin.ts
Expand Up @@ -7,7 +7,7 @@ import { SiteConfig } from '../shared/types';
import { pluginMdx } from './plugin-mdx';
import babelPluginIsland from './babel-plugin-island';
import { ISLAND_JSX_RUNTIME_PATH } from './constants/index';
import pluginInspect from 'vite-plugin-inspect';
// import pluginInspect from 'vite-plugin-inspect';

export async function createIslandPlugins(
config: SiteConfig,
Expand Down
4 changes: 4 additions & 0 deletions src/shared/types/index.ts
Expand Up @@ -112,6 +112,10 @@ export interface Hero {
name: string;
text: string;
tagline: string;
image?: {
src: string;
alt: string;
};
actions: {
text: string;
link: string;
Expand Down
19 changes: 11 additions & 8 deletions src/theme-default/components/HomeHero/index.tsx
@@ -1,21 +1,22 @@
import { usePageData } from 'island/client';
import { Button } from '../Button';
import styles from './index.module.scss';
import logo from './island.png';
import { normalizeHref } from '../../logic/index';

const DEFAULT_HERO = {
name: 'Island',
text: 'Island ssg',
tagline: 'Island ssg',
actions: []
actions: [],
image: undefined
};

export function HomeHero() {
const { hero = DEFAULT_HERO } = usePageData();
const hasImage = hero.image !== undefined;

return (
<div className={`${styles.hero} ${styles.hasImage}`}>
<div className={`${styles.hero} ${hasImage ? styles.hasImage : ''}`}>
<div className={styles.container}>
<div className={styles.main}>
<h1 className={styles.name}>
Expand All @@ -36,12 +37,14 @@ export function HomeHero() {
))}
</div>
</div>
<div className={styles.image}>
<div className={styles.imageContainer}>
<div className={styles.imageBg} />
<img src={logo} alt="" />
{hasImage ? (
<div className={styles.image}>
<div className={styles.imageContainer}>
<div className={styles.imageBg} />
<img src={hero.image?.src} alt={hero.image?.alt} />
</div>
</div>
</div>
) : null}
</div>
</div>
);
Expand Down

0 comments on commit 2bd354f

Please sign in to comment.