Skip to content

Commit d8f3f10

Browse files
authored
Merge pull request #83 from xsnippet/raw-snippet-url
Set proper links (hrefs) for "raw" snippet button
2 parents 911df9c + 706a89e commit d8f3f10

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/components/RecentSnippetItem.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const RecentSnippetItem = ({ snippet }) => {
1010
const syntax = mode.caption;
1111
const snippetTitle = snippet.get('title') || `#${snippet.get('id')}, Untitled`;
1212
const download = () => downloadSnippet(snippet);
13+
const rawUrl = process.env.RAW_SNIPPETS_URL_FORMAT.replace('%s', snippet.get('id'));
1314

1415
return (
1516
<li className="recent-snippet-item">
@@ -25,7 +26,7 @@ const RecentSnippetItem = ({ snippet }) => {
2526
<div className="recent-snippet-actions">
2627
<span className="recent-snippet-lang">{syntax}</span>
2728
<div>
28-
<button className="recent-snippet-button light">Raw</button>
29+
<a href={rawUrl} className="recent-snippet-button light">Raw</a>
2930
<button className="recent-snippet-button light" onClick={download}>Download</button>
3031
<Link to={`${snippet.get('id')}`} className="recent-snippet-button">Show</Link>
3132
</div>

src/components/Snippet.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class Snippet extends React.Component {
5151
const snippetTitle = snippet.get('title') || `#${snippet.get('id')}, Untitled`;
5252
const mode = modesByName[snippet.get('syntax')] || modesByName.text;
5353
const syntax = mode.caption;
54+
const rawUrl = process.env.RAW_SNIPPETS_URL_FORMAT.replace('%s', snippet.get('id'));
5455

5556
return (
5657
[
@@ -67,7 +68,7 @@ class Snippet extends React.Component {
6768
<div className="snippet-data-actions">
6869
<span className="snippet-data-lang">{syntax}</span>
6970
<div>
70-
<button className="snippet-button">Raw</button>
71+
<a href={rawUrl} className="snippet-button">Raw</a>
7172
<button className="snippet-button" onClick={this.download}>Download</button>
7273
<button
7374
className={`snippet-button ${this.state.isShowEmbed}`}

src/styles/Snippet.styl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ button-group-width = 312px
6868
background-color: button-active
6969
text-transform: uppercase
7070
cursor: pointer
71+
text-decoration: none
7172
&:last-child
7273
margin-right: 0
7374
&.true

webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ module.exports = () => {
205205
// testing to make debugging easier. We do not know which default they
206206
// use, so let's set 'production' explicitly and let user to override
207207
// this value.
208-
new webpack.EnvironmentPlugin({ NODE_ENV: 'production' }),
208+
new webpack.EnvironmentPlugin({
209+
NODE_ENV: 'production',
210+
RAW_SNIPPETS_URL_FORMAT: '//xsnippet.org/%s/raw',
211+
}),
209212

210213
// Generate index.html based on passed template, populating it with
211214
// produced JavaScript bundles.

0 commit comments

Comments
 (0)