1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-11-22 18:00:06 +01:00

add edit on github action

This commit is contained in:
Matthias Kretschmann 2018-11-18 23:11:36 +01:00
parent ca1086010e
commit 9f3b9cc37d
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 91 additions and 49 deletions

View File

@ -20,6 +20,7 @@ module.exports = {
jsonfeed: '/feed.json', jsonfeed: '/feed.json',
typekitID: 'msu4qap', typekitID: 'msu4qap',
itemsPerPage: 20, itemsPerPage: 20,
repoContentPath: 'https://github.com/kremalicious/blog/tree/master/content',
menu: [ menu: [
{ {
title: 'Photos', title: 'Photos',

View File

@ -1,5 +1,6 @@
const path = require('path') const path = require('path')
const { createFilePath } = require('gatsby-source-filesystem') const { createFilePath } = require('gatsby-source-filesystem')
const { repoContentPath } = require('../config')
// Create slug & date for posts from file path values // Create slug & date for posts from file path values
exports.createMarkdownFields = (node, createNodeField, getNode) => { exports.createMarkdownFields = (node, createNodeField, getNode) => {
@ -36,4 +37,15 @@ exports.createMarkdownFields = (node, createNodeField, getNode) => {
name: 'date', name: 'date',
value: date value: date
}) })
// github file link
const type = fileNode.sourceInstanceName
const file = fileNode.relativePath
const githubLink = `${repoContentPath}/${type}/${file}`
createNodeField({
node,
name: 'githubLink',
value: githubLink
})
} }

View File

@ -5,6 +5,7 @@ import styles from './PostActions.module.scss'
import { ReactComponent as Twitter } from '../../images/twitter.svg' import { ReactComponent as Twitter } from '../../images/twitter.svg'
import { ReactComponent as Bitcoin } from '../../images/bitcoin.svg' import { ReactComponent as Bitcoin } from '../../images/bitcoin.svg'
import { ReactComponent as GitHub } from '../../images/github.svg'
export default class PostActions extends PureComponent { export default class PostActions extends PureComponent {
state = { state = {
@ -13,7 +14,8 @@ export default class PostActions extends PureComponent {
static propTypes = { static propTypes = {
slug: PropTypes.string.isRequired, slug: PropTypes.string.isRequired,
url: PropTypes.string.isRequired url: PropTypes.string.isRequired,
githubLink: PropTypes.string.isRequired
} }
toggleModal = () => { toggleModal = () => {
@ -21,10 +23,11 @@ export default class PostActions extends PureComponent {
} }
render() { render() {
const { url, slug } = this.props const { url, slug, githubLink } = this.props
return ( return (
<aside className={styles.actions}> <aside className={styles.actions}>
<div>
<a <a
className={styles.action} className={styles.action}
href={`https://twitter.com/intent/tweet?text=@kremalicious&url=${url}${slug}`} href={`https://twitter.com/intent/tweet?text=@kremalicious&url=${url}${slug}`}
@ -32,9 +35,13 @@ export default class PostActions extends PureComponent {
<Twitter /> <Twitter />
<h1 className={styles.actionTitle}>Have a comment?</h1> <h1 className={styles.actionTitle}>Have a comment?</h1>
<p className={styles.actionText}> <p className={styles.actionText}>
Hit me up <span className={styles.link}>@kremalicious</span>. Hit me up on Twitter{' '}
<span className={styles.link}>@kremalicious</span>.
</p> </p>
</a> </a>
</div>
<div>
<button className={styles.action} onClick={this.toggleModal}> <button className={styles.action} onClick={this.toggleModal}>
<Bitcoin /> <Bitcoin />
<h1 className={styles.actionTitle}>Found something useful?</h1> <h1 className={styles.actionTitle}>Found something useful?</h1>
@ -43,6 +50,18 @@ export default class PostActions extends PureComponent {
<span className={styles.link}>with Bitcoins or Ether</span>. <span className={styles.link}>with Bitcoins or Ether</span>.
</p> </p>
</button> </button>
</div>
<div>
<a className={styles.action} href={githubLink}>
<GitHub />
<h1 className={styles.actionTitle}>Edit on GitHub</h1>
<p className={styles.actionText}>
Contribute to this post on{' '}
<span className={styles.link}>GitHub</span>.
</p>
</a>
</div>
{this.state.showModal && ( {this.state.showModal && (
<ModalThanks <ModalThanks

View File

@ -1,14 +1,33 @@
@import 'variables'; @import 'variables';
@import 'mixins';
.actions { .actions {
margin-top: $spacer * 3; @include breakoutviewport;
padding: ($spacer * $line-height) 0 ($spacer * $line-height) 100%;
background: rgba(#fff, .5);
margin-left: -100%;
@media (min-width: $screen-xs) { margin-top: $spacer * 3;
border-top: 1px dashed $brand-grey-dimmed;
border-bottom: 1px dashed $brand-grey-dimmed;
display: flex; display: flex;
flex-wrap: wrap;
justify-content: space-between; justify-content: space-between;
> div {
flex: 0 0 100%;
border-bottom: 1px dashed $brand-grey-dimmed;
&:last-child {
border-bottom: 0;
}
@media (min-width: $screen-sm) {
flex: 0 0 33.33333%;
border-bottom: 0;
border-left: 1px dashed $brand-grey-dimmed;
&:first-child {
border-left: 0;
}
}
} }
} }
@ -18,16 +37,15 @@
} }
.actionTitle { .actionTitle {
font-size: $font-size-h4; font-size: $font-size-base;
line-height: $line-height;
color: $text-color; color: $text-color;
margin-top: 0; margin-top: 0;
margin-bottom: 0; margin-bottom: $spacer / 4;
transition: color .2s ease-out; transition: color .2s ease-out;
} }
.actionText { .actionText {
font-size: $font-size-base; font-size: $font-size-small;
color: $brand-grey-light; color: $brand-grey-light;
margin-bottom: 0; margin-bottom: 0;
transition: color .2s ease-out; transition: color .2s ease-out;
@ -36,22 +54,13 @@
.action { .action {
display: block; display: block;
margin: 0; margin: 0;
padding-left: 1.75rem; padding-top: $spacer * $line-height;
padding-right: $spacer / 2; padding-bottom: $spacer * $line-height;
padding-left: $spacer * 2;
padding-right: $spacer;
position: relative; position: relative;
text-align: left; text-align: left;
height: 100%;
&:first-child {
margin-bottom: $spacer * $line-height;
}
@media (min-width: $screen-xs) {
flex: 1 1 50%;
&:first-child {
margin-bottom: 0;
}
}
&:hover, &:hover,
&:focus { &:focus {
@ -73,8 +82,8 @@
svg { svg {
position: absolute; position: absolute;
left: 0; left: $spacer;
top: .4rem; top: $spacer * $line-height;
fill: $brand-grey-light; fill: $brand-grey-light;
} }
} }

View File

@ -28,7 +28,7 @@ const Post = ({ data, location }) => {
coinhive, coinhive,
tags tags
} = post.frontmatter } = post.frontmatter
const { slug } = post.fields const { slug, githubLink } = post.fields
return ( return (
<Fragment> <Fragment>
@ -51,7 +51,7 @@ const Post = ({ data, location }) => {
{type !== 'photo' && <PostContent post={post} />} {type !== 'photo' && <PostContent post={post} />}
{type === 'link' && <PostLinkActions slug={slug} linkurl={linkurl} />} {type === 'link' && <PostLinkActions slug={slug} linkurl={linkurl} />}
<PostActions slug={slug} url={meta.siteUrl} /> <PostActions slug={slug} url={meta.siteUrl} githubLink={githubLink} />
<PostMeta post={post} meta={meta} /> <PostMeta post={post} meta={meta} />
</article> </article>
@ -116,6 +116,7 @@ export const pageQuery = graphql`
fields { fields {
slug slug
date date
githubLink
} }
rawMarkdownBody rawMarkdownBody
} }