mirror of
https://github.com/dzeiocom/markblog.git
synced 2025-06-19 14:09:18 +00:00
Fixed lint errors :D
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
import React from 'react'
|
||||
import { ChevronRight } from 'react-feather'
|
||||
import next from 'next'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
@ -12,7 +11,7 @@ interface Props {
|
||||
}
|
||||
|
||||
const months = [
|
||||
"le 13eme mois",
|
||||
'le 13eme mois',
|
||||
'Janvier',
|
||||
'Février',
|
||||
'Mars',
|
||||
@ -24,16 +23,13 @@ const months = [
|
||||
'Septembre',
|
||||
'Octobre',
|
||||
'Novembre',
|
||||
'Décembre'
|
||||
'Décembre',
|
||||
]
|
||||
|
||||
export default class Element extends React.Component<Props, {}> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
render() {
|
||||
public render() {
|
||||
let date = this.props.date
|
||||
if (typeof this.props.date === "string") {
|
||||
if (typeof this.props.date === 'string') {
|
||||
date = new Date(this.props.date)
|
||||
}
|
||||
const t = `${date.getDate()} ${months[date.getMonth()]} ${date.getFullYear()}`
|
||||
|
@ -1,11 +1,12 @@
|
||||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
import '../styl/styl.styl'
|
||||
import { ChevronRight, ChevronDown } from 'react-feather'
|
||||
import React from 'react'
|
||||
import { ChevronDown, ChevronRight } from 'react-feather'
|
||||
|
||||
import config from '../config'
|
||||
import '../styl/styl.styl'
|
||||
|
||||
interface Props {
|
||||
categories?: string[]
|
||||
categories?: Array<string>
|
||||
onQuery?: (query: string, sort?: boolean) => void
|
||||
onHeight?: (height: number) => void
|
||||
}
|
||||
@ -17,40 +18,9 @@ interface States {
|
||||
|
||||
export default class Filters extends React.Component<Props, States> {
|
||||
|
||||
private aside = undefined
|
||||
private input = undefined
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
|
||||
setInput = element => {
|
||||
this.input = element
|
||||
}
|
||||
|
||||
onKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
setTimeout(() => {
|
||||
this.submit()
|
||||
}, 1);
|
||||
}
|
||||
|
||||
onClick = () => {
|
||||
if (this.input.value !== "") {
|
||||
this.submit()
|
||||
return
|
||||
}
|
||||
this.input.focus()
|
||||
}
|
||||
|
||||
onChange = (ev) => {
|
||||
this.submit(ev.target.value === "true")
|
||||
}
|
||||
|
||||
submit = (sort?: boolean) => {
|
||||
if (this.props.onQuery) this.props.onQuery(this.input.value, sort)
|
||||
}
|
||||
|
||||
render() {
|
||||
public render() {
|
||||
return (
|
||||
<aside>
|
||||
<div>Trier</div>
|
||||
@ -72,14 +42,13 @@ export default class Filters extends React.Component<Props, States> {
|
||||
</div>
|
||||
<p>Languages :</p>
|
||||
<span>
|
||||
{this.props.categories.map(cat => (
|
||||
{this.props.categories.map((cat) => (
|
||||
<Link key={cat} href="/tag/[tag]" as={`/tag/${cat.toLowerCase()}`}>
|
||||
<a className="button">{cat}</a>
|
||||
</Link>
|
||||
))}
|
||||
</span>
|
||||
|
||||
|
||||
<style jsx>{`
|
||||
|
||||
aside {
|
||||
@ -123,4 +92,32 @@ export default class Filters extends React.Component<Props, States> {
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
||||
private setInput = (element) => {
|
||||
this.input = element
|
||||
}
|
||||
|
||||
private onKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
||||
setTimeout(() => {
|
||||
this.submit()
|
||||
}, 1)
|
||||
}
|
||||
|
||||
private onClick = () => {
|
||||
if (this.input.value !== '') {
|
||||
this.submit()
|
||||
return
|
||||
}
|
||||
this.input.focus()
|
||||
}
|
||||
|
||||
private onChange = (ev) => {
|
||||
this.submit(ev.target.value === 'true')
|
||||
}
|
||||
|
||||
private submit = (sort?: boolean) => {
|
||||
if (this.props.onQuery) {
|
||||
this.props.onQuery(this.input.value, sort)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
import React from 'react'
|
||||
import { PhoneCall, Mail, GitHub, Twitter, Linkedin } from 'react-feather'
|
||||
import Link from 'next/link'
|
||||
import { GitHub, Linkedin, Mail, PhoneCall, Twitter } from 'react-feather'
|
||||
|
||||
import config from '../config'
|
||||
|
||||
interface Props {}
|
||||
|
||||
interface States {}
|
||||
|
||||
export default class Footer extends React.Component<Props, States> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
render() {
|
||||
export default class Footer extends React.Component<{}, {}> {
|
||||
public render() {
|
||||
return (
|
||||
<footer>
|
||||
<div className="pre"></div>
|
||||
|
@ -1,14 +1,9 @@
|
||||
import React from 'react'
|
||||
|
||||
import config from '../config'
|
||||
|
||||
interface Props {
|
||||
}
|
||||
|
||||
export default class Header extends React.Component<Props, {}> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
render() {
|
||||
export default class Header extends React.Component<{}, {}> {
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
{/* <p>Bienvenue sur le Portfolio de Florian BOUILLON !</p> */}
|
||||
|
@ -1,20 +1,19 @@
|
||||
import React from 'react'
|
||||
import Navbar from './Navbar'
|
||||
import Menu from './Menu'
|
||||
import Header from './Header'
|
||||
import Footer from './Footer'
|
||||
|
||||
import config from '../config'
|
||||
|
||||
import Footer from './Footer'
|
||||
import Header from './Header'
|
||||
import Menu from './Menu'
|
||||
import Navbar from './Navbar'
|
||||
|
||||
interface Props {
|
||||
hasHeader?: boolean
|
||||
headerChild?: JSX.Element
|
||||
}
|
||||
|
||||
export default class Layout extends React.Component<Props, {}> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
render() {
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
<Navbar>
|
||||
|
@ -1,15 +1,10 @@
|
||||
import React from 'react'
|
||||
import Link from 'next/link'
|
||||
import React from 'react'
|
||||
|
||||
import config from '../config'
|
||||
|
||||
interface Props {
|
||||
}
|
||||
|
||||
export default class Menu extends React.Component<Props, {}> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
render() {
|
||||
export default class Menu extends React.Component<{}, {}> {
|
||||
public render() {
|
||||
return (
|
||||
<ul>
|
||||
<li>
|
||||
|
@ -1,6 +1,7 @@
|
||||
import Link from 'next/link'
|
||||
import React from 'react'
|
||||
import { Menu } from 'react-feather'
|
||||
import Link from 'next/link'
|
||||
|
||||
import config from '../config'
|
||||
|
||||
interface Props {
|
||||
@ -17,7 +18,7 @@ export default class Navbar extends React.Component<Props, States> {
|
||||
|
||||
private menuRef = undefined
|
||||
|
||||
constructor(props: Props) {
|
||||
public constructor(props: Props) {
|
||||
super(props)
|
||||
|
||||
if (this.props.height) {
|
||||
@ -25,39 +26,25 @@ export default class Navbar extends React.Component<Props, States> {
|
||||
}
|
||||
}
|
||||
|
||||
setRef = element => {
|
||||
this.menuRef = element
|
||||
}
|
||||
|
||||
onScroll = () => {
|
||||
this.setState({
|
||||
scrolled: window.pageYOffset > 207
|
||||
})
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
public componentDidMount() {
|
||||
if (window.location.origin !== config.domain) {
|
||||
window.location.replace(`${config.domain}${window.location.pathname}`)
|
||||
}
|
||||
window.addEventListener('scroll', this.onScroll)
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
public componentWillUnmount() {
|
||||
window.removeEventListener('scroll', this.onScroll)
|
||||
}
|
||||
|
||||
onClick = () => {
|
||||
this.menuRef.classList.toggle("shown")
|
||||
}
|
||||
|
||||
render() {
|
||||
public render() {
|
||||
const height = this.props.height || 80
|
||||
|
||||
// if (!this.state.scrolled)
|
||||
|
||||
// console.log(this.state.scrolled)
|
||||
return (
|
||||
<nav className={this.state && this.state.scrolled ? "scrolled" : ""}>
|
||||
<nav className={this.state && this.state.scrolled ? 'scrolled' : ''}>
|
||||
<style jsx global>{`
|
||||
body {
|
||||
margin-top: ${height}px;
|
||||
@ -120,9 +107,9 @@ export default class Navbar extends React.Component<Props, States> {
|
||||
}
|
||||
.head {
|
||||
display: flex;
|
||||
height: ${height-10}px;
|
||||
height: ${height - 10}px;
|
||||
background: white;
|
||||
padding-left: ${height-10}px;
|
||||
padding-left: ${height - 10}px;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
@ -132,8 +119,8 @@ export default class Navbar extends React.Component<Props, States> {
|
||||
|
||||
}
|
||||
span {
|
||||
width: ${height-10}px;
|
||||
height: ${height-10}px;
|
||||
width: ${height - 10}px;
|
||||
height: ${height - 10}px;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@ -144,4 +131,18 @@ export default class Navbar extends React.Component<Props, States> {
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
private setRef = (element) => {
|
||||
this.menuRef = element
|
||||
}
|
||||
|
||||
private onScroll = () => {
|
||||
this.setState({
|
||||
scrolled: window.pageYOffset > 207,
|
||||
})
|
||||
}
|
||||
|
||||
private onClick = () => {
|
||||
this.menuRef.classList.toggle('shown')
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import matter from 'gray-matter'
|
||||
|
||||
|
||||
interface PostInterface {
|
||||
slug: string
|
||||
title: string
|
||||
@ -15,13 +14,22 @@ export interface PostHeader {
|
||||
imageAlt?: string
|
||||
date: Date
|
||||
url?: string
|
||||
tags?: string[]
|
||||
tags?: Array<string>
|
||||
modifiedDate?: Date
|
||||
short?: string
|
||||
}
|
||||
|
||||
export default class Post implements PostInterface {
|
||||
|
||||
public static async fetchAll(): Promise<Array<Post>> {
|
||||
const files: Array<string> = ((require as any).context('../posts', true, /\.md$/)).keys()
|
||||
const posts: Array<Post> = []
|
||||
for (const file of files) {
|
||||
posts.push(new Post(file.replace('./', '')))
|
||||
}
|
||||
return posts
|
||||
}
|
||||
|
||||
public slug: string
|
||||
public title: string
|
||||
public content: string
|
||||
@ -34,7 +42,10 @@ export default class Post implements PostInterface {
|
||||
}
|
||||
|
||||
public async fetch() {
|
||||
if (!this.slug.endsWith(".md")) this.slug = "portfolio/" + this.slug + ".md"
|
||||
if (!this.slug.endsWith('.md')) {
|
||||
this.slug = `portfolio/${this.slug}.md`
|
||||
}
|
||||
|
||||
const content = await import(`../posts/${this.slug}`)
|
||||
const md = matter(content.default)
|
||||
this.title = md.data.title
|
||||
@ -43,24 +54,14 @@ export default class Post implements PostInterface {
|
||||
}
|
||||
|
||||
public fetchSync() {
|
||||
if (!this.slug.endsWith(".md")) this.slug = "portfolio/" + this.slug + ".md"
|
||||
if (!this.slug.endsWith('.md')) {
|
||||
this.slug = `portfolio/${this.slug}.md`
|
||||
}
|
||||
|
||||
const content = require(`../posts/${this.slug}`)
|
||||
const md = matter(content.default)
|
||||
this.title = md.data.title
|
||||
this.header = (md.data as PostHeader)
|
||||
this.content = md.content
|
||||
}
|
||||
|
||||
public static async fetchAll(): Promise<Post[]> {
|
||||
const files: string[] = ((require as any).context('../posts', true, /\.md$/)).keys()
|
||||
const posts: Post[] = []
|
||||
for (const file of files) {
|
||||
posts.push(
|
||||
new Post(
|
||||
file.replace("./", '')
|
||||
)
|
||||
)
|
||||
}
|
||||
return posts
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
import React from 'react'
|
||||
|
||||
/* tslint:disable:no-empty-interface */
|
||||
interface Props {}
|
||||
|
||||
interface States {}
|
||||
/* tslint:enable:no-empty-interface */
|
||||
|
||||
export default class Name extends React.Component<Props, States> {
|
||||
constructor(props: Props) {
|
||||
super(props)
|
||||
}
|
||||
render() {
|
||||
public render() {
|
||||
return (
|
||||
<span></span>
|
||||
)
|
||||
|
Reference in New Issue
Block a user