Skip to content

Commit

Permalink
style(app): run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
abedzantout committed Apr 6, 2020
1 parent 9ddb513 commit d6c59b7
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Dotenv = require('dotenv-webpack');
const { generateAllArticles } = require('./utils/helpers');

const next_config = {
webpack: config => {
webpack: (config) => {
config.plugins = config.plugins || [];

config.plugins = [
Expand Down
2 changes: 1 addition & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { trackPageView } from '../core/gtag';
import Footer from '../shared/components/footer/footer.component';
import Header from '../shared/components/header/header.component';

Router.events.on('routeChangeComplete', url => trackPageView(url));
Router.events.on('routeChangeComplete', (url) => trackPageView(url));

class MyApp extends App {
render() {
Expand Down
8 changes: 4 additions & 4 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Card from '../shared/components/card/card.component';
import Paginator from '../shared/components/paginator/paginator.component';
import TagFilters from '../shared/components/tag-filters/tag-filters.component';

const calculateRange = length => Array.from({ length }, (v, k) => k + 1);
const calculateRange = (length) => Array.from({ length }, (v, k) => k + 1);

type Props = {
entries: BlogPost[];
Expand All @@ -23,7 +23,7 @@ type Props = {
page?: number;
};

const cards = entries =>
const cards = (entries) =>
entries.map((entry, index) => <Card info={entry} key={index} />);

const IndexPage: NextPage<Props, any> = (props: Props) => {
Expand All @@ -43,7 +43,7 @@ const IndexPage: NextPage<Props, any> = (props: Props) => {
void router.push({ pathname: '/', query: { page: page, tag: tag } });
}, [page, tag]);

const handleTagChosen = tag => {
const handleTagChosen = (tag) => {
updatePage(1);
updateTag(tag);
};
Expand All @@ -64,7 +64,7 @@ const IndexPage: NextPage<Props, any> = (props: Props) => {
</div>
<div className="pagination">
<Paginator
handlePaginationChange={event => updatePage(event)}
handlePaginationChange={(event) => updatePage(event)}
range={range}
skip={page}
/>
Expand Down
4 changes: 2 additions & 2 deletions pages/post/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Props = {
suggestedArticles: BlogPost[];
};

const renderCards = suggestions =>
const renderCards = (suggestions) =>
suggestions.map((suggestion, index) => (
<Card key={index} info={suggestion} />
));
Expand Down Expand Up @@ -51,7 +51,7 @@ PostPage.getInitialProps = async ({ query }) => {
const { post } = query;
const article = await contentfulService.getPostBySlug(post);

const tags = article.tags ? article.tags.map(tag => tag.sys.id) : [];
const tags = article.tags ? article.tags.map((tag) => tag.sys.id) : [];

const suggestedArticles = await contentfulService.fetchSuggestions(
tags,
Expand Down
2 changes: 1 addition & 1 deletion shared/components/tag-filters/tag-filters.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const TagFilters: FunctionComponent<Props> = ({
updatePage,
selectedTagId
}) => {
const handleTagChosen = tag => {
const handleTagChosen = (tag) => {
updatePage(tag);
};

Expand Down
8 changes: 4 additions & 4 deletions utils/contentful.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,14 @@ const tagFields = [
}
];

module.exports = function(migration, context) {
module.exports = function (migration, context) {
const tag = migration.createContentType('tag', {
name: 'Tag',
description: 'tag',
displayField: 'name'
});

tagFields.forEach(field => {
tagFields.forEach((field) => {
tag.createField(field.id, {
name: field.name,
type: field.type,
Expand All @@ -126,7 +126,7 @@ module.exports = function(migration, context) {
displayField: 'name'
});

authorFields.forEach(field => {
authorFields.forEach((field) => {
author.createField(field.id, {
name: field.name,
type: field.type,
Expand All @@ -139,7 +139,7 @@ module.exports = function(migration, context) {
displayField: 'title'
});

blogFields.forEach(field => {
blogFields.forEach((field) => {
const options = {
name: field.name,
type: field.type,
Expand Down
4 changes: 2 additions & 2 deletions utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const getAllArticles = async () => {
};
exports.generateAllAuthors = async () => {
const authors = await getAllAuthors();
return authors.items.map(item => ({ ...item.fields }));
return authors.items.map((item) => ({ ...item.fields }));
};

exports.generateAllArticles = async () => {
const articles = await getAllArticles();
return articles.items.map(item => ({ ...item.fields }));
return articles.items.map((item) => ({ ...item.fields }));
};
12 changes: 6 additions & 6 deletions utils/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ const fs = require('fs');
const { exportPathMap } = require('../next.config');
const { generateAllArticles } = require('./helpers');
// Format to the right date
const formatDate = date => `${date.toISOString().split('.')[0]}+0:00`;
const formatDate = (date) => `${date.toISOString().split('.')[0]}+0:00`;
// Priority is determined by path depth. Feel free to modify this if needed:
const getPriority = url =>
const getPriority = (url) =>
url.includes('/our-insights')
? 0.9
: ((100 - (url.split('/').length - 2) * 10) / 100).toFixed(2);
Expand All @@ -24,7 +24,7 @@ const xmlHeader = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">`;

// Wrap all pages in <urlset> tags
const xmlUrlWrapper = nodes => `${xmlHeader}
const xmlUrlWrapper = (nodes) => `${xmlHeader}
${nodes}
</urlset>`;

Expand Down Expand Up @@ -54,14 +54,14 @@ exports.generateSitemap = async (domain, targetFolder) => {

const entries = await exportPathMap();

const pages = Object.entries({ ...entries }).map(item => item[0]);
const pages = Object.entries({ ...entries }).map((item) => item[0]);

const sitemap = `${xmlUrlWrapper(
pages.map(page => xmlUrlNode(domain, page, lastModified)).join(`
pages.map((page) => xmlUrlNode(domain, page, lastModified)).join(`
`)
)}`;

fs.writeFile(`${writeLocation}`, sitemap, err => {
fs.writeFile(`${writeLocation}`, sitemap, (err) => {
if (err) throw err;
console.log(
`sitemap.xml with ${pages.length} entries was written to ${targetFolder}${fileName}`
Expand Down

0 comments on commit d6c59b7

Please sign in to comment.