Permalink
Browse files

Include sitemap

  • Loading branch information...
bernardodiasc committed Mar 17, 2018
1 parent 3c56cad commit 0d7f2f457db38512d8392621d1e31935afcf4039
Showing with 104 additions and 7 deletions.
  1. +3 −0 .babelrc
  2. +7 −1 package.json
  3. +0 −1 public/google8493ccc1f985f325.html
  4. +2 −0 public/robots.txt
  5. +22 −0 public/sitemap.xml
  6. +43 −0 src/config/sitemap.js
  7. +12 −5 src/selectors/data.js
  8. +15 −0 yarn.lock
@@ -0,0 +1,3 @@
{
"presets": ["env", "react", "stage-0"]
}
@@ -14,10 +14,11 @@
"new:component": "node src/config/componentGenerator.js",
"new:content": "node src/config/contentGenerator.js",
"content": "./node_modules/.bin/filestojson src/config/filestojson.js",
"sitemap": "./node_modules/.bin/babel-node src/config/sitemap.js",
"precommit": "lint-staged",
"prestart": "npm run content",
"start": "react-scripts start",
"prebuild": "npm run content",
"prebuild": "npm run content && npm run sitemap",
"build": "react-scripts build && react-snap",
"postbuild": "yarn docs:build",
"test": "react-scripts test --env=jsdom --testPathIgnorePatterns=src/config/",
@@ -73,8 +74,12 @@
"@storybook/addon-options": "^3.3.11",
"@storybook/addons": "^3.3.11",
"@storybook/react": "^3.3.11",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.2.1",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"cross-env": "^5.1.3",
"ejs": "^2.5.7",
"enzyme": "^3.3.0",
@@ -87,6 +92,7 @@
"react-snap": "^1.11.3",
"react-test-renderer": "^16.2.0",
"serve": "^6.4.11",
"sitemap": "^1.13.0",
"storybook-router": "^0.3.2",
"stylelint": "^8.4.0",
"stylelint-config-standard": "^18.0.0"

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
<url> <loc>http://bernardodiasdacruz.com/</loc> <changefreq>weekly</changefreq> <priority>1.0</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/archive</loc> <changefreq>weekly</changefreq> <priority>0.5</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/search</loc> <changefreq>weekly</changefreq> <priority>0.5</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/about-me</loc> <changefreq>monthly</changefreq> <priority>0.5</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-03-16-how-to-fix-custom-domain-ovewriting-with-gh-pages-deploy-script</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-03-16-component-styles-isolation-dealing-with-css-inheritance</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-03-13-categories-and-typography</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-03-06-inject-google-analytics-tag-manager-in-a-meteor-app</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-03-05-fetching-from-instagram-using-facebook-graph-api</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-03-05-redesign-and-better-typography</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-02-27-opportunity-cost</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-02-27-comments-section</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-02-26-boilerplate-generators</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-02-26-blog-progress</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/2018-02-23-hello-world</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/category/frontend</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/category/integrations</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/category/strategy</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
<url> <loc>http://bernardodiasdacruz.com/category/this-blog</loc> <changefreq>weekly</changefreq> <priority>0.8</priority> </url>
</urlset>
@@ -0,0 +1,43 @@
import path from 'path'
import sm from 'sitemap'
import fs from 'fs'

import config from '.'
import data from '../data.json'
import {
getAllPostsForListing,
getAllCategoriesForListing,
} from '../selectors/data'

const OUTPUT_FILE = path.resolve(__dirname, '..', '..', 'public', 'sitemap.xml')

const postsUrls = getAllPostsForListing({data})
.map(post => ({
url: `${config.PUBLIC_URL}/${post.handle}`,
changefreq: 'weekly',
priority: 0.8,
}))

const categoriesUrls = getAllCategoriesForListing({data})
.map(category => ({
url: `${config.PUBLIC_URL}/category/${category.handle}`,
changefreq: 'weekly',
priority: 0.8,
}))

const sitemap = sm.createSitemap({
hostname: 'http://bernardodiasdacruz.com',
cacheTime: 600000, //600 sec (10 min) cache purge period
urls: [
{ url: '/', changefreq: 'weekly', priority: 1 },
{ url: '/archive', changefreq: 'weekly', priority: 0.5 },
{ url: '/search', changefreq: 'weekly', priority: 0.5 },
{ url: '/about-me', changefreq: 'monthly', priority: 0.5 },
...postsUrls,
...categoriesUrls,
]
})

fs.writeFileSync(OUTPUT_FILE, sitemap.toString())

console.log(`Sitemap written at ${OUTPUT_FILE}`)
@@ -1,6 +1,6 @@
import { pathOr, union } from 'ramda'

export const getAllPostData = (state) =>
export const getAllPostsData = (state) =>
pathOr({}, ['data', 'posts'], state)

export const getPostData = (state, post) =>
@@ -36,21 +36,21 @@ export const getAllPostDetails = (state, post) => ({
})

export const getAllPostsForListing = (state) => Object
.keys(getAllPostData(state))
.keys(getAllPostsData(state))
.map(post => ({...getAllPostDetails(state, post)}))

export const getAllPostsTags = (state) => {
let tags = []
Object
.keys(getAllPostData(state))
.keys(getAllPostsData(state))
.forEach(post => tags = union(tags, getPostTags(state, post)))
return tags
}

export const getAllPostsCategories = (state) => {
let categories = []
Object
.keys(getAllPostData(state))
.keys(getAllPostsData(state))
.forEach(post => categories = union(categories, [getPostCategory(state, post)]))
return categories
}
@@ -75,6 +75,9 @@ export const getAllArticleDetails = (state, article) => ({
files: getArticleData(state, article),
})

export const getAllCategoriesData = (state) =>
pathOr({}, ['data', 'categories'], state)

export const getCategoryData = (state, category) =>
pathOr({}, ['data', 'categories', category], state)

@@ -95,7 +98,11 @@ export const getAllCategoryDetails = (state, category) => ({
files: getCategoryData(state, category),
})

export const getAllCategoriesForListing = (state) => Object
.keys(getAllCategoriesData(state))
.map(category => ({...getAllCategoryDetails(state, category)}))

export const getAllPostsForListingByCategory = (state, category) => Object
.keys(getAllPostData(state))
.keys(getAllPostsData(state))
.filter(post => category === getPostCategory(state, post))
.map(post => ({...getAllPostDetails(state, post)}))

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 0d7f2f4

Please sign in to comment.