Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move things around for a neater project structure #9

Merged
merged 2 commits into from
Jul 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .storybook/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { configure, addDecorator, addParameters } from '@storybook/react'
import React from 'react'
import {createRenderer} from 'fela'
import {RendererProvider} from 'react-fela'
import {cssReset} from '../components/global_css'
import {cssReset} from '../app/components/global_css'

// Setup Fela client runtime
const renderer = createRenderer({devMode: true})
Expand All @@ -18,5 +18,5 @@ addParameters({
})

configure([
require.context('../components', true, /.stories.js$/)
require.context('../app/components', true, /.stories.js$/)
], module)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react'
import { useFela } from 'react-fela'
import island from '../../images/island.jpg'
import {asIsland} from '../../lib/isomorphic_helpers'
import {asIsland} from '../../isomorphic_helpers'

const styles = {
root: {
Expand Down
34 changes: 34 additions & 0 deletions app/entry.client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
This is the JS file loaded in the browser by all static pages.

⚠️ Client-side JS is totally optional in San Blas! ⚠️
You can delete everything in here if you don't need it.

Or you can run whatever client-side JS you do need:
Analytics snippets, ReactDOM.render(), fancy graphs, etc...
*/

/*
⚛️ Optional:
Rehydrate prerendered React/Fela components using San Blas isomorphic helpers.

If you use asIsland() to render components in your pages, the following code
will rehydrate those components with the same props.

If you remove this code, the prerendered component HTML won't be rehydrated.
*/

import { createRenderer } from 'fela'
import { rehydrate } from 'fela-dom'
import { rehydrateIslands } from './isomorphic_helpers'

// Rehydrate Fela styles
const felaRenderer = createRenderer()
rehydrate(felaRenderer)

// Rehydrate San Blas islands
import WelcomeBanner from './components/welcome_banner/welcome_banner'

rehydrateIslands({
WelcomeBanner
}, felaRenderer)
8 changes: 4 additions & 4 deletions lib/entry.prerender.js → app/entry.prerender.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ import { createRenderer } from 'fela'
import { RendererProvider } from 'react-fela'
import { renderToMarkup } from 'fela-dom'
import { Helmet } from 'react-helmet'
import { cssReset } from '../components/global_css'
import documentTemplate from '../layouts/document_template'
import DefaultLayout from '../layouts/default_layout'
import { cssReset } from './components/global_css'
import documentTemplate from './layouts/document_template'
import DefaultLayout from './layouts/default_layout'

export default function prerender (manifest, mode) {
/*
1. Require every JS and MDX file in the `pages` directory and create a useful collection of 'page' objects.
(uses Webpack's context module API, see https://webpack.js.org/guides/dependency-management/)
*/
const pages = []
const req = require.context('../pages', true, /^(?!.*\/_).*(js|mdx)$/)
const req = require.context('./pages', true, /^(?!.*\/_).*(js|mdx)$/)
req.keys().forEach(sourceFilePath => {
const pageModule = req(sourceFilePath)
const sourceFile = path.parse(sourceFilePath)
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
30 changes: 0 additions & 30 deletions lib/entry.client.js

This file was deleted.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"name": "sanblas",
"version": "2.0.1",
"scripts": {
"start": "concurrently \"node ./lib/build.js development\" \"serve\" --kill-others --prefix-colors=yellow.dim,cyan.dim",
"build": "node ./lib/build.js production",
"start": "concurrently \"node ./app/build.js development\" \"serve\" --kill-others --prefix-colors=yellow.dim,cyan.dim",
"build": "node ./app/build.js production",
"storybook": "start-storybook --port 9000"
},
"license": "MIT",
Expand Down