-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from burnpiro/post/diffusion-models
Post/diffusion models
- Loading branch information
Showing
22 changed files
with
252 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# erdem.pl blog | ||
|
||
[![CircleCI](https://circleci.com/gh/burnpiro/erdem.pl.svg?style=svg)](https://circleci.com/gh/burnpiro/erdem.pl) | ||
[![GHPages](https://github.com/burnpiro/erdem.pl/actions/workflows/main.yaml/badge.svg)](https://github.com/burnpiro/erdem.pl/actions) | ||
|
||
My personal blog. Built with [Gatsby](https://www.gatsbyjs.org) and [Lumen](https://github.com/alxshelepenok/gatsby-starter-lumen) to help with templating. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ module.exports = { | |
name: 'Kemal Erdem', | ||
photo: '/main.jpg', | ||
bio: | ||
'ML Developer, Software Architect, Freelance Consultant, JS Engineer, MTB lover', | ||
'ML Developer, Software Architect, JS Engineer, Ultra-distance cyclist', | ||
contacts: { | ||
email: '[email protected]', | ||
twitter: 'burnpiro', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const path = require('path'); | ||
const siteConfig = require('../../config.js'); | ||
|
||
module.exports = async (graphql, actions) => { | ||
const { createPage } = actions; | ||
|
||
const result = await graphql(` | ||
{ | ||
allMarkdownRemark( | ||
filter: { | ||
frontmatter: { draft: { eq: false }, popular: { ne: null }, template: { eq: "post" } } | ||
} | ||
) { | ||
totalCount | ||
} | ||
} | ||
`); | ||
|
||
const { postsPerPage } = siteConfig; | ||
const numPages = Math.ceil( | ||
result.data.allMarkdownRemark.totalCount / postsPerPage | ||
); | ||
|
||
for (let i = 0; i < numPages; i += 1) { | ||
createPage({ | ||
path: i === 0 ? '/popular' : `/popular/page/${i}`, | ||
component: path.resolve('./src/templates/popular-template.js'), | ||
context: { | ||
currentPage: i, | ||
postsLimit: postsPerPage, | ||
postsOffset: i * postsPerPage, | ||
prevPagePath: i <= 1 ? '/popular' : `/popular/page/${i - 1}`, | ||
nextPagePath: `/popular/page/${i + 1}`, | ||
hasPrevPage: i !== 0, | ||
hasNextPage: i !== numPages - 1, | ||
}, | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// @flow | ||
import React, { useState } from 'react'; | ||
import styles from './Tabs.module.scss'; | ||
import { types } from '@babel/core'; | ||
|
||
export const selectedTabType = { | ||
POPULAR: 'popular', | ||
MAIN: '', | ||
}; | ||
|
||
type Props = { | ||
selectedTab: typeof selectedTabType, | ||
}; | ||
|
||
const Tabs = ({ selectedTab: defaultSelectedTab }: Props) => { | ||
const handleItemClick = newSelectedTab => { | ||
if (newSelectedTab !== defaultSelectedTab) { | ||
window.location.href = `/${newSelectedTab}`; | ||
} | ||
}; | ||
|
||
return ( | ||
<div className={styles['tabset']}> | ||
<div | ||
onClick={() => handleItemClick(selectedTabType.POPULAR)} | ||
className={ | ||
defaultSelectedTab === selectedTabType.POPULAR | ||
? styles['tabset__tab'] + ' ' + styles['tabset__tab-checked'] | ||
: styles['tabset__tab'] | ||
} | ||
> | ||
Popular | ||
</div> | ||
<div | ||
onClick={() => handleItemClick(selectedTabType.MAIN)} | ||
className={ | ||
defaultSelectedTab === selectedTabType.MAIN | ||
? styles['tabset__tab'] + ' ' + styles['tabset__tab-checked'] | ||
: styles['tabset__tab'] | ||
} | ||
> | ||
Recent | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Tabs; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
@import '../../assets/scss/variables'; | ||
@import '../../assets/scss/mixins'; | ||
|
||
.tabset { | ||
display: flex; | ||
flex-direction: row; | ||
|
||
&__tab { | ||
flex: 1; | ||
position: relative; | ||
display: inline-block; | ||
padding: 15px 15px 25px; | ||
border: 1px solid transparent; | ||
border-bottom: 0; | ||
cursor: pointer; | ||
font-weight: 600; | ||
|
||
&::after { | ||
content: ''; | ||
position: absolute; | ||
left: 15px; | ||
bottom: 10px; | ||
width: 22px; | ||
height: 4px; | ||
background: #8d8d8d; | ||
} | ||
|
||
&:hover { | ||
color: $typographic-link-s-font-color; | ||
|
||
&::after { | ||
background: $typographic-link-s-font-color; | ||
} | ||
} | ||
|
||
&-checked { | ||
color: $typographic-link-s-font-color; | ||
border-color: #ccc; | ||
border-bottom: 1px solid #fff; | ||
margin-bottom: -1px; | ||
|
||
&::after { | ||
background: $typographic-link-s-font-color; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@include breakpoint-md { | ||
.tabset { | ||
&__tab { | ||
flex: inherit; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @flow | ||
export { default } from './Tabs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// @flow | ||
import React from 'react'; | ||
import { graphql } from 'gatsby'; | ||
import Layout from '../components/Layout'; | ||
import Sidebar from '../components/Sidebar'; | ||
import Feed from '../components/Feed'; | ||
import Page from '../components/Page'; | ||
import Tabs from '../components/Tabs'; | ||
import Pagination from '../components/Pagination'; | ||
import { useSiteMetadata } from '../hooks'; | ||
import type { PageContext, AllMarkdownRemark } from '../types'; | ||
import Search from '../components/Search'; | ||
import {selectedTabType} from "../components/Tabs/Tabs"; | ||
|
||
type Props = { | ||
data: AllMarkdownRemark, | ||
pageContext: PageContext, | ||
}; | ||
|
||
const PopularTemplate = ({ data, pageContext }: Props) => { | ||
const { title: siteTitle, subtitle: siteSubtitle } = useSiteMetadata(); | ||
|
||
const { | ||
currentPage, | ||
hasNextPage, | ||
hasPrevPage, | ||
prevPagePath, | ||
nextPagePath, | ||
} = pageContext; | ||
|
||
const { edges } = data.allMarkdownRemark; | ||
const pageTitle = | ||
currentPage > 0 ? `Posts - Page ${currentPage} - ${siteTitle}` : siteTitle; | ||
|
||
return ( | ||
<Layout title={pageTitle} description={siteSubtitle}> | ||
<Sidebar isIndex /> | ||
<Page> | ||
<Search /> | ||
<Tabs selectedTab={selectedTabType.POPULAR} /> | ||
<Feed edges={edges} /> | ||
<Pagination | ||
prevPagePath={prevPagePath} | ||
nextPagePath={nextPagePath} | ||
hasPrevPage={hasPrevPage} | ||
hasNextPage={hasNextPage} | ||
/> | ||
</Page> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export const query = graphql` | ||
query PopularTemplate($postsLimit: Int!, $postsOffset: Int!) { | ||
allMarkdownRemark( | ||
limit: $postsLimit | ||
skip: $postsOffset | ||
filter: { | ||
frontmatter: { draft: { eq: false }, popular: { ne: null }, template: { eq: "post" } } | ||
} | ||
sort: { fields: [frontmatter___popular, frontmatter___date], order: [DESC, DESC] } | ||
) { | ||
edges { | ||
node { | ||
fields { | ||
readTime { | ||
text | ||
minutes | ||
} | ||
slug | ||
} | ||
frontmatter { | ||
date | ||
title | ||
description | ||
} | ||
} | ||
} | ||
} | ||
} | ||
`; | ||
|
||
export default PopularTemplate; |