Fixed linting 😃

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
2020-02-06 21:18:11 +01:00
parent c4775134de
commit fee40613f1
16 changed files with 249 additions and 157 deletions

View File

@ -1,3 +1,5 @@
import React from 'react'
import { NextPageContext } from 'next'
import Head from 'next/head'
import Link from 'next/link'
@ -32,6 +34,11 @@ export default class PostPage extends Component<Props, States> {
}
public render() {
if (!this.props.post.header) {
return (
<Error statusCode={404} />
)
}
return (
<main>
<Head>
@ -42,7 +49,11 @@ export default class PostPage extends Component<Props, States> {
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>
<meta
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}
/>
{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}
<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>
{this.props.post === undefined ? (
<Error statusCode={404} />
) : (
<div>
<Picture src={this.props.post.header.image} alt={this.props.post.header.imageAlt} parentStyle={{zIndex: 999}} style={{
maxWidth: "100%",
borderRadius: 10,
maxHeight: 300,
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>`)}/>
<Picture
src={this.props.post.header.image || ''}
alt={this.props.post.header.imageAlt}
parentStyle={{zIndex: 999}}
style={{
maxWidth: '100%',
borderRadius: 10,
maxHeight: 300,
boxShadow: '0px 0px 4px rgba(0, 0, 0, 0.4)',
}}
/>
<ReactMarkdown
escapeHtml={false}
source={emoji.emojify(
this.props.post.content,
undefined,
(code: string, name: string) => `<span class="emoji">${code}</span>`,
)}
/>
<h2>Détails</h2>
<p>Tags:</p>
<ul>
{this.props.post.header.tags.map((el) => (
{this.props.post.header.tags?.map(el => (
<li key={el}>
<Link href="/tag/[tag]" as={'/tag/' + el.toLowerCase()}>
<a className="button">{el}</a>

View File

@ -9,7 +9,7 @@ import '../styl/styl.styl'
class MyApp extends App {
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}`)
}
}

View File

@ -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'
class MyDocument extends Document {
public static async getInitialProps(ctx) {
public static async getInitialProps(ctx: DocumentContext) {
const initialProps = await Document.getInitialProps(ctx)
return { ...initialProps }
}
public componentDidMount() {
if (window.location.origin !== config.domain && window.location.hostname !== "localhost") {
window.location.replace(`${config.domain}${window.location.pathname}`)
}
}
public render() {
return (
<Html lang="en">

View File

@ -5,13 +5,21 @@ import React, { Component } from 'react'
interface Props {
statusCode: number
}
const codesTexts = {
interface Arr {
[key: string]: string
}
const codesTexts: Arr = {
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, {}> {
public static getInitialProps({ res, err }: NextPageContext) {
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
return { statusCode }
}
public render = () => {
const statusCode = this.props.statusCode
return (
@ -45,9 +53,4 @@ export default class Error extends Component<Props, {}> {
</main>
)
}
public static getInitialProps({ res, err }: NextPageContext) {
const statusCode = res ? res.statusCode : err ? err.statusCode : 404
return { statusCode }
}
}

View File

@ -1,3 +1,5 @@
import React from 'react'
import { Component } from 'react'
import Element from '../components/Element'
import Filters from '../components/Filters'
@ -24,14 +26,15 @@ export default class Page extends Component<Props, States> {
const posts = await Post.fetchAll()
const header: Array<PostHeader> = []
const cats: Array<string> = []
posts.forEach((el) => {
posts.forEach(el => {
el.fetchSync()
if (!el.header) {
return
}
header.push(el.header)
cats.push(...el.header.tags)
})
header.sort((a, b) => {
return (a.date < b.date) ? 1 : -1
cats.push(...el.header.tags || [])
})
header.sort((a, b) => (a.date < b.date) ? 1 : -1)
cats.sort((a, b) => (a < b) ? -1 : 1)
@ -44,10 +47,17 @@ export default class Page extends Component<Props, States> {
}
public render() {
const asideHeight = this.state?.asideHeight ? this.state.asideHeight + 100 : 600
return (
<main>
<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&apos;a rien donnée <span className="emoji">😢</span></div>
)}
{this.state && this.state.elements && this.state.elements.map((el, index) => (
<Element
key={index}
link={`/${el.category.toLowerCase()}/${el.id}`}
@ -56,13 +66,13 @@ export default class Page extends Component<Props, States> {
alt={el.imageAlt}
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>
<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>{`
span:not(.emoji) {
display: flex;
@ -85,7 +95,7 @@ export default class Page extends Component<Props, States> {
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 {
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) => {
// console.log(`query: ${query}`)
const t = elements.filter( (el) => {
return el.title.toLowerCase().includes(query.toLowerCase())
})
const t = elements.filter( el => el.title.toLowerCase().includes(query.toLowerCase()))
if (recent) {
t.sort((a, b) => {
return (a.date < b.date) ? 1 : -1
})
t.sort((a, b) => (a.date < b.date) ? 1 : -1)
} else {
t.sort((a, b) => {
return (a.date > b.date) ? 1 : -1
})
t.sort((a, b) => (a.date > b.date) ? 1 : -1)
}
this.setState({
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.
*/

View File

@ -1,3 +1,4 @@
import React from 'react'
import { NextPage, NextPageContext } from 'next'
import Element from '../../components/Element'
@ -6,18 +7,12 @@ import Post from '../../components/Post'
import Error from '../_error'
interface Props {
files: Array<Post>,
files: Array<Post>
tag: string
}
const PortfolioIndex: NextPage<Props> = (props: Props) => {
const el: Array<JSX.Element> = []
for (const post of props.files) {
el.push(
)
}
if (props.files.length === 0) {
return (
<Error statusCode={404} />
@ -28,15 +23,20 @@ const PortfolioIndex: NextPage<Props> = (props: Props) => {
<div>
<h2>Tag: {props && props.tag}</h2>
<div>
{props.files.map((post, index) => (
<Element
key={index}
link={`/${post.header.category.toLowerCase()}/${post.header.id}`}
title={post.header.title}
image={post.header.image}
date={post.header.date || new Date()}
/>
))}
{props.files.map((post, index) => {
if (!post.header) {
return
}
return (
<Element
key={index}
link={`/${post.header.category.toLowerCase()}/${post.header.id}`}
title={post.header.title}
image={post.header.image}
date={post.header.date || new Date()}
/>
)
})}
</div>
<style jsx>{`
span:not(.emoji) {
@ -81,7 +81,10 @@ PortfolioIndex.getInitialProps = async (context: NextPageContext) => {
await post.fetch()
}
const tags = []
for (const tg of post.header.tags) {
if (!post.header) {
continue
}
for (const tg of post.header.tags || []) {
tags.push(tg.toLowerCase())
}
if (!tags.includes(tag)) {