Commit ef7711f7 authored by Seth A Johnson's avatar Seth A Johnson
Browse files

Initial commit

parents
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# dotenv environment variables file
.env
# gatsby files
.cache/
public
# Mac files
.DS_Store
# Yarn
yarn-error.log
.pnp/
.pnp.js
# Yarn Integrity file
.yarn-integrity
# Local Netlify folder
.netlify
\ No newline at end of file
.cache
package.json
package-lock.json
public
{
"endOfLine": "lf",
"semi": false,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5"
}
The MIT License (MIT)
Copyright (c) 2015 gatsbyjs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
## About Lever Press
1. clone the repo
2. run `yarn`
3. develop with `gatsby develop`
/**
* Implement Gatsby's Browser APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/browser-apis/
*/
// You can delete this file if you're not using it
module.exports = {
siteMetadata: {
title: `Lever Press`,
description: `Lever Press is a scholarly press supported by more than 50 liberal arts institutions. It publishes peer-reviewed, born digital, open access monographs at no cost to authors or their academic institutions.`,
author: `Lever Press`,
},
plugins: [
{
// keep as first gatsby-source-filesystem plugin for gatsby image support
// for netlify
resolve: 'gatsby-source-filesystem',
options: {
path: `${__dirname}/static/assets`,
name: 'assets',
},
},
{
resolve: `gatsby-plugin-google-analytics`,
options: {
trackingId: "UA-79270005-1",
}
},
{
resolve: `gatsby-plugin-sass`,
options: {
precision: 6
}
},
{
resolve: `gatsby-plugin-env-variables`,
options: {
whitelist: ["BRANCH"]
},
},
{
resolve: `gatsby-plugin-netlify-cms`,
options: {
manualInit: true, // https://github.com/netlify/netlify-cms/issues/1737#issuecomment-530992998 HELIO-3241
enableIdentityWidget: false,
modulePath: `${__dirname}/src/cms/cms.js`,
}
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `content`,
path: `${__dirname}/src/content`,
},
},
`gatsby-plugin-react-helmet`,
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `gatsby-starter-default`,
short_name: `starter`,
start_url: `/`,
background_color: `#663399`,
theme_color: `#663399`,
display: `minimal-ui`,
icon: `src/images/lever-logo.png`, // This path is relative to the root of the site.
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
{
resolve: 'gatsby-transformer-remark',
options: {
plugins: [
{
resolve: 'gatsby-remark-relative-images',
// options: {
// name: 'assets',
// },
},
{
resolve: 'gatsby-remark-images',
options: {
// It's important to specify the maxWidth (in pixels) of
// the content container as this plugin uses this as the
// base for generating different widths of each image.
maxWidth: 2048,
},
},
{
resolve: 'gatsby-remark-copy-linked-files',
options: {
destinationDir: 'static',
},
},
]
},
},
],
}
const path = require("path");
const { createFilePath } = require("gatsby-source-filesystem");
exports.createPages = async ({ actions, graphql, reporter }) => {
const { createPage } = actions;
const results = await graphql(`
query {
allMarkdownRemark(limit: 1000) {
edges {
node {
id
fields {
slug
}
frontmatter {
templateKey
}
}
}
}
}
`)
if (results.errors) {
reporter.panicOnBuild(`Error while running GraphQL query. ${results.errors}`)
return
}
// Filter out books, we don't make pages for those
// Also the home-page, or index.js. It just has pieces of content,
// not a generated page.
pages = results.data.allMarkdownRemark.edges.filter(edge => {
if (edge.node.frontmatter.templateKey === "book" ||
edge.node.frontmatter.templateKey === "home-page") {
return false
} else {
return edge
}
})
pages.forEach(edge => {
const pathName = edge.node.frontmatter.path || edge.node.fields.slug;
const component = path.resolve(`src/templates/${String(edge.node.frontmatter.templateKey)}.js`);
const id = edge.node.id
createPage({
path: pathName,
component,
context: {
id: id,
},
})
})
}
const { fmImagesToRelative } = require('gatsby-remark-relative-images');
exports.onCreateNode = ({ node, actions, getNode }) => {
fmImagesToRelative(node);
const { createNodeField } = actions;
if (node.internal.type === `MarkdownRemark`) {
// HELIO-3193
// frontmatter cover paths need to be corrected
if (node.frontmatter.cover) {
console.log("OLDPATH", node.frontmatter.cover)
console.log("FIXPATH", node.frontmatter.cover.replace(/^.*assets/, "/assets"))
createNodeField({
node,
name: `cover`,
//value: path.join("/", node.frontmatter.cover)
//value: node.frontmatter.cover
value: node.frontmatter.cover.replace(/^.*assets/, "/assets")
})
}
// end HELIO-3193
const value = createFilePath({ node, getNode });
createNodeField({
name: `slug`,
node,
value,
});
}
}
/**
* Implement Gatsby's SSR (Server Side Rendering) APIs in this file.
*
* See: https://www.gatsbyjs.org/docs/ssr-apis/
*/
// You can delete this file if you're not using it
{
"name": "gatsby-starter-default",
"private": true,
"description": "A simple starter to get up and developing quickly with Gatsby",
"version": "0.1.0",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"dependencies": {
"gatsby": "^2.16.1",
"gatsby-cli": "^2.8.28",
"gatsby-image": "^2.2.29",
"gatsby-plugin-env-variables": "^1.0.1",
"gatsby-plugin-google-analytics": "^2.1.34",
"gatsby-plugin-manifest": "^2.2.23",
"gatsby-plugin-netlify-cms": "^4.1.25",
"gatsby-plugin-offline": "^3.0.16",
"gatsby-plugin-react-helmet": "^3.1.13",
"gatsby-plugin-sass": "^2.1.20",
"gatsby-plugin-sharp": "^2.2.32",
"gatsby-remark-copy-linked-files": "^2.1.28",
"gatsby-remark-images": "^3.1.28",
"gatsby-remark-relative-images": "^0.2.3",
"gatsby-source-filesystem": "^2.1.33",
"gatsby-transformer-remark": "^2.6.30",
"gatsby-transformer-sharp": "^2.2.23",
"netlify-cms-app": "2.11.27",
"node-sass": "^4.13.0",
"prop-types": "^15.7.2",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react-helmet": "^5.2.1",
"react-markdown": "^4.2.2"
},
"devDependencies": {
"prettier": "^1.18.2"
},
"keywords": [
"gatsby"
],
"license": "MIT",
"scripts": {
"build": "gatsby build",
"develop": "gatsby develop",
"format": "prettier --write \"**/*.{js,jsx,json,md}\"",
"start": "npm run develop",
"serve": "gatsby serve",
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing \""
},
"repository": {
"type": "git",
"url": "https://github.com/gatsbyjs/gatsby-starter-default"
},
"bugs": {
"url": "https://github.com/gatsbyjs/gatsby/issues"
}
}
import CMS from 'netlify-cms-app';
import LinkFileComponent from "./components/linkFileComponent"
CMS.registerEditorComponent(LinkFileComponent);
// https://github.com/netlify/netlify-cms/issues/1737 and HELIO-3241
window.CMS_MANUAL_INIT = true;
if (process.env.BRANCH === "preview") {
console.log("---- USING PREVIEW BACKEND ----")
CMS.init({
config: {
backend: {
name: 'gitlab',
repo: 'michigan-publishing/about-leverpress',
branch: 'preview',
auth_type: 'implicit',
app_id: '1ad010fc364de8a6303468218779296589f4f424dd3284e42bf954cad431395b',
api_root: 'https://gitlab.umich.edu/api/v4',
base_url: 'https://gitlab.umich.edu',
auth_endpoint: 'oauth/authorize'
}
}
});
} else {
CMS.init({
config: {
backend: {
name: 'gitlab',
repo: 'michigan-publishing/about-leverpress',
branch: 'master',
auth_type: 'implicit',
app_id: '03d3fe1c9a36d44c83ea5d1f0382ac41333bd88052587631ae9fa15ce6b15123',
api_root: 'https://gitlab.umich.edu/api/v4',
base_url: 'https://gitlab.umich.edu',
auth_endpoint: 'oauth/authorize'
}
}
});
}
const LinkFileComponent = {
// Widget that allows linking to a file in the Media Gallery,
// such as a PDF, from the markdown body
id: "LinkFile",
label: "Link File",
fields: [
{name: 'text', label: 'Link Text', widget: 'string'},
{name: 'file', label: 'File', widget: 'file' }
],
pattern: /^<a href="(.*)">(.*)<\/a>$/,
fromBlock: function(match) {
return {
file: match[1],
text: match[2]
};
},
toBlock: function({file, text}) {
return `<a href="${file}">${text}</a>`
},
toPreview: function({file, text}) {
return `<a href="${file}">${text}</a>`
}
}
export default LinkFileComponent
import React from "react"
// import Img from "gatsby-image"
const Book = ({cover, book}) => {
const {
title,
author,
readLink,
buyLink,
description,
} = book
return (
<div className="card mb-3 book-card">
<div className="row no-gutters">
<div className="col-md-4">
<img src={cover} alt={`cover of ${title}`} className="card-img" />
</div>
<div className="col-md-8">
<div className="card-body">
<h3 className="card-title">{title}</h3>
<p className="card-subtitle text-muted h6">{author}</p>
<p className="card-text">{description}</p>
<a className="card-link btn btn-secondary btn-lg" role="button" href={readLink}>Read free online</a>
<a className="card-link btn btn-outline-primary btn-lg" role="button" href={buyLink}>Buy</a>
</div>
</div>
</div>
</div>
)
}
export default Book
import React from "react"
import BookCard from "./bookCard"
const BookList = ({books}) => {
return (
<div>
<h2 className="sr-only">Recent Books</h2>
<div className="row book-card-list">
{
books.map(({node}) => {
if (node.frontmatter.orderOnPage === 1 || node.frontmatter.orderOnPage === 2) {
return (
<BookCard key={node.id} cover={node.fields.cover} book={node.frontmatter} />
)
} else {
return null
}
})
}
</div>
</div>
)
}
export default BookList
//
// Base styles
//
.alert {
position: relative;
padding: $alert-padding-y $alert-padding-x;
margin-bottom: $alert-margin-bottom;
border: $alert-border-width solid transparent;
@include border-radius($alert-border-radius);
}
// Headings for larger alerts
.alert-heading {
// Specified to prevent conflicts of changing $headings-color
color: inherit;
}
// Provide class for links that match alerts
.alert-link {
font-weight: $alert-link-font-weight;
}
// Dismissible alerts
//
// Expand the right padding and account for the close button's positioning.
.alert-dismissible {
padding-right: ($close-font-size + $alert-padding-x * 2);
// Adjust close link position
.close {
position: absolute;
top: 0;
right: 0;
padding: $alert-padding-y $alert-padding-x;
color: inherit;
}
}
// Alternate styles
//
// Generate contextual modifier classes for colorizing the alert.
@each $color, $value in $theme-colors {
.alert-#{$color} {
@include alert-variant(theme-color-level($color, $alert-bg-level), theme-color-level($color, $alert-border-level), theme-color-level($color, $alert-color-level));
}
}
// Base class
//
// Requires one of the contextual, color modifier classes for `color` and
// `background-color`.
.badge {
display: inline-block;
padding: $badge-padding-y $badge-padding-x;
font-size: $badge-font-size;
font-weight: $badge-font-weight;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
@include border-radius($badge-border-radius);
// Empty badges collapse automatically
&:empty {
display: none;
}
}
// Quick fix for badges in buttons
.btn .badge {
position: relative;
top: -1px;
}
// Pill badges
//
// Make them extra rounded with a modifier to replace v3's badges.
.badge-pill {
padding-right: $badge-pill-padding-x;
padding-left: $badge-pill-padding-x;
@include border-radius($badge-pill-border-radius);
}
// Colors
//
// Contextual variations (linked badges get darker on :hover).
@each $color, $value in $theme-colors {
.badge-#{$color} {
@include badge-variant($value);
}
}