diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 8be170e..0000000 --- a/.eslintrc +++ /dev/null @@ -1,44 +0,0 @@ -{ - "extends": [ - "eslint:recommended", - "plugin:react/recommended", - "plugin:jsx-a11y/recommended", - "prettier" - ], - "plugins": [ - "react", - "jsx-a11y" - ], - "parserOptions": { - "ecmaFeatures": { - "jsx": true, - "modules": true - } - }, - "settings": { - "react": { - "version": "detect" - } - }, - "env": { - "browser": true, - "node": true - }, - "parser": "babel-eslint", - "rules": { - "react/jsx-uses-react": 2, - "react/jsx-uses-vars": 2, - "react/react-in-jsx-scope": 2, - "react/jsx-no-target-blank": 1, - "comma-dangle": [2, "always-multiline"], - "react/prop-types": 0, - "no-use-before-define": 0, - "padded-blocks": 0, - "id-length": [2, { - "min": 3, - "max": 30, - "properties": "never", - "exceptions": ["x", "y", "vx", "vy", "id", "i", "e", "fn", "_"] - }] - } -} diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..3725308 --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,37 @@ +module.exports = { + extends: [ + "plugin:@typescript-eslint/recommended", + "plugin:react-hooks/recommended", + "plugin:react/recommended", + "plugin:jsx-a11y/recommended", + "plugin:@next/next/recommended", + "prettier", + ], + settings: { + react: { + version: "detect", + }, + }, + env: { + browser: true, + node: true, + }, + parser: "@typescript-eslint/parser", + parserOptions: { + ecmaVersion: 2020, + sourceType: "module", + ecmaFeatures: { + jsx: true, + }, + }, + rules: { + "@typescript-eslint/ban-types": "warn", + "no-use-before-define": 0, + "padded-blocks": 0, + "react/jsx-no-target-blank": 0, + "react/jsx-uses-react": 2, + "react/jsx-uses-vars": 2, + "react/prop-types": 0, + "react/react-in-jsx-scope": 2, + }, +}; diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..b6a7d89 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +16 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..2b3533c --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +.next +out diff --git a/README.md b/README.md index 56062da..ddf37f4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # Koodiklinikka + ![Travis](https://travis-ci.org/koodiklinikka/koodiklinikka.fi.svg?branch=master) Koodiklinikka-logo @@ -13,7 +14,7 @@ - projektin hallintaan liittyviin asioihin - tai koko Koodiklinikkaan yleisesti. ------------------------------ +--- ## Projektin asennus @@ -41,7 +42,6 @@ yarn start Avaa selaimessasi: [`http://localhost:3000`](http://localhost:3000) - ## Komennot ### `yarn` diff --git a/TODO.md b/TODO.md index 4fbb7a5..b1c77d2 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,6 @@ -* Stripe - * Test ID `pk_test_OmNve9H1OuORlmD4rblpjgzh` - * Prod ID `pk_live_xrnwdLNXbt20LMxpIDffJnnC` -* API integration (test backend `https://lit-plateau-4689.herokuapp.com/`) -* Hero video -* Deployment +- Stripe + - Test ID `pk_test_OmNve9H1OuORlmD4rblpjgzh` + - Prod ID `pk_live_xrnwdLNXbt20LMxpIDffJnnC` +- API integration (test backend `https://lit-plateau-4689.herokuapp.com/`) +- Hero video +- Deployment diff --git a/components/ChannelReferenceRenderer.tsx b/components/ChannelReferenceRenderer.tsx index 372029f..adf2127 100644 --- a/components/ChannelReferenceRenderer.tsx +++ b/components/ChannelReferenceRenderer.tsx @@ -1,17 +1,32 @@ -export const ChannelReferenceRenderer = (props: { value: string }) => { +/* eslint-disable @typescript-eslint/ban-types */ +import React from "react"; + +function renderStringWithChannelRefs(value: string) { return ( <> - {props.value.split(/(<#[A-Z0-9]+\|[A-Za-z0-9]+>)/).map((str) => { + {value.split(/(<#[A-Z0-9]+\|[A-Za-z0-9]+>)/).map((str, i) => { const matches = str.match(/<#([A-Z0-9]+)\|([A-Za-z0-9]+)>/); if (matches) { return ( - + #{matches[2]} ); } - return str; + return {str}; })} ); +} + +export const ChannelReferenceRenderer = ({ + children, +}: React.PropsWithChildren<{}>) => { + // TODO: this should probably walk the tree + if (typeof children[0] === "string") + return renderStringWithChannelRefs(children[0]); + return <>{children}; }; diff --git a/components/Feed.tsx b/components/Feed.tsx index 23ca275..bd0a5bc 100644 --- a/components/Feed.tsx +++ b/components/Feed.tsx @@ -8,8 +8,7 @@ import ReactTimeAgo from "react-time-ago"; import JavascriptTimeAgo from "javascript-time-ago"; import timeagoFi from "javascript-time-ago/locale/fi"; -// TODO: Add type definitions for javascript-time-ago -(JavascriptTimeAgo as any).locale(timeagoFi); +JavascriptTimeAgo.addLocale(timeagoFi); export default class Feed extends React.Component { state = { diff --git a/components/Footer.tsx b/components/Footer.tsx index bb4b194..d278a8d 100644 --- a/components/Footer.tsx +++ b/components/Footer.tsx @@ -5,7 +5,7 @@ import sponsors from "../data/sponsors"; type Props = { href: string; name: string; - key: string; + title?: string; }; const SponsorLink = ({ href, name }: Props) => ( @@ -19,6 +19,17 @@ const SponsorLink = ({ href, name }: Props) => ( ); +const SocialLink = ({ href, name, title }: Props) => ( + + {title} + +); + export function Footer() { return (