-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
136 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#logos { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
html[data-theme="dark"] .logo-dark, | ||
html[data-theme="light"] .logo-light { | ||
display: none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react' | ||
import Link from '@docusaurus/Link' | ||
import styles from './RecentPosts.module.css' | ||
|
||
// Quick & dirty hack to get list of blog posts | ||
// (the "proper" way would be a custom plugin) | ||
import BlogPosts from "../../.docusaurus/docusaurus-plugin-content-blog/default/blog-post-list-prop-default.json" | ||
|
||
function getPostDate(permalink) { | ||
const matches = permalink.match(/\d{4}\/\d{2}\/\d{2}/g); | ||
if (matches.length === 1) { | ||
const matchDate = new Date(matches[0]); | ||
return matchDate.toLocaleString('en-us', | ||
{ month: 'short', year: 'numeric' }) | ||
} else { | ||
return null | ||
} | ||
} | ||
|
||
function BlogDate({ date }) { | ||
return (<span className={styles.date}> | ||
{date} | ||
</span>) | ||
} | ||
|
||
function BlogList() { | ||
const posts = BlogPosts.items; | ||
return (<div className={styles.bloglist}> | ||
{posts | ||
.filter(({ unlisted }) => !unlisted) | ||
.slice(0, 3) | ||
.map(({ title, permalink }) => { | ||
const date = getPostDate(permalink); | ||
return (<li key={permalink} className={styles.post}> | ||
{date && <BlogDate date={date} />} | ||
<Link to={permalink} style={{ textDecoration: "none" }}> | ||
{title} | ||
</Link> | ||
</li>) | ||
} | ||
)} | ||
|
||
</div>) | ||
} | ||
|
||
|
||
|
||
export default function RecentPosts() { | ||
return (<div> | ||
<h3>Read the latest blog posts</h3> | ||
<BlogList /> | ||
<Link to="blog"> | ||
More posts | ||
</Link> | ||
</div>) | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.bloglist { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: left; | ||
gap: .3em; | ||
width: 100%; | ||
padding-bottom: .5em; | ||
} | ||
|
||
|
||
.date { | ||
opacity: 70%; | ||
text-align: right; | ||
} | ||
|
||
.post { | ||
max-width: 60ch; | ||
padding-bottom: .3em; | ||
display: grid; | ||
grid-template-columns: 10ch 1fr; | ||
justify-content: left; | ||
column-gap: 1ch; | ||
width: 100%; | ||
list-style-type: none; | ||
text-align: left; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters