Skip to content

Commit

Permalink
Update .prettierrc and .editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidrylko committed Apr 21, 2024
1 parent f4d2ba0 commit 4aa2802
Show file tree
Hide file tree
Showing 12 changed files with 71 additions and 108 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true

[{*.ts, *.tsx}]
quote_type = single
max_line_length = 120

[{*.mdx, *.md, *.json}]
max_line_length = off
trim_trailing_whitespace = false
11 changes: 10 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"arrowParens": "avoid",
"semi": true,
"singleQuote": true
"singleQuote": true,
"tabWidth": 2,
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"options": {
"printWidth": 120
}
}
]
}
7 changes: 2 additions & 5 deletions gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,10 @@ const config: GatsbyConfig = {
`,
serialize: ({ query: { site, posts } }: any) =>
posts.nodes
.sort(
(a: any, b: any) => Date.parse(b.date) - Date.parse(a.date),
)
.sort((a: any, b: any) => Date.parse(b.date) - Date.parse(a.date))
.map((node: any) => {
const url = `${site.siteMetadata.siteUrl}${node.fields.slug}`;
const description =
node.frontmatter.description || node.excerpt;
const description = node.frontmatter.description || node.excerpt;
const content = `<p>${description}</p><div style='margin-top: 50px; font-style: italic;'><strong><a href='${url}'>Keep reading</a>.</strong></div><br /> <br />`;
return {
title: node.frontmatter.title,
Expand Down
27 changes: 7 additions & 20 deletions gatsby-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ import { createFilePath } from 'gatsby-source-filesystem';

const blogPost = path.resolve(`./src/templates/blog-post.tsx`);

export const createPages: GatsbyNode['createPages'] = async ({
graphql,
actions,
reporter,
}: any) => {
export const createPages: GatsbyNode['createPages'] = async ({ graphql, actions, reporter }: any) => {
const { createPage } = actions;
const result = await graphql(`
query AllMdx {
Expand All @@ -28,10 +24,7 @@ export const createPages: GatsbyNode['createPages'] = async ({
`);

if (result.errors) {
reporter.panicOnBuild(
`There was an error loading your blog posts`,
result.errors,
);
reporter.panicOnBuild(`There was an error loading your blog posts`, result.errors);
return;
}

Expand All @@ -40,8 +33,7 @@ export const createPages: GatsbyNode['createPages'] = async ({
if (posts.length > 0) {
posts.forEach((post, index) => {
const previousPostId = index === 0 ? null : posts[index - 1].id;
const nextPostId =
index === posts.length - 1 ? null : posts[index + 1].id;
const nextPostId = index === posts.length - 1 ? null : posts[index + 1].id;

createPage({
path: post.fields.slug,
Expand All @@ -56,11 +48,7 @@ export const createPages: GatsbyNode['createPages'] = async ({
}
};

export const onCreateNode: GatsbyNode['onCreateNode'] = ({
node,
actions,
getNode,
}) => {
export const onCreateNode: GatsbyNode['onCreateNode'] = ({ node, actions, getNode }) => {
if (node.internal.type !== `Mdx`) {
return;
}
Expand All @@ -78,9 +66,8 @@ export const onCreateNode: GatsbyNode['onCreateNode'] = ({

// https://www.gatsbyjs.com/docs/reference/graphql-data-layer/schema-customization/
// https://www.gatsbyjs.com/docs/how-to/local-development/graphql-typegen/
export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] =
({ actions }) => {
actions.createTypes(`#graphql
export const createSchemaCustomization: GatsbyNode['createSchemaCustomization'] = ({ actions }) => {
actions.createTypes(`#graphql
type Site {
siteMetadata: SiteMetadata!
}
Expand All @@ -89,4 +76,4 @@ export const createSchemaCustomization: GatsbyNode['createSchemaCustomization']
title: String!
}
`);
};
};
4 changes: 1 addition & 3 deletions gatsby-ssr.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import type { GatsbySSR } from 'gatsby';
import { SITE_METADATA } from './src/constants/site-metadata';

export const onRenderBody: GatsbySSR['onRenderBody'] = ({
setHtmlAttributes,
}) => {
export const onRenderBody: GatsbySSR['onRenderBody'] = ({ setHtmlAttributes }) => {
setHtmlAttributes({ lang: SITE_METADATA.lang });
};
3 changes: 1 addition & 2 deletions src/components/seo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const Seo: React.FC<SeoProps> = ({ title, description, noIndex, children }) => {

const metaDescription = description || siteDescription;
const metaTitle = [title, siteTitle].filter(Boolean).join(' | ');
const twitterHandle =
siteSocial.find(({ name }) => name === 'twitter')?.url ?? '';
const twitterHandle = siteSocial.find(({ name }) => name === 'twitter')?.url ?? '';

return (
<>
Expand Down
3 changes: 1 addition & 2 deletions src/constants/site-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ export const SITE_METADATA = {
lang: 'pl',
url: 'https://dawidrylko.com/',
title: 'Dawid Ryłko',
description:
'Dawid Ryłko. Moja osobista strona internetowa i blog. 68 97 119 105 100 32 82 121 108 107 111',
description: 'Dawid Ryłko. Moja osobista strona internetowa i blog. 68 97 119 105 100 32 82 121 108 107 111',
author: {
name: 'Dawid Ryłko',
},
Expand Down
5 changes: 1 addition & 4 deletions src/pages/404.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ const NotFoundPage: React.FC<PageProps> = ({ location }) => {
};

export const Head: HeadFC = () => (
<Seo
title={title}
description="Nie ma nic ciekawego na tej stronie, tym bardziej jej opisu."
/>
<Seo title={title} description="Nie ma nic ciekawego na tej stronie, tym bardziej jej opisu." />
);

export default NotFoundPage;
30 changes: 5 additions & 25 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,51 +51,31 @@ const BlogIndex: React.FC<PageProps<DataProps>> = ({ data, location }) => {
{posts.map(post => {
const title = post.frontmatter.title || post.fields.slug;
const description = post.frontmatter.description || post.excerpt;
const img = getImage(
post.frontmatter.featuredImg?.childImageSharp?.gatsbyImageData ||
null,
);
const img = getImage(post.frontmatter.featuredImg?.childImageSharp?.gatsbyImageData || null);

return (
<li key={post.fields.slug}>
<article
className="post-list-item"
itemScope
itemType="http://schema.org/Article"
>
<article className="post-list-item" itemScope itemType="http://schema.org/Article">
<header>
<h2>
<Link to={post.fields.slug} itemProp="url">
<span itemProp="headline">{title}</span>
</Link>
</h2>
<small>
<span
itemProp="datePublished"
content={post.frontmatter.dateOriginal}
>
<span itemProp="datePublished" content={post.frontmatter.dateOriginal}>
{post.frontmatter.dateFormatted}
</span>
&nbsp;|&nbsp;
<span
itemProp="author"
itemScope
itemType="https://schema.org/Person"
>
<span itemProp="author" itemScope itemType="https://schema.org/Person">
<Link itemProp="url" to="/bio">
<span itemProp="name">{siteAuthor?.name}</span>
</Link>
</span>
</small>
</header>
<section>
{img && (
<GatsbyImage
itemProp="image"
image={img}
alt={post.frontmatter.featuredImgAlt || ''}
/>
)}
{img && <GatsbyImage itemProp="image" image={img} alt={post.frontmatter.featuredImgAlt || ''} />}
<p
dangerouslySetInnerHTML={{
__html: description || '',
Expand Down
8 changes: 2 additions & 6 deletions src/pages/metadata.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ const createNonBlogPagesArray = ({ nonBlogPages: { pagePaths } }: DataType) =>
pagePaths.map((path, index) => [(index + 1).toString(), path]);

const createBlogPostsArray = ({ blogPosts: { postPaths } }: DataType) =>
postPaths
.map(({ fields: { slug } }) => slug)
.map((path, index) => [(index + 1).toString(), path]);
postPaths.map(({ fields: { slug } }) => slug).map((path, index) => [(index + 1).toString(), path]);

const title = 'Metadata 🤖';

Expand Down Expand Up @@ -77,9 +75,7 @@ export const query = graphql`
}
buildTime(formatString: "YYYY-MM-DD HH:mm:ss")
}
nonBlogPages: allSitePage(
filter: { component: { regex: "/^(?!.*templates/blog-post).*$/" } }
) {
nonBlogPages: allSitePage(filter: { component: { regex: "/^(?!.*templates/blog-post).*$/" } }) {
pageCount: totalCount
pagePaths: distinct(field: { path: SELECT })
}
Expand Down
16 changes: 16 additions & 0 deletions src/pages/resume.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Layout from '../components/layout';
import ReturnLink from '../components/return-link';
import Seo from '../components/seo';
import Table from '../components/table';
import Bio from '../components/bio';

const experience = [
['Silesian Solutions', 'Founder', 'Oct 2015 - Present'],
Expand All @@ -23,11 +24,26 @@ const ResumePage: React.FC<PageProps> = ({ location }) => {
return (
<Layout location={location}>
<h1>{title}</h1>
<Bio />
<h2>Summary</h2>
<p>
Hello, I'm Dawid Ryłko, a seasoned developer with a wealth of experience spanning several years. My professional
journey has been fueled by a passion for optimization and a knack for unconventional solutions. Beyond coding, I
am an avid enthusiast of movies and games.
</p>
<p>
In the dynamic realm of technology, I am unwaveringly dedicated to self-improvement and staying abreast of the
latest innovations. My commitment to excellence is the cornerstone of my approach to software development.
</p>
<h2>Experience</h2>
<Table data={experience} />
<h2>Education</h2>
<Table data={education} />
<hr />
<a href="/resume.pdf" download>
Download Full Résumé
</a>
<hr />
<ReturnLink />
</Layout>
);
Expand Down
48 changes: 8 additions & 40 deletions src/templates/blog-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,53 +31,30 @@ type Data = {
next: PostNode;
};

const BlogPostTemplate: React.FC<PageProps<Data>> = ({
data,
location,
children,
}) => {
const BlogPostTemplate: React.FC<PageProps<Data>> = ({ data, location, children }) => {
const { siteTitle, siteAuthor } = useSiteMetadata();
const { previous, next, mdx: post } = data;

const img = getImage(
post.frontmatter.featuredImg?.childImageSharp?.gatsbyImageData || null,
);
const img = getImage(post.frontmatter.featuredImg?.childImageSharp?.gatsbyImageData || null);

return (
<Layout location={location}>
<article
className="blog-post"
itemScope
itemType="http://schema.org/Article"
>
<article className="blog-post" itemScope itemType="http://schema.org/Article">
<header>
<h1 itemProp="headline">{post.frontmatter.title}</h1>
<small>
<span
itemProp="datePublished"
content={post.frontmatter.dateOriginal}
>
<span itemProp="datePublished" content={post.frontmatter.dateOriginal}>
{post.frontmatter.dateFormatted}
</span>
&nbsp;|&nbsp;
<span
itemProp="author"
itemScope
itemType="https://schema.org/Person"
>
<span itemProp="author" itemScope itemType="https://schema.org/Person">
<Link itemProp="url" to="/bio">
<span itemProp="name">{siteAuthor?.name}</span>
</Link>
</span>
</small>
</header>
{img && (
<GatsbyImage
itemProp="image"
image={img}
alt={post.frontmatter.featuredImgAlt || ''}
/>
)}
{img && <GatsbyImage itemProp="image" image={img} alt={post.frontmatter.featuredImgAlt || ''} />}
<section itemProp="articleBody">{children}</section>
<hr />
<footer>
Expand Down Expand Up @@ -115,22 +92,13 @@ const BlogPostTemplate: React.FC<PageProps<Data>> = ({
};

export const Head = function ({ data: { mdx: post } }: any) {
return (
<Seo
title={post.frontmatter.title}
description={post.frontmatter.description || ''}
/>
);
return <Seo title={post.frontmatter.title} description={post.frontmatter.description || ''} />;
};

export default BlogPostTemplate;

export const blogPageQuery = graphql`
query BlogPostBySlug(
$id: String!
$previousPostId: String
$nextPostId: String
) {
query BlogPostBySlug($id: String!, $previousPostId: String, $nextPostId: String) {
mdx(id: { eq: $id }) {
id
frontmatter {
Expand Down

0 comments on commit 4aa2802

Please sign in to comment.