Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Revert "chore: use 'src' dir"
Browse files Browse the repository at this point in the history
This reverts commit 4382d76.
  • Loading branch information
mcansh committed Mar 27, 2020
1 parent 4382d76 commit 72d776c
Show file tree
Hide file tree
Showing 73 changed files with 74 additions and 55 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
extends: ['@mcansh/eslint-config/typescript'],
settings: {
'import/resolver': {
'babel-plugin-root-import': {},
typescript: {},
},
},
Expand All @@ -18,10 +19,10 @@ module.exports = {
'error',
{
devDependencies: [
'src/__tests__/**/*',
'src/test-utils/index.tsx',
'__tests__/**/*',
'test-utils/index.tsx',
'scripts/**/*',
'src/types/jest-dom.d.ts',
'types/jest-dom.d.ts',
'next.config.js',
'.eslintrc.js',
'prettier.config.js',
Expand Down
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = api => {
const presets = ['next/babel'];
const plugins = [
'styled-components',
'root-import',
['inline-react-svg', { svgo: false }],
'macros',
'preval',
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import React from 'react';
import styled from 'styled-components';
import { motion, AnimatePresence } from 'framer-motion';

import Curve from '../../../public/static/images/curve.svg';

import Button from '~/components/button';
import DateHeading from '~/components/header/date';
import Image, { ImageType } from '~/components/header/image';
import Curve from '~/public/static/images/curve.svg';

const HeaderStyles = styled.header.attrs({ 'data-testid': 'header' })`
height: 50vh;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 6 additions & 9 deletions src/components/meta.tsx → components/meta.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import Head from 'next/head';
import { useRouter } from 'next/router';

import { description, homepage } from '~/package.json';
import { name } from '~/utils/authorInfo';
import { iso8601 } from '~/utils/dates';
import getCloudinaryURL from '~/utils/get-cloudinary-url';
Expand All @@ -19,25 +20,21 @@ const Meta: React.FC<Props> = ({ title, date, image }) => {
const pageTitle = title ? `${title}${name}` : name;
const fullImageUrl = image?.imageUrl
? getCloudinaryURL(image.imageUrl)
: `${process.env.HOME}/static/images/me.jpg`;
: `${homepage}/static/images/me.jpg`;

return (
<Head>
<title key="title">{pageTitle}</title>
<meta charSet="utf-8" />
<meta
key="description"
name="description"
content={process.env.DESCRIPTION}
/>
<meta key="description" name="description" content={description} />
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="loganmcansh" />
<meta key="twitter:title" name="twitter:title" content={pageTitle} />
<meta name="twitter:description" content={process.env.DESCRIPTION} />
<meta name="twitter:description" content={description} />
<meta key="twitter:image" name="twitter:image" content={fullImageUrl} />

<meta key="og:title" property="og:title" content={pageTitle} />
<meta property="og:description" content={process.env.DESCRIPTION} />
<meta property="og:description" content={description} />
<meta
key="og:type"
property="og:type"
Expand All @@ -46,7 +43,7 @@ const Meta: React.FC<Props> = ({ title, date, image }) => {
<meta
key="og:url"
property="og:url"
content={`${process.env.HOME}/${router.pathname}`}
content={`${homepage}/${router.pathname}`}
/>
<meta key="og:image" property="og:image" content={fullImageUrl} />
{date && (
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ module.exports = {
testURL: 'http://localhost:3000/',
coverageDirectory: './coverage/',
collectCoverage: true,
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
collectCoverageFrom: [
'components/**/*.{js,jsx,ts,tsx}',
'pages/**/*.{js,jsx,ts,tsx}',
'utils/**/*.{js,jsx,ts,tsx}',
],
setupFilesAfterEnv: [
'@testing-library/jest-dom/extend-expect',
'jest-styled-components',
'<rootDir>/jest.setup.js',
],
testPathIgnorePatterns: ['/.next/', '/node_modules/', '/types/'],
moduleNameMapper: {
'~/(.*)': '<rootDir>/src/$1',
},
};
12 changes: 1 addition & 11 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@ const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
});

const {
version,
repository,
description,
homepage,
author,
} = require('./package.json');
const { version, repository } = require('./package.json');

const nextConfig = {
target: 'serverless',
Expand All @@ -21,7 +15,6 @@ const nextConfig = {
granularChunks: true,
modern: true,
plugins: true,
jsconfigPaths: true,
},
dontAutoRegisterSw: true,
workboxOpts: {
Expand All @@ -39,9 +32,6 @@ const nextConfig = {
},

env: {
DESCRIPTION: description,
HOME: homepage,
AUTHOR: author,
TWITTER: 'loganmcansh',
INSTAGRAM: 'loganmcansh',
GITHUB: 'mcansh',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@
"@zeit/next-source-maps": "0.0.4-canary.1",
"babel-plugin-dynamic-import-node": "2.3.0",
"babel-plugin-inline-react-svg": "1.1.1",
"babel-plugin-root-import": "6.5.0",
"babel-plugin-styled-components": "1.10.7",
"eslint": "6.8.0",
"eslint-config-airbnb": "18.1.0",
"eslint-config-kentcdodds": "14.8.0",
"eslint-config-prettier": "6.10.1",
"eslint-import-resolver-babel-plugin-root-import": "1.1.1",
"eslint-import-resolver-typescript": "2.0.0",
"eslint-plugin-import": "2.20.1",
"eslint-plugin-jest": "23.8.2",
Expand Down Expand Up @@ -113,7 +115,7 @@
},
"husky": {
"hooks": {
"pre-commit": "node scripts/sitemap.js && git add src/data/posts.json && lint-staged",
"pre-commit": "node scripts/sitemap.js && git add data/posts.json && lint-staged",
"post-commit": "yarn run update-mdx-meta post-commit"
}
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 10 additions & 10 deletions posts.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { meta as learningSoftwareDevelopment } from './src/pages/why-im-learning-software-development.mdx';
import { meta as html5Progress } from './src/pages/html5-progress-element.mdx';
import { meta as objectLifecycle } from './src/pages/object-lifecycle-cheatsheet.mdx';
import { meta as javascriptClasses } from './src/pages/javascript-classes.mdx';
import { meta as rackKeyConcepts } from './src/pages/rack-key-concepts.mdx';
import { meta as lifeAndCode } from './src/pages/similarities-between-life-and-code.mdx';
import { meta as timeToHex } from './src/pages/time-to-hex.mdx';
import { meta as sinatraProject } from './src/pages/sinatra-project.mdx';
import { meta as railsProject } from './src/pages/rails-project.mdx';
import { meta as rubyProject } from './src/pages/ruby-project.mdx';
import { meta as learningSoftwareDevelopment } from './pages/why-im-learning-software-development.mdx';
import { meta as html5Progress } from './pages/html5-progress-element.mdx';
import { meta as objectLifecycle } from './pages/object-lifecycle-cheatsheet.mdx';
import { meta as javascriptClasses } from './pages/javascript-classes.mdx';
import { meta as rackKeyConcepts } from './pages/rack-key-concepts.mdx';
import { meta as lifeAndCode } from './pages/similarities-between-life-and-code.mdx';
import { meta as timeToHex } from './pages/time-to-hex.mdx';
import { meta as sinatraProject } from './pages/sinatra-project.mdx';
import { meta as railsProject } from './pages/rails-project.mdx';
import { meta as rubyProject } from './pages/ruby-project.mdx';

export default [
learningSoftwareDevelopment,
Expand Down
2 changes: 1 addition & 1 deletion scripts/atom.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs');
const path = require('path');

const { description, homepage } = require('../package.json');
const posts = require('../src/data/posts.json');
const posts = require('../data/posts.json');

const OUT_DIR = path.join(process.cwd(), 'public');

Expand Down
2 changes: 1 addition & 1 deletion scripts/jsonfeed.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs');
const path = require('path');

const { description, homepage } = require('../package.json');
const posts = require('../src/data/posts.json');
const posts = require('../data/posts.json');

const OUT_DIR = path.join(process.cwd(), 'public');

Expand Down
6 changes: 3 additions & 3 deletions scripts/sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const prettier = require('prettier');
const DOMAIN = 'https://mcansh.blog';
const META = /export\s+const\s+meta\s+=\s+({[\s\S]*?\n})/;
const SITEMAP_PATH = 'public/sitemap.xml';
const POSTS_PATH = 'src/data/posts.json';
const POSTS_PATH = 'data/posts.json';

// Set the header
const xmlHeader = `<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -43,7 +43,7 @@ function xmlUrlNode(pagePath) {
page,
pageName === 'index' ? '' : `${pageName}/`
);
const content = fs.readFileSync(path.join('src/pages', pagePath), 'utf-8');
const content = fs.readFileSync(path.join('pages', pagePath), 'utf-8');
const match = content.match(META);
const loc = DOMAIN + relativeUrl;

Expand Down Expand Up @@ -73,7 +73,7 @@ function xmlUrlNode(pagePath) {
}

function generateSiteMap() {
const posts = recursiveReadDirSync('src/pages', [], 'src/pages');
const posts = recursiveReadDirSync('pages', [], 'pages');
const postsMeta = [];

const nodes = posts
Expand Down
5 changes: 0 additions & 5 deletions src/utils/authorInfo.ts

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"jsx": "preserve",
"baseUrl": ".",
"paths": {
"~/*": ["./src/*"]
"~/*": ["./*"]
}
},
"exclude": ["node_modules"],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 0 additions & 3 deletions src/types/global.d.ts → types/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,5 @@ declare namespace NodeJS {
readonly ANALYZE: 'true' | 'false' | undefined;
readonly SENTRY_RELEASE: string;
readonly FATHOM_SITE_ID: string;
readonly DESCRIPTION: string;
readonly HOME: string;
readonly AUTHOR: string;
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions utils/authorInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as somebody from 'somebody';

import { author } from '~/package.json';

const { name, email, url } = somebody.parse(author);

export { name, email, url };
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 30 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3849,6 +3849,13 @@ [email protected]:
babel-plugin-macros "^2.8.0"
require-from-string "^2.0.2"

[email protected]:
version "6.5.0"
resolved "https://registry.yarnpkg.com/babel-plugin-root-import/-/babel-plugin-root-import-6.5.0.tgz#ac4016426b5d36c48127c73ad199fa72c9ff8817"
integrity sha512-PTD8fPl4v1kwn01u9d4rgRavDs5Z+jv4qa4/y6iYtoSgM4/xmjwMqo66j5A/BTZQEMA6OV5iFgyZ1PIhroJqqg==
dependencies:
slash "^3.0.0"

[email protected], "babel-plugin-styled-components@>= 1":
version "1.10.7"
resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.10.7.tgz#3494e77914e9989b33cc2d7b3b29527a949d635c"
Expand Down Expand Up @@ -5714,6 +5721,23 @@ eslint-config-prettier@^6.10.0:
dependencies:
get-stdin "^6.0.0"

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-babel-plugin-root-import/-/eslint-import-resolver-babel-plugin-root-import-1.1.1.tgz#b060f1177557918389f7ed476e5b36a43854a381"
integrity "sha1-sGDxF3VXkYOJ9+1Hbls2pDhUo4E= sha512-ZZxdV9AxzL2WFVggDxZ36xodPg2+BTrkhhMf/of+BxSVh/GKLGCs17EDq5b61wqC7/oQsA2h1RtH1fV7HOUV/w=="
dependencies:
eslint-import-resolver-node "^0.2.1"
json5 "^0.5.0"

eslint-import-resolver-node@^0.2.1:
version "0.2.3"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c"
integrity "sha1-Wt2BBujJKNssuiMrzZ76hG49oWw= sha512-HI8ShtDIy7gON76Nr3bu4zl0DuCLPo1Fud9P2lltOQKeiAS2r5/o/l3y+V8HJ1cDLFSz+tHu7/V9fI5jirwlbw=="
dependencies:
debug "^2.2.0"
object-assign "^4.0.1"
resolve "^1.1.6"

eslint-import-resolver-node@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.2.tgz#58f15fb839b8d0576ca980413476aab2472db66a"
Expand Down Expand Up @@ -8243,6 +8267,11 @@ [email protected], json5@^2.1.0:
dependencies:
minimist "^1.2.0"

json5@^0.5.0:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
integrity "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= sha512-4xrs1aW+6N5DalkqSVA8fxh458CXvR99WU8WLKmq4v8eWAL86Xo3BVqyd3SkA9wEVjCMqyvvRRkshAdOnBp5rw=="

json5@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe"
Expand Down Expand Up @@ -11395,7 +11424,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"
integrity "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs= sha512-9znBF0vBcaSN3W2j7wKvdERPwqTxSpCq+if5C0WoTCyV9n24rua28jeuQ2pL/HOf+yUe/Mef+H/5p60K0Id3bg=="

resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1:
resolve@^1.1.6, resolve@^1.10.0, resolve@^1.12.0, resolve@^1.13.1, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.3.2, resolve@^1.5.0, resolve@^1.8.1:
version "1.15.1"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.15.1.tgz#27bdcdeffeaf2d6244b95bb0f9f4b4653451f3e8"
integrity sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==
Expand Down

0 comments on commit 72d776c

Please sign in to comment.