This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React from "react" | |
| import { StaticQuery, graphql } from "gatsby" | |
| const IndexPage = () => ( | |
| <StaticQuery | |
| query={graphql` | |
| query IndexPageQuery { | |
| api { | |
| transcripts { | |
| date | |
| title |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require("dotenv").config(); | |
| const { ApolloServer, gql } = require("apollo-server"); | |
| const axios = require("axios"); | |
| const redis = require("redis"); | |
| const { compose, map, orderBy } = require("lodash/fp"); | |
| const Promise = require("bluebird"); | |
| Promise.promisifyAll(redis); | |
| redisClient = redis.createClient({ port: process.env.REDIS_PORT }); | |
| const typeDefs = gql` | |
| type Transcript { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require("dotenv").config(); | |
| const redis = require("redis"); | |
| const Promise = require("bluebird"); | |
| const moment = require("moment"); | |
| const axios = require("axios"); | |
| const cheerio = require("cheerio"); | |
| Promise.promisifyAll(redis); | |
| redisClient = redis.createClient({ port: process.env.REDIS_PORT }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createGlobalStyle } from "styled-components" | |
| const GlobalStyle = createGlobalStyle` | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; | |
| } | |
| ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { map } from "lodash/fp"; | |
| import * as d3 from "d3"; | |
| const margin = { top: 50, right: 50, bottom: 100, left: 50 }; | |
| const container = { | |
| width: window.innerWidth, | |
| height: 480 | |
| }; | |
| const chart = { | |
| width: container.width - margin.left - margin.right, | |
| height: container.height - margin.top - margin.bottom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState, useEffect } from "react"; | |
| import axios from "axios"; | |
| import { draw } from "./chart"; | |
| const App = () => { | |
| const [rainfalls, setRainfalls] = useState(null); | |
| useEffect(() => { | |
| async function get() { | |
| const { | |
| data: { | |
| data: { station } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { ApolloServer, gql } = require("apollo-server"); | |
| const typeDefs = gql` | |
| type Rainfall { | |
| date: String | |
| value: String | |
| } | |
| type Station { | |
| id: String | |
| rainfalls: [Rainfall] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const redis = require("redis"); | |
| const Promise = require("bluebird"); | |
| Promise.promisifyAll(redis); | |
| redisClient = redis.createClient({ port: process.env.REDIS_PORT }); | |
| (async () => { | |
| const res = await axios.request({ | |
| url: "https://opendata.cwb.gov.tw/api/v1/rest/datastore/C-B0025-001", | |
| params: { | |
| Authorization: process.env.TOKEN |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { Component } from "react"; | |
| import Style from "./style"; | |
| class Carousel extends Component { | |
| componentDidMount() { | |
| const width = this.slickList.getBoundingClientRect().width; | |
| this.slickTrack.style.width = `${width * this.props.children.length}px`; | |
| this.slickTrack.querySelectorAll(".slick-slide").forEach(slide => { | |
| slide.style.width = `${width}px`; | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ | |
| { "name": "Afghanistan", "alpha2Code": "AF", "alpha3Code": "AFG" }, | |
| { "name": "Aland Islands", "alpha2Code": "AX", "alpha3Code": "ALA" }, | |
| { "name": "Albania", "alpha2Code": "AL", "alpha3Code": "ALB" }, | |
| { "name": "Algeria", "alpha2Code": "DZ", "alpha3Code": "DZA" }, | |
| { "name": "American Samoa", "alpha2Code": "AS", "alpha3Code": "ASM" }, | |
| { "name": "Andorra", "alpha2Code": "AD", "alpha3Code": "AND" }, | |
| { "name": "Angola", "alpha2Code": "AO", "alpha3Code": "AGO" }, | |
| { "name": "Anguilla", "alpha2Code": "AI", "alpha3Code": "AIA" }, | |
| { "name": "Antarctica", "alpha2Code": "AQ", "alpha3Code": "ATA" }, |