Skip to content

Commit

Permalink
feat: lazy load components and update resume (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexieyizhe authored Jul 16, 2020
1 parent d443d96 commit 1fb9631
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Continuous Integration
on: push

jobs:
ci:
checks:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip')"
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ jobs:
git checkout master
npm version $VERSION_TAG --git-tag-version=false
git commit -am "ci: release version $VERSION_TAG [ci skip]"
git commit -am "chore: bump version to $VERSION_TAG [ci skip]"
git push origin -f HEAD:release
git push origin HEAD:master
git push origin -f HEAD:master
38 changes: 38 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"version": "3.0.0",
"author": "Alex Xie <[email protected]>",
"dependencies": {
"@loadable/component": "^5.13.1",
"gatsby": "^2.24.3",
"gatsby-image": "^2.2.26",
"gatsby-plugin-alias-imports": "^1.0.5",
Expand Down Expand Up @@ -32,6 +33,7 @@
"styled-components": "^4.4.0"
},
"devDependencies": {
"@types/loadable__component": "^5.13.0",
"@types/react": "^16.9.5",
"@types/react-dom": "^16.9.1",
"@types/react-helmet": "^5.0.11",
Expand Down
Binary file modified src/assets/resume/current.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/assets/resume/current.pdf
Binary file not shown.
61 changes: 16 additions & 45 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,50 +1,21 @@
import React, { useState, useEffect } from "react";
import React from "react";
import loadable from "@loadable/component";

import PageWrapper from "~components/PageWrapper";
import LandingSection from "~sections/landing";

const importFeatured = () =>
import("../sections/featured").then(component => component.default);
const importAbout = () =>
import("../sections/about").then(component => component.default);
const importShowcase = () =>
import("../sections/showcase").then(component => component.default);
const importFooter = () =>
import("../components/Footer").then(component => component.default);

const IndexPage = () => {
const [FeaturedSection, setFeaturedSection] = useState<React.FC | null>(null);
const [AboutSection, setAboutSection] = useState<React.FC | null>(null);
const [ShowcaseSection, setShowcaseSection] = useState<React.FC | null>(null);
const [FooterSection, setFooterSection] = useState<React.FC | null>(null);

useEffect(() => {
const loadComponents = async () => {
const featuredSection = await importFeatured();
setFeaturedSection(featuredSection);

const aboutSection = await importAbout();
setAboutSection(aboutSection);

const showcaseSection = await importShowcase();
setShowcaseSection(showcaseSection);

const footerSection = await importFooter();
setFooterSection(footerSection);
};

loadComponents();
}, []);

return (
<PageWrapper>
<LandingSection />
{FeaturedSection}
{AboutSection}
{ShowcaseSection}
{FooterSection}
</PageWrapper>
);
};

const Featured = loadable(() => import("~sections/featured"));
const About = loadable(() => import("~sections/about"));
const Showcase = loadable(() => import("~sections/showcase"));
const Footer = loadable(() => import("~components/Footer"));

const IndexPage = () => (
<PageWrapper>
<LandingSection />
<Featured />
<About />
<Showcase />
<Footer />
</PageWrapper>
);
export default IndexPage;

1 comment on commit 1fb9631

@vercel
Copy link

@vercel vercel bot commented on 1fb9631 Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.