Skip to content

Commit

Permalink
#11 Implements ArticlePreview component
Browse files Browse the repository at this point in the history
  • Loading branch information
raeperd authored Jan 9, 2022
1 parent 9d961ce commit 911f682
Show file tree
Hide file tree
Showing 22 changed files with 14,035 additions and 6,941 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
- name: Build
run: |
npm install
npm run test
npm run build
npm run export
touch ./out/.nojekyll
Expand Down
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ yarn-error.log*
.vercel

# content
content/Private
content/.obsidian
content/Daily
lib/content/Private
lib/content/.obsidian
lib/content/Daily

# idea
.idea
Expand Down
12 changes: 12 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// jest.config.js
// eslint-disable-next-line @typescript-eslint/no-var-requires
const nextJest = require('next/jest')

const createJestConfig = nextJest({ dir: './' })

const customJestConfig = {
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
}

module.exports = createJestConfig(customJestConfig)
47 changes: 0 additions & 47 deletions lib/api.ts

This file was deleted.

8 changes: 8 additions & 0 deletions lib/article.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getAllArticles } from './article';

test('getAllArticles', () => {
const articles = getAllArticles()
expect(articles).toHaveLength(5)

expect(articles[0].title?.length).toBeGreaterThanOrEqual(0)
})
34 changes: 34 additions & 0 deletions lib/article.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { join } from 'path';
import { readdirSync, readFileSync, statSync } from 'fs';
import matter from 'gray-matter';

const ARTICLE_DIRECTORY = join(process.cwd(), 'lib', 'content', 'article')

export function getAllArticles(): Article[] {
return readdirSync(ARTICLE_DIRECTORY)
.filter((file) => !file.startsWith('_'))
.map((file) => readArticleSync(file))
}

function readArticleSync(file: string): Article {
const filePath = join(ARTICLE_DIRECTORY, file)
const fileContent = readFileSync(filePath, 'utf8')
const { data, content } = matter(fileContent)
return {
slug: file.replace(/\.md$/, ''),
title: data.title,
date: data.date
? data.date.toDateString()
: statSync(filePath).birthtime.toDateString(),
tags: data.tags ? data.tags : [],
content,
}
}

export interface Article {
slug: string,
title?: string,
date: string,
tags: string[],
content: string
}
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
@@ -1,12 +1,12 @@
+++
author = "lee.so"
title = "Emoji Support"
date = "2019-03-05"
description = "Guide to emoji usage in Hugo"
tags = [
---
author : lee.so
title : Emoji Support
date : 2019-03-05
description : Guide to emoji usage in Hugo
tags : [
"emoji",
]
+++
---

Emoji can be enabled in a Hugo project in a number of ways.
<!--more-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
+++
author = "lee.so"
title = "Markdown Syntax Guide"
date = "2019-03-11"
description = "Sample article showcasing basic Markdown syntax and formatting for HTML elements."
tags = [
---
author : lee.so
title : Markdown Syntax Guide
date : 2019-03-11
description : Sample article showcasing basic Markdown syntax and formatting for HTML elements.
tags : [
"markdown",
"css",
"html",
]
categories = [
categories : [
"themes",
"syntax",
]
series = ["Themes Guide"]
aliases = ["migrate-from-jekyl"]
+++
series : ["Themes Guide"]
aliases : ["migrate-from-jekyl"]
---

This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.
<!--more-->
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
+++
author = "lee.so"
title = "Placeholder Text"
date = "2019-03-09"
description = "Lorem Ipsum Dolor Si Amet"
tags = [
---
author: lee.so
title: Placeholder Text
date: 2019-03-09
description: Lorem Ipsum Dolor Si Amet
tags: [
"markdown",
"text",
]
+++
---

Lorem est tota propiore conpellat pectoribus de pectora summo. <!--more-->Redit teque digerit hominumque toris verebor lumina non cervice subde tollit usus habet Arctonque, furores quas nec ferunt. Quoque montibus nunc caluere tempus inhospita parcite confusaque translucet patri vestro qui optatis lumine cognoscere flos nubis! Fronde ipsamque patulos Dryopen deorum.

Expand All @@ -19,7 +19,7 @@ Lorem est tota propiore conpellat pectoribus de pectora summo. <!--more-->Redit
Rursus nulli murmur; hastile inridet ut ab gravi sententia! Nomine potitus silentia flumen, sustinet placuit petis in dilapsa erat sunt. Atria tractus malis.

1. Comas hunc haec pietate fetum procerum dixit
2. Post torum vates letum Tiresia
2. Article torum vates letum Tiresia
3. Flumen querellas
4. Arcanaque montibus omnes
5. Quidem et
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
+++
author = "lee.so"
title = "Rich Content"
date = "2019-03-10"
description = "A brief description of Hugo Shortcodes"
tags = [
---
author : lee.so
title : Rich Content
date : 2019-03-10
description : A brief description of Hugo Shortcodes
tags : [
"shortcodes",
"privacy",
]
+++
---

Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-management/shortcodes/#use-hugos-built-in-shortcodes) for rich content, along with a [Privacy Config](https://gohugo.io/about/hugo-and-gdpr/) and a set of Simple Shortcodes that enable static and no-JS versions of various social media embeds.
<!--more-->
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 911f682

Please sign in to comment.