1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-03-05 15:55:25 +00:00

fixed end point - fixed posts in metadata

This commit is contained in:
2016-09-13 04:37:56 +00:00
parent e558fe5da2
commit e5d340df5d
10 changed files with 102 additions and 18 deletions

View File

@@ -44,10 +44,14 @@ export function fetchPreview() {
}
}
export function fetchPost(category, post) {
//adjust url according to parameters
//mainly used to load md files in the parent directory within /posts
export function fetchPost(post, category = null) {
let url;
return (dispatch) => {
dispatch(fetching());
return fetch(`/public/posts/${category}/${post}.md`)
url = category !== null || typeof category === 'undefined' ? `/public/posts/${category}/${post}.md` : `/public/posts/${post}.md`;
return fetch(url)
.then(response => response.text())
.then(response => {
dispatch(loadPost(response));

View File

@@ -22,6 +22,13 @@ function loadSensorInfoMonth(sensor_info){
}
}
function loadUniqueDates(dates){
return{
type: types.LOAD_UNIQUE_DATES,
dates
}
}
function fetchingList(){
return {
type: types.FETCHING_LIST
@@ -40,6 +47,12 @@ function fetchingInfoMonth(){
}
}
function fetchingUniqueDates(){
return {
type: types.FETCHING_UNIQUE_DATES
}
}
export function fetchSensorList(){
return (dispatch) => {
dispatch(fetchingList());
@@ -80,4 +93,18 @@ export function fetchSensorInfoMonth(location, year, month){
console.log(error);
});
}
}
export function fetchUniqueDates(location){
return (dispatch) => {
dispatch(fetchingUniqueDates());
return fetch(`/api/uniquedates/${location}`)
.then(response => response.json())
.then(json => {
dispatch(loadUniqueDates(json));
})
.catch(error => {
console.log(error);
});
}
}