()
| 43 | } |
| 44 | |
| 45 | export function loadMarkdown() { |
| 46 | const queryParams = parse(location.search); |
| 47 | if (queryParams.id) { |
| 48 | const url = gistUrl + queryParams.id + '/raw'; |
| 49 | return (dispatch, getState) => { |
| 50 | return fetch(url, { |
| 51 | method: 'get' |
| 52 | }) |
| 53 | .then(checkStatus) |
| 54 | .then(response => response.text()) |
| 55 | .then(md => dispatch({ |
| 56 | type: LOAD_MARKDOWN, |
| 57 | markdown: md |
| 58 | })) |
| 59 | .then(() => dispatch(fetchData())) |
| 60 | .catch(() => { |
| 61 | dispatch(loadMarkdownFromHTML()); |
| 62 | dispatch(fetchData()); |
| 63 | }) |
| 64 | }; |
| 65 | } |
| 66 | return loadMarkdownFromHTML(); |
| 67 | } |
| 68 | |
| 69 | function loadMarkdownFromHTML() { |
| 70 | return { |
no test coverage detected