1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-12-23 01:30:01 +01:00
This commit is contained in:
Matthias Kretschmann 2021-02-28 04:09:56 +01:00
parent 71feac2ea8
commit 6f3a47ae38
Signed by: m
GPG Key ID: 606EEEF3C479A91F
15 changed files with 33202 additions and 191 deletions

View File

@ -228,7 +228,7 @@ npm run new photo /path/to/photo.jpg
``` ```
- [`scripts/new.js`](scripts/new.js) - [`scripts/new.js`](scripts/new.js)
- [`scripts/new.md`](scripts/new.md) - [`scripts/new-article.md`](scripts/new-article.md)
- [`scripts/new-photo.md`](scripts/new-photo.md) - [`scripts/new-photo.md`](scripts/new-photo.md)
## 🚚 Deployment ## 🚚 Deployment

33329
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,7 @@
"format": "prettier --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx,md,json,css,scss}'", "format": "prettier --ignore-path .gitignore --write '**/*.{js,jsx,ts,tsx,md,json,css,scss}'",
"tsc": "tsc --noEmit", "tsc": "tsc --noEmit",
"deploy": "./scripts/deploy-s3.sh", "deploy": "./scripts/deploy-s3.sh",
"new": "babel-node ./scripts/new.js" "new": "ts-node ./scripts/new.ts"
}, },
"browserslist": [ "browserslist": [
">0.2%", ">0.2%",
@ -86,12 +86,11 @@
"use-dark-mode": "^2.3.1" "use-dark-mode": "^2.3.1"
}, },
"devDependencies": { "devDependencies": {
"@babel/node": "^7.12.16",
"@babel/preset-typescript": "^7.12.16",
"@svgr/webpack": "^5.5.0", "@svgr/webpack": "^5.5.0",
"@testing-library/jest-dom": "^5.11.9", "@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5", "@testing-library/react": "^11.2.5",
"@types/classnames": "^2.2.11", "@types/classnames": "^2.2.11",
"@types/fs-extra": "^9.0.7",
"@types/jest": "^26.0.20", "@types/jest": "^26.0.20",
"@types/loadable__component": "^5.13.3", "@types/loadable__component": "^5.13.3",
"@types/lunr": "^2.3.3", "@types/lunr": "^2.3.3",
@ -129,6 +128,7 @@
"stylelint-config-prettier": "^8.0.2", "stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^20.0.0", "stylelint-config-standard": "^20.0.0",
"stylelint-prettier": "^1.1.2", "stylelint-prettier": "^1.1.2",
"ts-node": "^9.1.1",
"typescript": "^4.1.5" "typescript": "^4.1.5"
}, },
"repository": { "repository": {

View File

@ -1,3 +0,0 @@
{
"presets": ["@babel/env"]
}

View File

@ -5,7 +5,7 @@ import ora from 'ora'
import fastExif from 'fast-exif' import fastExif from 'fast-exif'
import iptc from 'node-iptc' import iptc from 'node-iptc'
const templatePath = path.join(__dirname, 'new.md') const templatePath = path.join(__dirname, 'new-article.md')
const templatePathPhoto = path.join(__dirname, 'new-photo.md') const templatePathPhoto = path.join(__dirname, 'new-photo.md')
const template = fs.readFileSync(templatePath).toString() const template = fs.readFileSync(templatePath).toString()
const templatePhoto = fs.readFileSync(templatePathPhoto).toString() const templatePhoto = fs.readFileSync(templatePathPhoto).toString()
@ -22,12 +22,12 @@ const isPhoto = process.argv[2] === 'photo'
spinner.text = `Adding '${title}'.` spinner.text = `Adding '${title}'.`
let titleSlug = slugify(title, { lower: true }) let titleSlug = slugify(title, { lower: true })
const postsPath = path.join('.', 'content', 'posts') const postsPath = path.join('.', 'content', 'articles')
const photosPath = path.join('.', 'content', 'photos') const photosPath = path.join('.', 'content', 'photos')
let date = new Date().toISOString() let date = new Date().toISOString()
async function getIptc(imagePath) { async function getIptc(imagePath: string) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
fs.readFile(imagePath, (err, data) => { fs.readFile(imagePath, (err, data) => {
if (err) reject(err) if (err) reject(err)
@ -37,7 +37,7 @@ async function getIptc(imagePath) {
}) })
} }
async function getExif(imagePath) { async function getExif(imagePath: string) {
let exifData let exifData
try { try {
exifData = await fastExif.read(imagePath, true) exifData = await fastExif.read(imagePath, true)
@ -45,7 +45,7 @@ async function getExif(imagePath) {
return null return null
} }
let iptcData let iptcData = {}
try { try {
iptcData = await getIptc(imagePath) iptcData = await getIptc(imagePath)
} catch (error) { } catch (error) {
@ -115,5 +115,5 @@ if (isPhoto) {
fs.outputFile(file, newContents) fs.outputFile(file, newContents)
.then(() => fs.readFile(file, 'utf8')) .then(() => fs.readFile(file, 'utf8'))
.then(() => spinner.succeed(`New post '${title}' created.`)) .then(() => spinner.succeed(`New post '${title}' created.`))
.catch((err) => spinner.fail(`Error creating post: ${err}`)) .catch((err: Error) => spinner.fail(`Error creating post: ${err.message}`))
} }

View File

@ -3,6 +3,8 @@ declare module 'pigeon-marker'
declare module 'react-blockies' declare module 'react-blockies'
declare module 'remark-react' declare module 'remark-react'
declare module 'unified' declare module 'unified'
declare module 'fast-exif'
declare module 'node-iptc'
declare module 'ethereum-blockies' { declare module 'ethereum-blockies' {
export function toDataUrl(address: string): string export function toDataUrl(address: string): string

View File

@ -20,7 +20,7 @@
display: block; display: block;
flex: 1 1 20%; flex: 1 1 20%;
white-space: nowrap; white-space: nowrap;
padding: $spacer $spacer / 1.5; padding: $spacer;
border-bottom: 1px dashed $brand-grey-dimmed; border-bottom: 1px dashed $brand-grey-dimmed;
svg { svg {
@ -45,7 +45,6 @@
span { span {
border-left: 1px dashed $brand-grey-dimmed; border-left: 1px dashed $brand-grey-dimmed;
border-bottom: 0; border-bottom: 0;
padding: $spacer * 1.5 $spacer;
&, &,
&:first-child { &:first-child {

View File

@ -5,7 +5,7 @@
padding-left: 0.2rem; padding-left: 0.2rem;
padding-right: 0.2rem; padding-right: 0.2rem;
margin-top: $spacer / 2; margin-top: $spacer / 2;
margin-bottom: $spacer / 6; margin-bottom: 0;
font-size: $font-size-base; font-size: $font-size-base;
transition: color 0.2s ease-out; transition: color 0.2s ease-out;
} }

View File

@ -31,10 +31,12 @@ export const postTeaserQuery = graphql`
export default function PostTeaser({ export default function PostTeaser({
post, post,
toggleSearch toggleSearch,
hideDate
}: { }: {
post: Partial<Post> post: Partial<Post>
toggleSearch?: () => void toggleSearch?: () => void
hideDate?: boolean
}): ReactElement { }): ReactElement {
const { image, title, type, updated } = post.frontmatter const { image, title, type, updated } = post.frontmatter
const { slug, date } = post.fields const { slug, date } = post.fields
@ -57,7 +59,7 @@ export default function PostTeaser({
)} )}
<PostTitle slug={slug} title={title} className={styles.title} /> <PostTitle slug={slug} title={title} className={styles.title} />
{date && ( {date && !hideDate && (
<div className={styles.time}> <div className={styles.time}>
<Time date={date} /> <Time date={date} />
</div> </div>

View File

@ -13,5 +13,5 @@
} }
.posts h1 { .posts h1 {
font-size: $font-size-h3; font-size: $font-size-h4;
} }

View File

@ -59,8 +59,8 @@ export default function Post({
{type === 'photo' ? ( {type === 'photo' ? (
<> <>
<PostContent post={post} />
{image && image.fields && <Exif exif={image.fields.exif} />} {image && image.fields && <Exif exif={image.fields.exif} />}
<PostContent post={post} />
</> </>
) : ( ) : (
<PostContent post={post} /> <PostContent post={post} />

View File

@ -19,13 +19,13 @@
.articles { .articles {
@media (min-width: $screen-sm) { @media (min-width: $screen-sm) {
gap: $spacer * 2; gap: $spacer * 1.5;
grid-template-columns: repeat(2, 1fr); grid-template-columns: repeat(2, 1fr);
} }
} }
.articles:first-of-type h1 { .articles:first-of-type h1 {
font-size: $font-size-h3; font-size: $font-size-h4;
} }
.articlesLast { .articlesLast {

View File

@ -7,7 +7,7 @@ import { PhotoThumb } from '../components/templates/Photos'
import PostMore from '../components/templates/Post/More' import PostMore from '../components/templates/Post/More'
import styles from './index.module.scss' import styles from './index.module.scss'
export default function Home(props: PageProps): ReactElement { export default function Home({ data }: PageProps): ReactElement {
return ( return (
<> <>
<SEO /> <SEO />
@ -17,17 +17,17 @@ export default function Home(props: PageProps): ReactElement {
</h2> </h2>
<div className={styles.articles}> <div className={styles.articles}>
{(props.data as any).latestArticles.edges {(data as any).latestArticles.edges
.slice(0, 2) .slice(0, 2)
.map(({ node }: { node: Post }) => ( .map(({ node }: { node: Post }) => (
<PostTeaser key={node.id} post={node} /> <PostTeaser key={node.id} post={node} hideDate />
))} ))}
</div> </div>
<div className={`${styles.articles} ${styles.articlesLast}`}> <div className={`${styles.articles} ${styles.articlesLast}`}>
{(props.data as any).latestArticles.edges {(data as any).latestArticles.edges
.slice(2, 8) .slice(2, 8)
.map(({ node }: { node: Post }) => ( .map(({ node }: { node: Post }) => (
<PostTeaser key={node.id} post={node} /> <PostTeaser key={node.id} post={node} hideDate />
))} ))}
</div> </div>
</section> </section>
@ -38,11 +38,9 @@ export default function Home(props: PageProps): ReactElement {
</h2> </h2>
<div className={styles.photos}> <div className={styles.photos}>
{(props.data as any).latestPhotos.edges.map( {(data as any).latestPhotos.edges.map(({ node }: { node: Post }) => (
({ node }: { node: Post }) => ( <PhotoThumb key={node.id} photo={node} />
<PhotoThumb key={node.id} photo={node} /> ))}
)
)}
</div> </div>
</section> </section>
</> </>

View File

@ -13,5 +13,5 @@
"noImplicitAny": true "noImplicitAny": true
}, },
"exclude": ["node_modules", "public", ".cache", "*.js"], "exclude": ["node_modules", "public", ".cache", "*.js"],
"include": ["./src/**/*", "./jest/**/*"] "include": ["./src/**/*", "./scripts/*.ts", "./jest/**/*"]
} }