mirror of
https://github.com/kremalicious/blog.git
synced 2025-02-14 21:10:25 +01:00
Merge pull request #104 from kremalicious/feature/github-link
add edit on github action
This commit is contained in:
commit
1cb17c0a2f
@ -54,7 +54,7 @@ In the end looks like this, including location display with [pigeon-maps](https:
|
|||||||
If you want to know how this works, have a look at the respective component under
|
If you want to know how this works, have a look at the respective component under
|
||||||
|
|
||||||
- [`src/components/atoms/Exif.jsx`](src/components/atoms/Exif.jsx)
|
- [`src/components/atoms/Exif.jsx`](src/components/atoms/Exif.jsx)
|
||||||
- the EXIF node fields creation [`gatsby/exif.js`](gatsby/exif.js) running in [`gatsby-node.js`](gatsby-node.js)
|
- the EXIF node fields creation [`gatsby/createExifFields.js`](gatsby/createExifFields.js) running in [`gatsby-node.js`](gatsby-node.js)
|
||||||
|
|
||||||
### 💰 Cryptocurrency donation via Web3/MetaMask
|
### 💰 Cryptocurrency donation via Web3/MetaMask
|
||||||
|
|
||||||
|
@ -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',
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const { createMarkdownFields } = require('./gatsby/onCreateNode')
|
const { createMarkdownFields } = require('./gatsby/createMarkdownFields')
|
||||||
const { createExifFields } = require('./gatsby/exif')
|
const { createExifFields } = require('./gatsby/createExifFields')
|
||||||
const {
|
const {
|
||||||
generatePostPages,
|
generatePostPages,
|
||||||
generateTagPages,
|
generateTagPages,
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
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 & github file link for posts from file path values
|
||||||
exports.createMarkdownFields = (node, createNodeField, getNode) => {
|
exports.createMarkdownFields = (node, createNodeField, getNode) => {
|
||||||
const fileNode = getNode(node.parent)
|
const fileNode = getNode(node.parent)
|
||||||
const parsedFilePath = path.parse(fileNode.relativePath)
|
const parsedFilePath = path.parse(fileNode.relativePath)
|
||||||
@ -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
|
||||||
|
})
|
||||||
}
|
}
|
@ -5,6 +5,65 @@ 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'
|
||||||
|
|
||||||
|
const ActionContent = ({ title, text, textLink }) => (
|
||||||
|
<>
|
||||||
|
<h1 className={styles.actionTitle}>{title}</h1>
|
||||||
|
<p className={styles.actionText}>
|
||||||
|
{text} <span className={styles.link}>{textLink}</span>
|
||||||
|
</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const ActionTwitter = ({ url, slug }) => (
|
||||||
|
<a
|
||||||
|
className={styles.action}
|
||||||
|
href={`https://twitter.com/intent/tweet?text=@kremalicious&url=${url}${slug}`}
|
||||||
|
>
|
||||||
|
<Twitter />
|
||||||
|
<ActionContent
|
||||||
|
title="Have a comment?"
|
||||||
|
text="Hit me up on Twitter"
|
||||||
|
textLink="@kremalicious"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
|
||||||
|
ActionTwitter.propTypes = {
|
||||||
|
url: PropTypes.string.isRequired,
|
||||||
|
slug: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
const ActionCrypto = ({ toggleModal }) => (
|
||||||
|
<button className={styles.action} onClick={toggleModal}>
|
||||||
|
<Bitcoin />
|
||||||
|
<ActionContent
|
||||||
|
title="Found something useful?"
|
||||||
|
text="Say thanks with"
|
||||||
|
textLink="Bitcoins or Ether"
|
||||||
|
/>
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
|
||||||
|
ActionCrypto.propTypes = {
|
||||||
|
toggleModal: PropTypes.func.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
|
const ActionGitHub = ({ githubLink }) => (
|
||||||
|
<a className={styles.action} href={githubLink}>
|
||||||
|
<GitHub />
|
||||||
|
<ActionContent
|
||||||
|
title="Edit on GitHub"
|
||||||
|
text="Contribute to this post on"
|
||||||
|
textLink="GitHub"
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
|
||||||
|
ActionGitHub.propTypes = {
|
||||||
|
githubLink: PropTypes.string.isRequired
|
||||||
|
}
|
||||||
|
|
||||||
export default class PostActions extends PureComponent {
|
export default class PostActions extends PureComponent {
|
||||||
state = {
|
state = {
|
||||||
@ -13,7 +72,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,28 +81,21 @@ 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}>
|
||||||
<a
|
<div>
|
||||||
className={styles.action}
|
<ActionTwitter url={url} slug={slug} />
|
||||||
href={`https://twitter.com/intent/tweet?text=@kremalicious&url=${url}${slug}`}
|
</div>
|
||||||
>
|
|
||||||
<Twitter />
|
<div>
|
||||||
<h1 className={styles.actionTitle}>Have a comment?</h1>
|
<ActionCrypto toggleModal={this.toggleModal} />
|
||||||
<p className={styles.actionText}>
|
</div>
|
||||||
Hit me up <span className={styles.link}>@kremalicious</span>.
|
|
||||||
</p>
|
<div>
|
||||||
</a>
|
<ActionGitHub githubLink={githubLink} />
|
||||||
<button className={styles.action} onClick={this.toggleModal}>
|
</div>
|
||||||
<Bitcoin />
|
|
||||||
<h1 className={styles.actionTitle}>Found something useful?</h1>
|
|
||||||
<p className={styles.actionText}>
|
|
||||||
Say thanks{' '}
|
|
||||||
<span className={styles.link}>with Bitcoins or Ether</span>.
|
|
||||||
</p>
|
|
||||||
</button>
|
|
||||||
|
|
||||||
{this.state.showModal && (
|
{this.state.showModal && (
|
||||||
<ModalThanks
|
<ModalThanks
|
||||||
|
@ -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;
|
||||||
display: flex;
|
border-top: 1px dashed $brand-grey-dimmed;
|
||||||
justify-content: space-between;
|
border-bottom: 1px dashed $brand-grey-dimmed;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user