1
0
Fork 0

link post tweaks

This commit is contained in:
Matthias Kretschmann 2018-07-21 23:30:16 +02:00
parent 0c1722de2b
commit 5edd7f66db
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 68 additions and 16 deletions

View File

@ -1,15 +1,18 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Link } from 'gatsby'
import Forward from '../svg/Forward'
import Infinity from '../svg/Infinity'
import styles from './PostLinkActions.module.scss'
const PostLinkActions = ({ linkurl, slug }) => (
<div className={styles.postLinkActions}>
<a className="more-link" href={linkurl}>
Go to source
</a>
<a className="more-link" href={slug} rel="tooltip" title="Permalink">
Permalink
Go to source <Forward />
</a>
<Link className="more-link" to={slug} rel="tooltip" title="Permalink">
<Infinity />
</Link>
</div>
)

View File

@ -5,4 +5,22 @@
justify-content: space-between;
margin-top: $spacer * 2;
margin-bottom: $spacer * 2;
a {
svg {
width: $font-size-small;
height: $font-size-small;
display: inline-block;
fill: $text-color-light;
vertical-align: baseline;
}
&:last-child {
svg {
width: $font-size-base;
height: $font-size-base;
fill: $brand-cyan;
}
}
}
}

View File

@ -1,19 +1,26 @@
import React from 'react'
import React, { Fragment } from 'react'
import PropTypes from 'prop-types'
import Forward from '../svg/Forward'
import styles from './PostTitle.module.scss'
const PostTitle = ({ type, linkurl, title }) =>
type === 'link' ? (
<h1
className={[styles.hentry__title, styles.hentry__title__link].join(' ')}
>
<a href={linkurl} title={`Go to source: ${linkurl}`}>
{title}
</a>
</h1>
const PostTitle = ({ type, linkurl, title }) => {
const linkHostname = linkurl ? new URL(linkurl).hostname : null
return type === 'link' ? (
<Fragment>
<h1
className={[styles.hentry__title, styles.hentry__title__link].join(' ')}
>
<a href={linkurl} title={`Go to source: ${linkurl}`}>
{title} <Forward />
</a>
</h1>
<div className={styles.linkurl}>{linkHostname}</div>
</Fragment>
) : (
<h1 className={styles.hentry__title}>{title}</h1>
)
}
PostTitle.propTypes = {
type: PropTypes.string,

View File

@ -14,4 +14,29 @@
.hentry__title__link {
font-size: $font-size-h3;
svg {
width: $font-size-base;
height: $font-size-base;
display: inline-block;
fill: $text-color-light;
vertical-align: baseline;
}
}
.linkurl {
@include ellipsis();
width: 100%;
text-align: center;
color: $brand-grey-light;
font-family: $font-family-base;
font-size: $font-size-mini;
padding: ($spacer/3) 0;
max-width: 70%;
margin: -($spacer) auto $spacer auto;
@media (min-width: $screen-sm) {
max-width: 50%;
}
}

View File

@ -66,8 +66,7 @@
// Text overflow
/////////////////////////////////////
@mixin ellipsis($width) {
width: $width;
@mixin ellipsis() {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;