Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
fix: disable non-deterministic slug_short
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Dec 10, 2019
1 parent e1537a7 commit 7ff0ed7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
38 changes: 19 additions & 19 deletions gatsby/createPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ module.exports = store => ({ actions, getNodes, graphql }) => {
})

// set up short url redirects
const slugShort = isHomePage(node) ? `/` : `/${index}`
createNodeField({
node,
name: `slug_short`,
value: notIsErrorPage(node) ? slugShort : null,
})
// const slugShort = isHomePage(node) ? `/` : `/${index}`
// createNodeField({
// node,
// name: `slug_short`,
// value: notIsErrorPage(node) ? slugShort : null,
// })
if (notIsErrorPage(node)) {
redirects.push(
[
slugShort,
url + isHomePage(node)
? ``
: `?ref=${encodeURIComponent(slugShort)}`,
`301!`,
node.frontmatter.lang === `de` && `Language=de`,
]
.filter(Boolean)
.join(` `)
.trim()
)
// redirects.push(
// [
// slugShort,
// url + (isHomePage(node)
// ? ``
// : `?ref=${encodeURIComponent(slugShort)}`),
// `301!`,
// node.frontmatter.lang === `de` && `Language=de`,
// ]
// .filter(Boolean)
// .join(` `)
// .trim()
// )

// &fb_locale=en_US redirections as in https://stackoverflow.com/a/20827962/3484824
node.fields.translations
Expand Down
2 changes: 1 addition & 1 deletion gatsby/sourceNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = store =>
older: Mdx
all: Mdx
translations: [Translations]
slug_short: String
# slug_short: String
}
type Mdx implements Node {
fields: MdxFields
Expand Down
16 changes: 9 additions & 7 deletions src/components/ShareWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ class ShareWidget extends Component {

getLink = () =>
this.props.siteUrl +
(this.state.showFullUrl
? this.props.post.fields.url
: this.props.post.fields.slug_short)
// (this.state.showFullUrl
// ?
this.props.post.fields.url
// : this.props.post.fields.slug_short)

onLinkModalButtonClick = ({ metaKey }) =>
metaKey ? this.copyToClipboard() : this.toggleLinkModal()
Expand Down Expand Up @@ -157,9 +158,10 @@ class ShareWidget extends Component {
siteUrl,
...props
} = this.props
const { title, tweet_id, lang } = post.frontmatter
const { title, tweet_id: tweetId, lang } = post.frontmatter
const link = siteUrl + post.fields.url
const shortLink = siteUrl + post.fields.slug_short
// const shortLink = siteUrl + post.fields.slug_short
const shortLink = link

return (
<Container id="sharewidget" {...props}>
Expand Down Expand Up @@ -195,9 +197,9 @@ class ShareWidget extends Component {
>
<StyledA
href={
tweet_id
tweetId
? `https://twitter.com/intent/retweet?tweet_id=${encodeURIComponent(
tweet_id
tweetId
)}`
: `http://twitter.com/share?text=${encodeURIComponent(
title
Expand Down
5 changes: 3 additions & 2 deletions src/templates/BlogPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const BlogPost = props => {
podcast={post.frontmatter.podcast}
podcastPlayerMeta={PodcastPlayerMeta}
shortUrl={
props.data.site.siteMetadata.siteUrl + post.fields.slug_short
// props.data.site.siteMetadata.siteUrl + post.fields.slug_short
props.data.site.siteMetadata.siteUrl + post.fields.url
}
/>

Expand Down Expand Up @@ -275,7 +276,7 @@ export const query = graphql`
dateTime
dateStr
dateStrLocalized
slug_short
# slug_short
url
translations {
fields {
Expand Down

0 comments on commit 7ff0ed7

Please sign in to comment.