Skip to content

Commit 1227991

Browse files
committed
Fixed link generator name and theme query string
1 parent 25a1bf4 commit 1227991

File tree

3 files changed

+41
-17
lines changed

3 files changed

+41
-17
lines changed

src/components/addons.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,22 @@ const CustomizeGithubStatsBase = ({ prefix, options, onUpdate }) =>
185185
</label>
186186
</>
187187

188+
const CustomizeStreakStats = ({ prefix, options, onUpdate }) => (
189+
<>
190+
<label htmlFor={`${prefix}-theme`}>
191+
Theme:&nbsp;
192+
<select
193+
id={`${prefix}-theme`}
194+
onChange={({ target: { value } }) => onUpdate("theme", value)}
195+
defaultValue={options.theme}
196+
>
197+
<option value="default">default</option>
198+
<option value="dark">dark</option>
199+
</select>
200+
</label>
201+
</>
202+
)
203+
188204
const Addons = props => {
189205
const [debounce, setDebounce] = useState(undefined);
190206
const [badgeOptions, setBadgeOptions] = useState({

src/components/markdown.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,6 @@ const Markdown = props => {
147147
}
148148
return ""
149149
}
150-
const DisplayStreakStats = ({ show, github, options }) => {
151-
if (show) {
152-
return (
153-
<>
154-
{`<p>&nbsp;<img align="center" src="${streakStatsLinkGenerator({
155-
github: github,
156-
options,
157-
})}" alt="${github}" /></p>`}
158-
<br />
159-
<br />
160-
</>
161-
)
162-
}
163-
return ""
164-
}
165150
const isSocial = social => {
166151
return (
167152
social.dev ||
@@ -254,6 +239,21 @@ const Markdown = props => {
254239
}
255240
return ""
256241
}
242+
const DisplayStreakStats = props => {
243+
if (props.show) {
244+
return (
245+
<>
246+
{`<p><img align="center" src="${streakStatsLinkGenerator({
247+
github: props.github,
248+
options: props.options,
249+
})}" alt="${props.github}" /></p>`}
250+
<br />
251+
<br />
252+
</>
253+
)
254+
}
255+
return ""
256+
}
257257
return (
258258
<div id="markdown-content" className="break-words">
259259
<>

src/utils/link-generators.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,19 @@ const githubStatsStylingQueryString = options => {
1313
return query_string
1414
}
1515

16+
const streakStatsStylingQueryString = options => {
17+
const params = {
18+
...(options.theme && options.theme !== "none") && { theme: options.theme },
19+
}
20+
const query_string = Object.entries(params).map(([key, value]) => `${key}=${value}`).join("&")
21+
return query_string
22+
}
23+
1624
export const githubStatsLinkGenerator = ({github, options}) =>
1725
`https://github-readme-stats.vercel.app/api?username=${github}&${githubStatsStylingQueryString(options)}`
1826

1927
export const topLanguagesLinkGenerator = ({github, options}) =>
2028
`https://github-readme-stats.vercel.app/api/top-langs?username=${github}&${githubStatsStylingQueryString(options)}&layout=compact`
2129

22-
export const githubStreakLinkGenerator = ({github, options}) =>
23-
`https://github-readme-streak-stats.herokuapp.com/?user=${github}`
30+
export const streakStatsLinkGenerator = ({github, options}) =>
31+
`https://github-readme-streak-stats.herokuapp.com/?user=${github}&${streakStatsStylingQueryString(options)}`

0 commit comments

Comments
 (0)