mirror of
https://github.com/dzeiocom/markblog.git
synced 2025-04-22 10:52:12 +00:00
Fixed linting 😃
Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
parent
c4775134de
commit
fee40613f1
@ -87,7 +87,6 @@ module.exports = {
|
|||||||
"@typescript-eslint/no-namespace": "error",
|
"@typescript-eslint/no-namespace": "error",
|
||||||
"@typescript-eslint/no-parameter-properties": "off",
|
"@typescript-eslint/no-parameter-properties": "off",
|
||||||
"@typescript-eslint/no-use-before-define": "off",
|
"@typescript-eslint/no-use-before-define": "off",
|
||||||
"@typescript-eslint/no-var-requires": "error",
|
|
||||||
"@typescript-eslint/prefer-for-of": "error",
|
"@typescript-eslint/prefer-for-of": "error",
|
||||||
"@typescript-eslint/prefer-function-type": "error",
|
"@typescript-eslint/prefer-function-type": "error",
|
||||||
"@typescript-eslint/prefer-namespace-keyword": "error",
|
"@typescript-eslint/prefer-namespace-keyword": "error",
|
||||||
@ -134,8 +133,7 @@ module.exports = {
|
|||||||
"string",
|
"string",
|
||||||
"Boolean",
|
"Boolean",
|
||||||
"boolean",
|
"boolean",
|
||||||
"Undefined",
|
"Undefined"
|
||||||
"undefined"
|
|
||||||
],
|
],
|
||||||
"id-match": "error",
|
"id-match": "error",
|
||||||
"max-classes-per-file": [
|
"max-classes-per-file": [
|
||||||
|
@ -38,7 +38,13 @@ export default class Element extends React.Component<Props, {}> {
|
|||||||
<div>
|
<div>
|
||||||
<Link href="/[category]/[slug]" as={this.props.link}>
|
<Link href="/[category]/[slug]" as={this.props.link}>
|
||||||
{this.props.image ? (
|
{this.props.image ? (
|
||||||
<a aria-label={this.props.title}><Picture src={this.props.image} alt={this.props.alt} style={{height: 250, borderRadius: 10}} /></a> //<img src={require(`../images${this.props.image}`/*this.props.image*/)} alt={this.props.alt}/>
|
<a aria-label={this.props.title}>
|
||||||
|
<Picture
|
||||||
|
src={this.props.image}
|
||||||
|
alt={this.props.alt}
|
||||||
|
style={{height: 250, borderRadius: 10}}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
) : (
|
) : (
|
||||||
<div></div>
|
<div></div>
|
||||||
)}
|
)}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import React from 'react'
|
import React, { RefObject, FormEvent } from 'react'
|
||||||
import { ChevronDown, ChevronRight } from 'react-feather'
|
import { ChevronDown, ChevronRight } from 'react-feather'
|
||||||
|
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
@ -18,7 +18,13 @@ interface States {
|
|||||||
|
|
||||||
export default class Filters extends React.Component<Props, States> {
|
export default class Filters extends React.Component<Props, States> {
|
||||||
|
|
||||||
private input = undefined
|
private input: RefObject<HTMLInputElement>
|
||||||
|
|
||||||
|
public constructor(props: Props) {
|
||||||
|
super(props)
|
||||||
|
|
||||||
|
this.input = React.createRef()
|
||||||
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
@ -35,14 +41,20 @@ export default class Filters extends React.Component<Props, States> {
|
|||||||
</div>
|
</div>
|
||||||
<label htmlFor="sidebar-filter">Filtrer</label>
|
<label htmlFor="sidebar-filter">Filtrer</label>
|
||||||
<div className="input icon-right inline">
|
<div className="input icon-right inline">
|
||||||
<input id="sidebar-filter" placeholder="ex: dzeio.com" type="text" ref={this.setInput} onKeyDownCapture={this.onKeyDown} />
|
<input
|
||||||
|
id="sidebar-filter"
|
||||||
|
placeholder="ex: dzeio.com"
|
||||||
|
type="text"
|
||||||
|
ref={this.input}
|
||||||
|
onKeyDownCapture={this.onKeyDown}
|
||||||
|
/>
|
||||||
<i>
|
<i>
|
||||||
<ChevronRight onClick={this.onClick} />
|
<ChevronRight onClick={this.onClick} />
|
||||||
</i>
|
</i>
|
||||||
</div>
|
</div>
|
||||||
<p>Languages :</p>
|
<p>Languages :</p>
|
||||||
<span>
|
<span>
|
||||||
{this.props.categories.map((cat) => (
|
{this.props.categories?.map(cat => (
|
||||||
<Link key={cat} href="/tag/[tag]" as={`/tag/${cat.toLowerCase()}`}>
|
<Link key={cat} href="/tag/[tag]" as={`/tag/${cat.toLowerCase()}`}>
|
||||||
<a className="button">{cat}</a>
|
<a className="button">{cat}</a>
|
||||||
</Link>
|
</Link>
|
||||||
@ -93,10 +105,6 @@ export default class Filters extends React.Component<Props, States> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private setInput = (element) => {
|
|
||||||
this.input = element
|
|
||||||
}
|
|
||||||
|
|
||||||
private onKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
private onKeyDown = (ev: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.submit()
|
this.submit()
|
||||||
@ -104,20 +112,20 @@ export default class Filters extends React.Component<Props, States> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onClick = () => {
|
private onClick = () => {
|
||||||
if (this.input.value !== '') {
|
if (this.input.current?.value !== '') {
|
||||||
this.submit()
|
this.submit()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.input.focus()
|
this.input.current.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
private onChange = (ev) => {
|
private onChange = (ev: React.KeyboardEvent<HTMLInputElement>|FormEvent<HTMLSelectElement>) => {
|
||||||
this.submit(ev.target.value === 'true')
|
this.submit((ev.target as HTMLInputElement).value === 'true')
|
||||||
}
|
}
|
||||||
|
|
||||||
private submit = (sort?: boolean) => {
|
private submit = (sort?: boolean) => {
|
||||||
if (this.props.onQuery) {
|
if (this.props.onQuery && this.input.current?.value) {
|
||||||
this.props.onQuery(this.input.value, sort)
|
this.props.onQuery(this.input.current.value, sort)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,19 +10,39 @@ export default class Footer extends React.Component<{}, {}> {
|
|||||||
<div className="pre"></div>
|
<div className="pre"></div>
|
||||||
<div className="footer">
|
<div className="footer">
|
||||||
<span>
|
<span>
|
||||||
<a aria-label="Email Address" href="mailto:contact@avior.me" target="_blank">
|
<a
|
||||||
|
aria-label="Email Address"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="mailto:contact@avior.me"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
<Mail color={config.colors[500]} />
|
<Mail color={config.colors[500]} />
|
||||||
</a>
|
</a>
|
||||||
<a aria-label="Phone Number" href="tel:+33672292683" target="_blank">
|
<a aria-label="Phone Number" rel="noopener noreferrer" href="tel:+33672292683" target="_blank">
|
||||||
<PhoneCall color={config.colors[500]} />
|
<PhoneCall color={config.colors[500]} />
|
||||||
</a>
|
</a>
|
||||||
<a aria-label="Git" rel="noopener noreferrer" href="https://git.delta-wings.net" target="_blank">
|
<a
|
||||||
|
aria-label="Git"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
href="https://git.delta-wings.net"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
<GitHub color={config.colors[500]} />
|
<GitHub color={config.colors[500]} />
|
||||||
</a>
|
</a>
|
||||||
<a aria-label="Twitter" rel="nofollow noopener noreferrer" href="https://twitter.com/aviortheking" target="_blank">
|
<a
|
||||||
|
aria-label="Twitter"
|
||||||
|
rel="nofollow noopener noreferrer"
|
||||||
|
href="https://twitter.com/aviortheking"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
<Twitter color={config.colors[500]} />
|
<Twitter color={config.colors[500]} />
|
||||||
</a>
|
</a>
|
||||||
<a aria-label="linkdedin" rel="nofollow noopener noreferrer" href="https://www.linkedin.com/in/florian-bouillon/" target="_blank">
|
<a
|
||||||
|
aria-label="linkdedin"
|
||||||
|
rel="nofollow noopener noreferrer"
|
||||||
|
href="https://www.linkedin.com/in/florian-bouillon/"
|
||||||
|
target="_blank"
|
||||||
|
>
|
||||||
<Linkedin color={config.colors[500]} />
|
<Linkedin color={config.colors[500]} />
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -4,13 +4,14 @@ import config from '../config'
|
|||||||
|
|
||||||
export default class Header extends React.Component<{}, {}> {
|
export default class Header extends React.Component<{}, {}> {
|
||||||
public render() {
|
public render() {
|
||||||
|
const t = `linear-gradient(90deg, ${config.colors[400]} 0%, ${config.colors[600]} 92.19%)`
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{/* <p>Bienvenue sur le Portfolio de Florian BOUILLON !</p> */}
|
{/* <p>Bienvenue sur le Portfolio de Florian BOUILLON !</p> */}
|
||||||
<style jsx>{`
|
<style jsx>{`
|
||||||
div {
|
div {
|
||||||
position: relative;
|
position: relative;
|
||||||
background: url('/clouds.svg'), linear-gradient(90deg, ${config.colors[400]} 0%, ${config.colors[600]} 92.19%);
|
background: url('/clouds.svg'), ${t};
|
||||||
background-repeat: repeat-x;
|
background-repeat: repeat-x;
|
||||||
background-position: bottom;
|
background-position: bottom;
|
||||||
min-height: 207px;
|
min-height: 207px;
|
||||||
@ -22,12 +23,6 @@ export default class Header extends React.Component<{}, {}> {
|
|||||||
font-size: 35px;
|
font-size: 35px;
|
||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
img {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0;
|
|
||||||
min-width: 100%;
|
|
||||||
height: 50px;
|
|
||||||
}
|
|
||||||
`}</style>
|
`}</style>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import React from 'react'
|
import React, { RefObject } from 'react'
|
||||||
import { Menu } from 'react-feather'
|
import { Menu } from 'react-feather'
|
||||||
|
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
@ -16,11 +16,13 @@ export default class Navbar extends React.Component<Props, States> {
|
|||||||
|
|
||||||
private height = 80
|
private height = 80
|
||||||
|
|
||||||
private menuRef = undefined
|
private menuRef: RefObject<any>
|
||||||
|
|
||||||
public constructor(props: Props) {
|
public constructor(props: Props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
|
this.menuRef = React.createRef()
|
||||||
|
|
||||||
if (this.props.height) {
|
if (this.props.height) {
|
||||||
this.height = this.props.height
|
this.height = this.props.height
|
||||||
}
|
}
|
||||||
@ -60,12 +62,12 @@ export default class Navbar extends React.Component<Props, States> {
|
|||||||
<Link href="/">
|
<Link href="/">
|
||||||
<a><img src="/logo.svg" alt="logo"/></a>
|
<a><img src="/logo.svg" alt="logo"/></a>
|
||||||
</Link>
|
</Link>
|
||||||
<span onClick={this.onClick} data-menu={this.refs.menu}>
|
<span onClick={this.onClick} data-menu={this.menuRef}>
|
||||||
<Menu size={30} />
|
<Menu size={30} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div ref={this.setRef} className="menu">
|
<div ref={this.menuRef} className="menu">
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -129,10 +131,6 @@ export default class Navbar extends React.Component<Props, States> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private setRef = (element) => {
|
|
||||||
this.menuRef = element
|
|
||||||
}
|
|
||||||
|
|
||||||
private onScroll = () => {
|
private onScroll = () => {
|
||||||
this.setState({
|
this.setState({
|
||||||
scrolled: window.pageYOffset > 207,
|
scrolled: window.pageYOffset > 207,
|
||||||
@ -140,6 +138,6 @@ export default class Navbar extends React.Component<Props, States> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private onClick = () => {
|
private onClick = () => {
|
||||||
this.menuRef.classList.toggle('shown')
|
this.menuRef.current.classList.toggle('shown')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,25 @@
|
|||||||
import { Component, CSSProperties } from "react"
|
import React, { Component, CSSProperties } from 'react'
|
||||||
|
|
||||||
interface props {
|
interface Props {
|
||||||
src: string,
|
src: string
|
||||||
alt?: string,
|
alt?: string
|
||||||
style?: CSSProperties
|
style?: CSSProperties
|
||||||
parentStyle?: CSSProperties
|
parentStyle?: CSSProperties
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Picture extends Component<props, {}> {
|
export default class Picture extends Component<Props, {}> {
|
||||||
public render() {
|
public render() {
|
||||||
const sets = require(`../images${this.props.src}?resize&sizes[]=300&sizes[]=600&sizes[]=1000`)
|
const sets = require(`../images${this.props.src}?resize&sizes[]=300&sizes[]=600&sizes[]=1000`)
|
||||||
return (
|
return (
|
||||||
<picture style={this.props.parentStyle}>
|
<picture style={this.props.parentStyle}>
|
||||||
<source srcSet={require(`../images${this.props.src}?webp`).default} type="image/webp" />
|
<source srcSet={require(`../images${this.props.src}?webp`).default} type="image/webp" />
|
||||||
<img srcSet={sets.srcSet} src={sets.src} alt={this.props.alt} style={Object.assign({width: "100%", objectFit: "cover"}, this.props.style)} />
|
<img
|
||||||
|
srcSet={sets.srcSet}
|
||||||
|
src={sets.src}
|
||||||
|
alt={this.props.alt}
|
||||||
|
style={
|
||||||
|
Object.assign({width: '100%', objectFit: 'cover'}, this.props.style)
|
||||||
|
} />
|
||||||
</picture>
|
</picture>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,17 @@ export interface PostHeader {
|
|||||||
|
|
||||||
export default class Post implements PostInterface {
|
export default class Post implements PostInterface {
|
||||||
|
|
||||||
|
public slug: string
|
||||||
|
public title: string = ''
|
||||||
|
public content: string = ''
|
||||||
|
public isStarted = false
|
||||||
|
|
||||||
|
public header?: PostHeader
|
||||||
|
|
||||||
|
public constructor(slug: string) {
|
||||||
|
this.slug = slug
|
||||||
|
}
|
||||||
|
|
||||||
public static async fetchAll(): Promise<Array<Post>> {
|
public static async fetchAll(): Promise<Array<Post>> {
|
||||||
const files: Array<string> = ((require as any).context('../posts', true, /\.md$/)).keys()
|
const files: Array<string> = ((require as any).context('../posts', true, /\.md$/)).keys()
|
||||||
const posts: Array<Post> = []
|
const posts: Array<Post> = []
|
||||||
@ -30,16 +41,6 @@ export default class Post implements PostInterface {
|
|||||||
return posts
|
return posts
|
||||||
}
|
}
|
||||||
|
|
||||||
public slug: string
|
|
||||||
public title: string
|
|
||||||
public content: string
|
|
||||||
public isStarted = false
|
|
||||||
|
|
||||||
public header: PostHeader
|
|
||||||
|
|
||||||
constructor(slug: string) {
|
|
||||||
this.slug = slug
|
|
||||||
}
|
|
||||||
|
|
||||||
public async fetch() {
|
public async fetch() {
|
||||||
if (!this.slug.endsWith('.md')) {
|
if (!this.slug.endsWith('.md')) {
|
||||||
|
@ -1,15 +1,13 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
/* tslint:disable:no-empty-interface */
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
||||||
interface Props {}
|
interface Props {}
|
||||||
|
|
||||||
interface States {}
|
interface States {}
|
||||||
/* tslint:enable:no-empty-interface */
|
/* eslint-enable @typescript-eslint/no-empty-interface */
|
||||||
|
|
||||||
export default class Name extends React.Component<Props, States> {
|
export default class Name extends React.Component<Props, States> {
|
||||||
constructor(props: Props) {
|
|
||||||
super(props)
|
|
||||||
}
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<span></span>
|
<span></span>
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
import { NextPageContext } from 'next'
|
import { NextPageContext } from 'next'
|
||||||
import Head from 'next/head'
|
import Head from 'next/head'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
@ -32,6 +34,11 @@ export default class PostPage extends Component<Props, States> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
if (!this.props.post.header) {
|
||||||
|
return (
|
||||||
|
<Error statusCode={404} />
|
||||||
|
)
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
<Head>
|
<Head>
|
||||||
@ -42,7 +49,11 @@ export default class PostPage extends Component<Props, States> {
|
|||||||
content={this.props.post.header.short || this.props.post.header.title}
|
content={this.props.post.header.short || this.props.post.header.title}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<meta key="og:title" property="og:title" content={`${this.props.post.header.title} - ${config.og.title}`} />
|
<meta
|
||||||
|
key="og:title"
|
||||||
|
property="og:title"
|
||||||
|
content={`${this.props.post.header.title} - ${config.og.title}`}
|
||||||
|
/>
|
||||||
<title key="title">{`${this.props.post.header.title} - ${config.og.title}`}</title>
|
<title key="title">{`${this.props.post.header.title} - ${config.og.title}`}</title>
|
||||||
<meta
|
<meta
|
||||||
key="og:description"
|
key="og:description"
|
||||||
@ -50,25 +61,46 @@ export default class PostPage extends Component<Props, States> {
|
|||||||
content={this.props.post.header.short || this.props.post.header.title}
|
content={this.props.post.header.short || this.props.post.header.title}
|
||||||
/>
|
/>
|
||||||
{this.props.post.header.image ? (
|
{this.props.post.header.image ? (
|
||||||
<meta key="og:image" property="og:image" content={`${config.domain}${this.props.post.header.image}`}/>
|
<meta
|
||||||
|
key="og:image"
|
||||||
|
property="og:image"
|
||||||
|
content={`${config.domain}${this.props.post.header.image}`}
|
||||||
|
/>
|
||||||
) : undefined}
|
) : undefined}
|
||||||
<script type="application/javascript" async defer src="https://hashover.dzeio.com/comments.php"></script>
|
<script
|
||||||
|
type="application/javascript"
|
||||||
|
async
|
||||||
|
defer
|
||||||
|
src="https://hashover.dzeio.com/comments.php"
|
||||||
|
></script>
|
||||||
</Head>
|
</Head>
|
||||||
{this.props.post === undefined ? (
|
{this.props.post === undefined ? (
|
||||||
<Error statusCode={404} />
|
<Error statusCode={404} />
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<Picture src={this.props.post.header.image} alt={this.props.post.header.imageAlt} parentStyle={{zIndex: 999}} style={{
|
<Picture
|
||||||
maxWidth: "100%",
|
src={this.props.post.header.image || ''}
|
||||||
|
alt={this.props.post.header.imageAlt}
|
||||||
|
parentStyle={{zIndex: 999}}
|
||||||
|
style={{
|
||||||
|
maxWidth: '100%',
|
||||||
borderRadius: 10,
|
borderRadius: 10,
|
||||||
maxHeight: 300,
|
maxHeight: 300,
|
||||||
boxShadow: "0px 0px 4px rgba(0, 0, 0, 0.4)"
|
boxShadow: '0px 0px 4px rgba(0, 0, 0, 0.4)',
|
||||||
}}/>
|
}}
|
||||||
<ReactMarkdown escapeHtml={false} source={emoji.emojify(this.props.post.content, null, (code, name) => `<span class="emoji">${code}</span>`)}/>
|
/>
|
||||||
|
<ReactMarkdown
|
||||||
|
escapeHtml={false}
|
||||||
|
source={emoji.emojify(
|
||||||
|
this.props.post.content,
|
||||||
|
undefined,
|
||||||
|
(code: string, name: string) => `<span class="emoji">${code}</span>`,
|
||||||
|
)}
|
||||||
|
/>
|
||||||
<h2>Détails</h2>
|
<h2>Détails</h2>
|
||||||
<p>Tags:</p>
|
<p>Tags:</p>
|
||||||
<ul>
|
<ul>
|
||||||
{this.props.post.header.tags.map((el) => (
|
{this.props.post.header.tags?.map(el => (
|
||||||
<li key={el}>
|
<li key={el}>
|
||||||
<Link href="/tag/[tag]" as={'/tag/' + el.toLowerCase()}>
|
<Link href="/tag/[tag]" as={'/tag/' + el.toLowerCase()}>
|
||||||
<a className="button">{el}</a>
|
<a className="button">{el}</a>
|
||||||
|
@ -9,7 +9,7 @@ import '../styl/styl.styl'
|
|||||||
class MyApp extends App {
|
class MyApp extends App {
|
||||||
|
|
||||||
public componentDidMount() {
|
public componentDidMount() {
|
||||||
if (window.location.origin !== config.domain && window.location.hostname !== "localhost") {
|
if (window.location.origin !== config.domain && window.location.hostname !== 'localhost') {
|
||||||
window.location.replace(`${config.domain}${window.location.pathname}`)
|
window.location.replace(`${config.domain}${window.location.pathname}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,14 @@
|
|||||||
import Document, { Head, Html, Main, NextScript } from 'next/document'
|
import React from 'react'
|
||||||
|
|
||||||
|
import Document, { Head, Html, Main, NextScript, DocumentContext } from 'next/document'
|
||||||
import config from '../config'
|
import config from '../config'
|
||||||
|
|
||||||
class MyDocument extends Document {
|
class MyDocument extends Document {
|
||||||
public static async getInitialProps(ctx) {
|
public static async getInitialProps(ctx: DocumentContext) {
|
||||||
const initialProps = await Document.getInitialProps(ctx)
|
const initialProps = await Document.getInitialProps(ctx)
|
||||||
return { ...initialProps }
|
return { ...initialProps }
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidMount() {
|
|
||||||
if (window.location.origin !== config.domain && window.location.hostname !== "localhost") {
|
|
||||||
window.location.replace(`${config.domain}${window.location.pathname}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
return (
|
return (
|
||||||
<Html lang="en">
|
<Html lang="en">
|
||||||
|
@ -5,13 +5,21 @@ import React, { Component } from 'react'
|
|||||||
interface Props {
|
interface Props {
|
||||||
statusCode: number
|
statusCode: number
|
||||||
}
|
}
|
||||||
|
interface Arr {
|
||||||
const codesTexts = {
|
[key: string]: string
|
||||||
|
}
|
||||||
|
const codesTexts: Arr = {
|
||||||
404: 'Page non trouvé !',
|
404: 'Page non trouvé !',
|
||||||
500: "Le serveur n'a pas pu répondre a ta demande :O",
|
500: 'Le serveur n\'a pas pu répondre a ta demande :O',
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Error extends Component<Props, {}> {
|
export default class Error extends Component<Props, {}> {
|
||||||
|
|
||||||
|
public static getInitialProps({ res, err }: NextPageContext) {
|
||||||
|
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
|
||||||
|
return { statusCode }
|
||||||
|
}
|
||||||
|
|
||||||
public render = () => {
|
public render = () => {
|
||||||
const statusCode = this.props.statusCode
|
const statusCode = this.props.statusCode
|
||||||
return (
|
return (
|
||||||
@ -45,9 +53,4 @@ export default class Error extends Component<Props, {}> {
|
|||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public static getInitialProps({ res, err }: NextPageContext) {
|
|
||||||
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
|
|
||||||
return { statusCode }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import React from 'react'
|
||||||
|
|
||||||
import { Component } from 'react'
|
import { Component } from 'react'
|
||||||
import Element from '../components/Element'
|
import Element from '../components/Element'
|
||||||
import Filters from '../components/Filters'
|
import Filters from '../components/Filters'
|
||||||
@ -24,14 +26,15 @@ export default class Page extends Component<Props, States> {
|
|||||||
const posts = await Post.fetchAll()
|
const posts = await Post.fetchAll()
|
||||||
const header: Array<PostHeader> = []
|
const header: Array<PostHeader> = []
|
||||||
const cats: Array<string> = []
|
const cats: Array<string> = []
|
||||||
posts.forEach((el) => {
|
posts.forEach(el => {
|
||||||
el.fetchSync()
|
el.fetchSync()
|
||||||
|
if (!el.header) {
|
||||||
|
return
|
||||||
|
}
|
||||||
header.push(el.header)
|
header.push(el.header)
|
||||||
cats.push(...el.header.tags)
|
cats.push(...el.header.tags || [])
|
||||||
})
|
|
||||||
header.sort((a, b) => {
|
|
||||||
return (a.date < b.date) ? 1 : -1
|
|
||||||
})
|
})
|
||||||
|
header.sort((a, b) => (a.date < b.date) ? 1 : -1)
|
||||||
|
|
||||||
cats.sort((a, b) => (a < b) ? -1 : 1)
|
cats.sort((a, b) => (a < b) ? -1 : 1)
|
||||||
|
|
||||||
@ -44,10 +47,17 @@ export default class Page extends Component<Props, States> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
|
const asideHeight = this.state?.asideHeight ? this.state.asideHeight + 100 : 600
|
||||||
return (
|
return (
|
||||||
<main>
|
<main>
|
||||||
<span>
|
<span>
|
||||||
{this.state && this.state.elements && this.state.elements.length !== 0 ? this.state.elements.map((el, index) => (
|
{!this.state || !this.state.elements && (
|
||||||
|
<div>Chargement en cours... <span className="emoji">😃</span></div>
|
||||||
|
)}
|
||||||
|
{this.state && this.state.loaded && this.state.elements.length === 0 && (
|
||||||
|
<div>La recherche n'a rien donnée <span className="emoji">😢</span></div>
|
||||||
|
)}
|
||||||
|
{this.state && this.state.elements && this.state.elements.map((el, index) => (
|
||||||
<Element
|
<Element
|
||||||
key={index}
|
key={index}
|
||||||
link={`/${el.category.toLowerCase()}/${el.id}`}
|
link={`/${el.category.toLowerCase()}/${el.id}`}
|
||||||
@ -56,13 +66,13 @@ export default class Page extends Component<Props, States> {
|
|||||||
alt={el.imageAlt}
|
alt={el.imageAlt}
|
||||||
date={el.date || new Date()}
|
date={el.date || new Date()}
|
||||||
/>
|
/>
|
||||||
)) : this.state && this.state.loaded ? (
|
))}
|
||||||
<div>La recherche n'a rien donnée <span className="emoji">😢</span></div>
|
|
||||||
) : (
|
|
||||||
<div>Chargement en cours... <span className="emoji">😃</span></div>
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
<Filters categories={this.state && this.state.categories || []} onQuery={this.onQuery} onHeight={this.onHeight}/>
|
<Filters
|
||||||
|
categories={this.state && this.state.categories || []}
|
||||||
|
onQuery={this.onQuery}
|
||||||
|
onHeight={this.onHeight}
|
||||||
|
/>
|
||||||
<style jsx>{`
|
<style jsx>{`
|
||||||
span:not(.emoji) {
|
span:not(.emoji) {
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -85,7 +95,7 @@ export default class Page extends Component<Props, States> {
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 820px) and (min-height: ${this.state && this.state.asideHeight ? this.state.asideHeight + 100 : 600}px) {
|
@media (min-width: 820px) and (min-height: ${asideHeight}px) {
|
||||||
span {
|
span {
|
||||||
max-width: calc(100% - 400px);
|
max-width: calc(100% - 400px);
|
||||||
}
|
}
|
||||||
@ -101,17 +111,11 @@ export default class Page extends Component<Props, States> {
|
|||||||
|
|
||||||
private onQuery = async (query: string, recent: boolean = true) => {
|
private onQuery = async (query: string, recent: boolean = true) => {
|
||||||
// console.log(`query: ${query}`)
|
// console.log(`query: ${query}`)
|
||||||
const t = elements.filter( (el) => {
|
const t = elements.filter( el => el.title.toLowerCase().includes(query.toLowerCase()))
|
||||||
return el.title.toLowerCase().includes(query.toLowerCase())
|
|
||||||
})
|
|
||||||
if (recent) {
|
if (recent) {
|
||||||
t.sort((a, b) => {
|
t.sort((a, b) => (a.date < b.date) ? 1 : -1)
|
||||||
return (a.date < b.date) ? 1 : -1
|
|
||||||
})
|
|
||||||
} else {
|
} else {
|
||||||
t.sort((a, b) => {
|
t.sort((a, b) => (a.date > b.date) ? 1 : -1)
|
||||||
return (a.date > b.date) ? 1 : -1
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
elements: t,
|
elements: t,
|
||||||
@ -124,3 +128,27 @@ export default class Page extends Component<Props, States> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Email configuration :D
|
||||||
|
|
||||||
|
IN MX 10 srv1.dzeio.com.
|
||||||
|
IN TXT "mailconf=https://autoconfig.avior.me/mail/config-v1.1.xml"
|
||||||
|
IN TXT "v=spf1 mx ~all"
|
||||||
|
_autodiscover._tcp IN SRV 0 0 443 autodiscover.avior.me.
|
||||||
|
_imaps._tcp IN SRV 0 0 143 srv1.dzeio.com.
|
||||||
|
_submission._tcp IN SRV 0 0 587 srv1.dzeio.com.
|
||||||
|
autoconfig IN CNAME srv1.dzeio.com.
|
||||||
|
autodiscover IN CNAME srv1.dzeio.com.
|
||||||
|
imap IN CNAME srv1.dzeio.com.
|
||||||
|
mail IN CNAME srv1.dzeio.com.
|
||||||
|
pop3 IN CNAME srv1.dzeio.com.
|
||||||
|
smtp IN CNAME srv1.dzeio.com.
|
||||||
|
|
||||||
|
mail._domainkey IN TXT ( "DKIM" )
|
||||||
|
|
||||||
|
HestiaCP
|
||||||
|
|
||||||
|
webmail IN CNAME srv1.dzeio.com.
|
||||||
|
|
||||||
|
*/
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import React from 'react'
|
||||||
import { NextPage, NextPageContext } from 'next'
|
import { NextPage, NextPageContext } from 'next'
|
||||||
|
|
||||||
import Element from '../../components/Element'
|
import Element from '../../components/Element'
|
||||||
@ -6,18 +7,12 @@ import Post from '../../components/Post'
|
|||||||
import Error from '../_error'
|
import Error from '../_error'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
files: Array<Post>,
|
files: Array<Post>
|
||||||
tag: string
|
tag: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const PortfolioIndex: NextPage<Props> = (props: Props) => {
|
const PortfolioIndex: NextPage<Props> = (props: Props) => {
|
||||||
|
|
||||||
const el: Array<JSX.Element> = []
|
|
||||||
for (const post of props.files) {
|
|
||||||
el.push(
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (props.files.length === 0) {
|
if (props.files.length === 0) {
|
||||||
return (
|
return (
|
||||||
<Error statusCode={404} />
|
<Error statusCode={404} />
|
||||||
@ -28,7 +23,11 @@ const PortfolioIndex: NextPage<Props> = (props: Props) => {
|
|||||||
<div>
|
<div>
|
||||||
<h2>Tag: {props && props.tag}</h2>
|
<h2>Tag: {props && props.tag}</h2>
|
||||||
<div>
|
<div>
|
||||||
{props.files.map((post, index) => (
|
{props.files.map((post, index) => {
|
||||||
|
if (!post.header) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return (
|
||||||
<Element
|
<Element
|
||||||
key={index}
|
key={index}
|
||||||
link={`/${post.header.category.toLowerCase()}/${post.header.id}`}
|
link={`/${post.header.category.toLowerCase()}/${post.header.id}`}
|
||||||
@ -36,7 +35,8 @@ const PortfolioIndex: NextPage<Props> = (props: Props) => {
|
|||||||
image={post.header.image}
|
image={post.header.image}
|
||||||
date={post.header.date || new Date()}
|
date={post.header.date || new Date()}
|
||||||
/>
|
/>
|
||||||
))}
|
)
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
<style jsx>{`
|
<style jsx>{`
|
||||||
span:not(.emoji) {
|
span:not(.emoji) {
|
||||||
@ -81,7 +81,10 @@ PortfolioIndex.getInitialProps = async (context: NextPageContext) => {
|
|||||||
await post.fetch()
|
await post.fetch()
|
||||||
}
|
}
|
||||||
const tags = []
|
const tags = []
|
||||||
for (const tg of post.header.tags) {
|
if (!post.header) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
for (const tg of post.header.tags || []) {
|
||||||
tags.push(tg.toLowerCase())
|
tags.push(tg.toLowerCase())
|
||||||
}
|
}
|
||||||
if (!tags.includes(tag)) {
|
if (!tags.includes(tag)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user