aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorflu0r1ne <flu0r1ne@flu0r1ne.net>2021-07-21 04:42:31 -0500
committerflu0r1ne <flu0r1ne@flu0r1ne.net>2021-07-21 04:42:58 -0500
commite424680fc013c291bd7eea4dc63b96401e5126a8 (patch)
treeb39227c50b2c365c49694fa4f86b2630d428ebc2
parent437268370661087dbe31323efb18dfe1a518da33 (diff)
downloadhomepage-e424680fc013c291bd7eea4dc63b96401e5126a8.tar.xz
homepage-e424680fc013c291bd7eea4dc63b96401e5126a8.zip
Added a timestamp and sorts posts by timestamp
-rw-r--r--components/Breadcrumbs/breadcrumbs.module.scss2
-rw-r--r--components/Breadcrumbs/index.tsx4
-rw-r--r--pages/logs/[directory].tsx4
-rw-r--r--pages/logs/index.module.scss12
-rw-r--r--pages/logs/index.tsx12
-rw-r--r--pages/logs/logs.md2
-rw-r--r--posts/cgit-nginx-ubuntu/meta.json3
-rw-r--r--posts/packaging-nebula-for-debian/meta.json3
-rw-r--r--templates/Default/default.module.scss13
-rw-r--r--templates/Default/index.tsx8
-rw-r--r--utils/Posts.tsx16
11 files changed, 63 insertions, 16 deletions
diff --git a/components/Breadcrumbs/breadcrumbs.module.scss b/components/Breadcrumbs/breadcrumbs.module.scss
index 104eec2..6facea4 100644
--- a/components/Breadcrumbs/breadcrumbs.module.scss
+++ b/components/Breadcrumbs/breadcrumbs.module.scss
@@ -12,4 +12,4 @@
.divider {
margin: 0 0.3rem;
-} \ No newline at end of file
+}
diff --git a/components/Breadcrumbs/index.tsx b/components/Breadcrumbs/index.tsx
index ed650e3..c5a17b8 100644
--- a/components/Breadcrumbs/index.tsx
+++ b/components/Breadcrumbs/index.tsx
@@ -9,7 +9,7 @@ export type BreadcrumbsProps = {
};
const Breadcrumbs : FC<BreadcrumbsProps> = ({children, className, ...props}) => (
- <div className={clsx(styles.breadcrumbs, className)} {...props}>
+ <span className={clsx(styles.breadcrumbs, className)} {...props}>
{Children.map(children, (child, index) => {
return (
<>
@@ -22,7 +22,7 @@ const Breadcrumbs : FC<BreadcrumbsProps> = ({children, className, ...props}) =>
</>
);
})}
- </div>
+ </span>
);
const Crumb : FC = ({children, ...props}) => (
diff --git a/pages/logs/[directory].tsx b/pages/logs/[directory].tsx
index 00fe78d..c3760f7 100644
--- a/pages/logs/[directory].tsx
+++ b/pages/logs/[directory].tsx
@@ -1,4 +1,3 @@
-import path from 'path';
import { GetStaticProps, GetStaticPropsContext } from 'next';
import React, { FC } from 'react';
import { getPosts, getMarkdown, Post, getPostFromDirectory } from '../../utils/Posts';
@@ -11,10 +10,13 @@ interface Props {
}
const Page : FC<Props> = ({ post, markdown }) => {
+ const { lastUpdated } = post.meta;
+
return (
<>
<DefaultPage
path={"/logs/" + post.directory}
+ lastUpdated={lastUpdated}
>
<Markdown
md={markdown}
diff --git a/pages/logs/index.module.scss b/pages/logs/index.module.scss
new file mode 100644
index 0000000..7e79afe
--- /dev/null
+++ b/pages/logs/index.module.scss
@@ -0,0 +1,12 @@
+.logList {
+ margin-top: 1em;
+
+ li {
+ line-height: 1.15;
+ margin-left: 1em;
+ margin-top: 0.3em;
+ list-style-image: none;
+ list-style-position: outside;
+ list-style-type: disc;
+ }
+} \ No newline at end of file
diff --git a/pages/logs/index.tsx b/pages/logs/index.tsx
index ed3c58b..fa74aa4 100644
--- a/pages/logs/index.tsx
+++ b/pages/logs/index.tsx
@@ -1,24 +1,26 @@
import DefaultPage from '../../templates/Default';
import Markdown from '../../components/Markdown';
+import styles from './index.module.scss';
import { GetStaticProps, GetStaticPropsContext } from 'next';
import React, { FC } from 'react';
-import { getPosts, getMetadata, Post, PostMetadata } from '../../utils/Posts';
-//@ts-ignore
+import { getPosts, Post } from '../../utils/Posts';
+// @ts-ignore
import md from './logs.md';
-
interface Props {
posts: Post[]
};
const Logs : FC<Props> = ({ posts }) => {
- console.log(posts);
+
+
return(
<DefaultPage
path={"/logs"}
>
- <ul>
+ <Markdown md={md} />
+ <ul className={styles.logList}>
{
posts.map(({ directory, meta }) => (
<li><a href={'/logs/' + directory}>{meta.name}</a></li>
diff --git a/pages/logs/logs.md b/pages/logs/logs.md
index 5515287..c177646 100644
--- a/pages/logs/logs.md
+++ b/pages/logs/logs.md
@@ -2,5 +2,3 @@
Eclectic thoughts, miscellany, and discursive drivel
-- [Packaging Nebula for Debian](/logs/packaging-nebula-for-debian)
-- [Installing cGit behind NGINX on Ubuntu](/logs/cgit-nginx-ubuntu)
diff --git a/posts/cgit-nginx-ubuntu/meta.json b/posts/cgit-nginx-ubuntu/meta.json
index 81968b4..1a800fa 100644
--- a/posts/cgit-nginx-ubuntu/meta.json
+++ b/posts/cgit-nginx-ubuntu/meta.json
@@ -1,3 +1,4 @@
{
- "name": "Installing cGit behind NGINX on Ubuntu"
+ "name": "Installing cGit behind NGINX on Ubuntu",
+ "lastUpdated": "2021-07-17"
} \ No newline at end of file
diff --git a/posts/packaging-nebula-for-debian/meta.json b/posts/packaging-nebula-for-debian/meta.json
index 2e4895c..1f8f362 100644
--- a/posts/packaging-nebula-for-debian/meta.json
+++ b/posts/packaging-nebula-for-debian/meta.json
@@ -1,3 +1,4 @@
{
- "name": "Packaging Nebula for Debian"
+ "name": "Packaging Nebula for Debian",
+ "lastUpdated": "2021-07-19"
} \ No newline at end of file
diff --git a/templates/Default/default.module.scss b/templates/Default/default.module.scss
index ba6096f..7dd99c5 100644
--- a/templates/Default/default.module.scss
+++ b/templates/Default/default.module.scss
@@ -1,4 +1,17 @@
.viewportOverrides {
margin-top: 4em;
margin-bottom: 3em;
+}
+
+.date {
+ margin-top: 0.5em;
+ padding: 0.1em 0.2em;
+ display: block;
+}
+
+@media screen and (min-width: 1000px) {
+ .date {
+ float: right;
+ padding: 0.1em 0.2em;
+ }
} \ No newline at end of file
diff --git a/templates/Default/index.tsx b/templates/Default/index.tsx
index 8902bf8..f693da2 100644
--- a/templates/Default/index.tsx
+++ b/templates/Default/index.tsx
@@ -7,6 +7,7 @@ import styles from './default.module.scss';
export type DefaultPage = {
className?: string;
path?: string;
+ lastUpdated?: string;
};
export type RelPathProps = {
@@ -37,11 +38,16 @@ const RelPath : FC<RelPathProps> = ({path, ...props}) => {
);
}
-const DefaultPage : FC<DefaultPage> = ({className, children, path, ...props}) => (
+const LastUpdatedDate : FC = ({children}) => (
+ <span className={styles.date}><b>Last Updated: </b>{children}</span>
+)
+
+const DefaultPage : FC<DefaultPage> = ({className, lastUpdated, children, path, ...props}) => (
<Viewport
className={clsx(styles.viewportOverrides, className)}
>
{path !== undefined ? <RelPath path={path!} /> : undefined}
+ {lastUpdated ? <LastUpdatedDate>{lastUpdated}</LastUpdatedDate> : undefined}
{children}
</Viewport>
);
diff --git a/utils/Posts.tsx b/utils/Posts.tsx
index d82467e..2a69629 100644
--- a/utils/Posts.tsx
+++ b/utils/Posts.tsx
@@ -7,6 +7,7 @@ marked.setOptions(markedOptions);
interface PostMetadata {
name: string;
+ lastUpdated: string;
}
interface Post {
@@ -45,9 +46,20 @@ async function getPostFromDirectory(directory : string) {
async function getPosts() : Promise<Post[]> {
const directories = await fs.readdir(POST_PATH);
- const posts = directories.map(getPostFromDirectory);
+ const posts = await Promise.all(directories.map(getPostFromDirectory));
- return await Promise.all(posts);
+ return posts.sort((post_a, post_b) => {
+ const a = new Date(post_a.meta.lastUpdated);
+ const b = new Date(post_b.meta.lastUpdated);
+
+ if(a === b)
+ return 0;
+
+ if(a > b)
+ return -1;
+
+ return 1;
+ });
}
async function getMarkdown(post : Post) : Promise<string> {