Last active
April 29, 2020 16:16
-
-
Save kimrgrey/80d61771650f7a9c87b326c2d9bf7335 to your computer and use it in GitHub Desktop.
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
package server | |
import ( | |
"fmt" | |
"github.com/trickstersio/go-create-react-app/webpack" | |
) | |
// User represents current user session | |
type User struct { | |
Email string | |
FirstName string | |
LastName string | |
} | |
// ViewData contains data for the view | |
type ViewData struct { | |
CurrentUser User | |
Webpack *webpack.Webpack | |
} | |
// NewViewData creates new data for the view | |
func NewViewData(buildPath string) (ViewData, error) { | |
wp, err := webpack.New(buildPath) | |
if err != nil { | |
return ViewData{}, fmt.Errorf("failed to read webpack configuration: %w", err) | |
} | |
return ViewData{ | |
CurrentUser: User{ | |
Email: "bill@example.com", | |
FirstName: "Bill", | |
LastName: "Black", | |
}, | |
Webpack: wp, | |
}, nil | |
} | |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Create React App on the Go</title> | |
<link href="https://fonts.googleapis.com/css?family=Roboto:400,400i,500,500i,700,700i&subset=cyrillic" rel="stylesheet"> | |
{{ range .Webpack.Manifest.Entrypoints.Styles }} | |
<link href="{{ . }}" rel="stylesheet"> | |
{{ end }} | |
<style> | |
<!-- some layout styles goes here --> | |
</style> | |
</head> | |
<body> | |
<div class="page"> | |
<div class="header"> | |
<div class="burger"> | |
<span class="burger-item"></span> | |
<span class="burger-item"></span> | |
<span class="burger-item"></span> | |
</div> | |
<div class="title"> | |
My Awesome App | |
</div> | |
<div class="user"> | |
{{ .CurrentUser.Email }} | |
</div> | |
</div> | |
<div class="sidebar"></div> | |
<div class="main"> | |
<h1>Home</h1> | |
<div id="root"></div> | |
{{ range .Webpack.Manifest.Entrypoints.Scripts }} | |
<script src="{{ . }}"></script> | |
{{ end }} | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment