- {CHINESE_LOCATION_INFO_MESSAGE_FIRST}.
+ {CHINESE_LOCATION_INFO_MESSAGE_FIRST}
+ .
- {CHINESE_LOCATION_INFO_MESSAGE_SECOND}.
+ {CHINESE_LOCATION_INFO_MESSAGE_SECOND}
+ .
Yesterday you said tomorrow.
diff --git a/src/hooks/useSiteMetadata.js b/src/hooks/useSiteMetadata.js
index ddc03736ce2..5310eb5493e 100644
--- a/src/hooks/useSiteMetadata.js
+++ b/src/hooks/useSiteMetadata.js
@@ -1,4 +1,4 @@
-import { useStaticQuery, graphql } from 'gatsby';
+import { graphql, useStaticQuery } from 'gatsby';
const useSiteMetadata = () => {
const { site } = useStaticQuery(
@@ -6,13 +6,18 @@ const useSiteMetadata = () => {
query SiteMetaData {
site {
siteMetadata {
- title
+ siteTitle
siteUrl
description
+ logo
+ navLinks {
+ name
+ url
+ }
}
}
}
- `
+ `,
);
return site.siteMetadata;
};
diff --git a/src/pages/404.jsx b/src/pages/404.jsx
index f5547f470ff..7af80b06db6 100644
--- a/src/pages/404.jsx
+++ b/src/pages/404.jsx
@@ -1,20 +1,22 @@
import React from 'react';
import Layout from 'src/components/Layout';
+import useSiteMetadata from 'src/hooks/useSiteMetadata';
-const NotFoundPage = () => (
-
- 404
- This page doesn't exist.
-
- If you wanna more message, you could visit{' '}
-
- https://github.com/yihong0618/running_page
-
-
-
-);
+const NotFoundPage = () => {
+ const { siteUrl } = useSiteMetadata();
+ return (
+
+ 404
+ This page doesn't exist.
+
+ If you wanna more message, you could visit
+ {' '}
+
+ {siteUrl}
+
+
+
+ );
+};
export default NotFoundPage;
diff --git a/src/pages/index.jsx b/src/pages/index.jsx
index 509910323a8..4b8ca397a7e 100644
--- a/src/pages/index.jsx
+++ b/src/pages/index.jsx
@@ -1,31 +1,32 @@
-import React, { useState, useEffect } from 'react';
+import React, { useEffect, useState } from 'react';
import Layout from 'src/components/Layout';
-import SVGStat from 'src/components/SVGStat';
-import YearsStat from 'src/components/YearsStat';
import LocationStat from 'src/components/LocationStat';
-import RunTable from 'src/components/RunTable';
import RunMap from 'src/components/RunMap';
+import RunTable from 'src/components/RunTable';
+import SVGStat from 'src/components/SVGStat';
+import YearsStat from 'src/components/YearsStat';
import useActivities from 'src/hooks/useActivities';
+import useSiteMetadata from 'src/hooks/useSiteMetadata';
+import { IS_CHINESE } from 'src/utils/const';
import {
- titleForShow,
- scrollToMap,
- geoJsonForRuns,
+ filterAndSortRuns,
filterCityRuns,
- filterYearRuns,
filterTitleRuns,
- filterAndSortRuns,
- sortDateFunc,
+ filterYearRuns,
+ geoJsonForRuns,
getBoundsForGeoData,
+ scrollToMap,
+ sortDateFunc,
+ titleForShow
} from 'src/utils/utils';
-import { IS_CHINESE, USE_ANIMATION_FOR_GRID } from 'src/utils/const';
export default () => {
+ const { siteTitle } = useSiteMetadata();
const { activities, thisYear } = useActivities();
const [year, setYear] = useState(thisYear);
- const [mapButtonYear,setMapButtonYear] = useState(thisYear)
const [runIndex, setRunIndex] = useState(-1);
const [runs, setActivity] = useState(
- filterAndSortRuns(activities, year, filterYearRuns, sortDateFunc)
+ filterAndSortRuns(activities, year, filterYearRuns, sortDateFunc),
);
const [title, setTitle] = useState('');
const [geoData, setGeoData] = useState(geoJsonForRuns(runs));
@@ -38,6 +39,7 @@ export default () => {
height: 400,
...bounds,
});
+
const changeByItem = (item, name, func) => {
scrollToMap();
setActivity(filterAndSortRuns(activities, item, func, sortDateFunc));
@@ -48,7 +50,7 @@ export default () => {
const changeYear = (y) => {
// default year
setYear(y);
- setMapButtonYear(y)
+
if (viewport.zoom > 3) {
setViewport({
width: '100%',
@@ -56,6 +58,7 @@ export default () => {
...bounds,
});
}
+
changeByItem(y, 'Year', filterYearRuns);
clearInterval(intervalId);
};
@@ -92,6 +95,7 @@ export default () => {
if (i >= runsNum) {
clearInterval(id);
}
+
const tempRuns = runs.slice(0, i);
setGeoData(geoJsonForRuns(tempRuns));
i += sliceNume;
@@ -104,13 +108,16 @@ export default () => {
if (year !== 'Total') {
return;
}
+
let rectArr = document.querySelectorAll('rect');
+
if (rectArr.length !== 0) {
rectArr = Array.from(rectArr).slice(1);
}
rectArr.forEach((rect) => {
const rectColor = rect.getAttribute('fill');
+
// not run has no click event
if (rectColor !== '#444444') {
const runDate = rect.innerHTML;
@@ -126,15 +133,17 @@ export default () => {
rect.addEventListener(
'click',
() => locateActivity(runLocate),
- false
+ false,
);
}
}
});
let polylineArr = document.querySelectorAll('polyline');
+
if (polylineArr.length !== 0) {
- polylineArr = Array.from(polylineArr).slice();
+ polylineArr = Array.from(polylineArr).slice(1);
}
+
// add picked runs svg event
polylineArr.forEach((polyline) => {
// not run has no click event
@@ -143,28 +152,6 @@ export default () => {
const [runName] = runDate.match(/\d{4}-\d{1,2}-\d{1,2}/) || [
`${+thisYear + 1}`,
];
- if (USE_ANIMATION_FOR_GRID) {
- const length = polyline.getTotalLength();
- polyline.style.transition = polyline.style.WebkitTransition = 'none';
- polyline.style.strokeDasharray = length + ' ' + length;
- polyline.style.strokeDashoffset = length;
- polyline.getBoundingClientRect();
- polyline.style.animation = polyline.style.WebkitTransition =
- 'dash 5s linear alternate infinite';
- polyline.style.strokeDashoffset = '0';
- let keyFrames = document.createElement('style');
- // tricky for (length-1000)
- keyFrames.innerHTML = `\
- @keyframes dash {\
- from {\
- stroke-dasharray: 0 ${length};\
- }\
- to {\
- stroke-dasharray: ${length} ${length-1000};\
- }\
- }`;
- polyline.appendChild(keyFrames)
- }
const run = runs
.filter((r) => r.start_date_local.slice(0, 10) === runName)
.sort((a, b) => b.distance - a.distance)[0];
@@ -181,7 +168,9 @@ export default () => {
{viewport.zoom <= 3 && IS_CHINESE ? (
{
setViewport={setViewport}
changeYear={changeYear}
thisYear={thisYear}
- mapButtonYear={mapButtonYear}
/>
{year === 'Total' ? (
diff --git a/src/utils/const.js b/src/utils/const.js
index 53fbf2cda2a..30d4150b82c 100644
--- a/src/utils/const.js
+++ b/src/utils/const.js
@@ -1,6 +1,5 @@
// const
-const MAPBOX_TOKEN =
- 'pk.eyJ1IjoieWlob25nMDYxOCIsImEiOiJja2J3M28xbG4wYzl0MzJxZm0ya2Fua2p2In0.PNKfkeQwYuyGOTT_x9BJ4Q';
+const MAPBOX_TOKEN = 'pk.eyJ1IjoieWlob25nMDYxOCIsImEiOiJja2J3M28xbG4wYzl0MzJxZm0ya2Fua2p2In0.PNKfkeQwYuyGOTT_x9BJ4Q';
const MUNICIPALITY_CITIES_ARR = [
'北京市',
'上海市',
@@ -13,14 +12,12 @@ const MUNICIPALITY_CITIES_ARR = [
// IF you outside China please make sure IS_CHINESE = false
const IS_CHINESE = true;
const USE_ANIMATION_FOR_GRID = false;
-const CHINESE_INFO_MESSAGE = (yearLength, year) =>
- `我用 App 记录自己跑步 ${yearLength} 年了,下面列表展示的是 ${year} 的数据`;
-const ENGLISH_INFO_MESSAGE = (yearLength, year) =>
- `Running Journey with ${yearLength} Years, the table shows year ${year} data`;
+const CHINESE_INFO_MESSAGE = (yearLength, year) => `我用 App 记录自己跑步 ${yearLength} 年了,下面列表展示的是 ${year} 的数据`;
+const ENGLISH_INFO_MESSAGE = (yearLength, year) => `Running Journey with ${yearLength} Years, the table shows year ${year} data`;
// not support English for now
-const CHINESE_LOCATION_INFO_MESSAGE_FIRST = "我跑过了一些地方,希望随着时间推移,地图点亮的地方越来越多";
-const CHINESE_LOCATION_INFO_MESSAGE_SECOND = "不要停下来,不要停下奔跑的脚步";
+const CHINESE_LOCATION_INFO_MESSAGE_FIRST = '我跑过了一些地方,希望随着时间推移,地图点亮的地方越来越多';
+const CHINESE_LOCATION_INFO_MESSAGE_SECOND = '不要停下来,不要停下奔跑的脚步';
const INFO_MESSAGE = IS_CHINESE ? CHINESE_INFO_MESSAGE : ENGLISH_INFO_MESSAGE;
const FULL_MARATHON_RUN_TITLE = IS_CHINESE ? '全程马拉松' : 'Full Marathon';
@@ -52,13 +49,6 @@ export {
USE_ANIMATION_FOR_GRID,
};
-export const AVATAR =
- 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQTtc69JxHNcmN1ETpMUX4dozAgAN6iPjWalQ&usqp=CAU'; // Temp avatar
-export const NAVS = [
- { text: 'Blog', link: 'https://github.com/yihong0618/running_page' },
- { text: 'About', link: 'https://github.com/yihong0618/running_page' },
-];
-
const nike = 'rgb(224,237,94)'; // if you want change the main color change here src/styles/variables.scss
export const MAIN_COLOR = nike;
export const PROVINCE_FILL_COLOR = '#47b8e0';