Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: homepage blog posts #428

Open
wants to merge 3 commits into
base: astro-docs
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/components/NucleusBlogPostCard.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
const { article } = Astro.props;
const imageURL = article["preview_image"];
---

<div class="card">
<div class=".media">
<img src={imageURL} />
</div>
<div class="body">
<div class="blog-heading">
<a href={article.link}>
<h3>{article.title}</h3>
</a>
</div>
<div class="blog-subheading">
<p>{article.subtitle}...</p>
</div>
<div class="blog-publised-date">

</div>
</div>
</div>

<style>
.card {
margin-block-start: 0;
border-radius: 0.5rem;
overflow: clip;
background-color: var(--sl-color-gray-7);
box-shadow: 0 0 0 1px var(--sl-color-gray-6);
transition: box-shadow 0.25s ease-in-out;

.media {
aspect-ratio: 16 / 9;
overflow: clip;
}

.body {
margin-block-start: 0;
padding-block-start: 1rem;
padding-block-end: 1rem;
padding-inline-start: 1rem;
padding-inline-end: 1rem;

h3 {
font-size: var(--sl-text-h4);
font-weight: 500;
color: var(--sl-color-gray-3);
}

p {
margin-block-start: 1rem;
font-size: var(--sl-text-base);
color: var(--sl-color-gray-3);
}
}
}
</style>
25 changes: 25 additions & 0 deletions src/components/NucleusBlogsLayout.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
import { blogArticles } from '@scripts/blog';
import NucleusBlogPostCard from './NucleusBlogPostCard.astro';

const blogs = await blogArticles();
---
<div class="blog not-content">
<NucleusBlogPostCard article={blogs[0]}/>
<NucleusBlogPostCard article={blogs[3]}/>
<NucleusBlogPostCard article={blogs[5]}/>
<NucleusBlogPostCard article={blogs[7]}/>
</div>

<style>
.blog {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1.5rem;
padding-block-start: 2rem;

@media (width >= 50rem) {
grid-template-columns: repeat(4, 1fr);
}
}
</style>
44 changes: 2 additions & 42 deletions src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ hero:

import SignPost from '@components/SignPost.astro';
import HeroAction from '@components/HeroAction.astro';
import NucleusBlogsLayout from '@components/NucleusBlogsLayout.astro';
import { CardGrid } from '@astrojs/starlight/components';

<CardGrid>
Expand Down Expand Up @@ -75,48 +76,7 @@ import { CardGrid } from '@astrojs/starlight/components';

## Latest Nucleus blog articles

<div class="blog" role="list">
<div class="card" role="listitem">
<div class="media">
<img src="https://blog.nucleus.design/a11y-colours-in-design-systems/a11ycolours.jpg" alt="Using accessible colours in a design system" />
</div>
<div class="body">
<h3><a href="https://blog.nucleus.design/a11y-colours-in-design-systems/">Using accessible colours in a design system</a></h3>
<p>Why it is important and how to make it work.</p>
<p>7 July 2023</p>
</div>
</div>
<div class="card" role="listitem">
<div class="media">
<img src="https://blog.nucleus.design/be-aware-of-css-custom-properties/css-custom-properties.jpg" alt="Exposing the problem with CSS custom properties in a Design System." />
</div>
<div class="body">
<h3><a href="https://blog.nucleus.design/be-aware-of-css-custom-properties/">Be aware of using CSS custom properties</a></h3>
<p>Exposing the problem with CSS custom properties in a Design System.</p>
<p>1 December 2022</p>
</div>
</div>
<div class="card" role="listitem">
<div class="media">
<img src="https://blog.nucleus.design/creating-the-nucleus-logo/nucleus-logo-drafting.jpg" alt="Drafting the new Nucleus logo" />
</div>
<div class="body">
<h3><a href="https://blog.nucleus.design/creating-the-nucleus-logo/">Creating the Nucleus logo</a></h3>
<p>How we created our logo and why we needed to.</p>
<p>29 April 2022</p>
</div>
</div>
<div class="card" role="listitem">
<div class="media">
<img src="https://blog.nucleus.design/creating-a-new-sketch-library-for-nucleus/box-of-chocolates.jpg" alt="A selection of chocolates used as a metaphor for components." />
</div>
<div class="body">
<h3><a href="https://blog.nucleus.design/creating-a-new-sketch-library-for-nucleus/">Creating a new Sketch library for Nucleus</a></h3>
<p>Understanding the requirements of UX designers.</p>
<p>4 March 2022</p>
</div>
</div>
</div>
<NucleusBlogsLayout />

<footer class="endpage">
</footer>
7 changes: 7 additions & 0 deletions src/scripts/blog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const blogArticles = async () => {
return fetch('https://feature-posts-api.nucleus-blog.pages.dev/articles.json')
.then((response) => response.json())
.then(response => response.articles);
};

export { blogArticles };
43 changes: 0 additions & 43 deletions src/styles/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -367,50 +367,7 @@ main {
}
}

.blog {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 1.5rem;
padding-block-start: 2rem;

@media (width >= 50rem) {
grid-template-columns: repeat(4, 1fr);
}

.card {
margin-block-start: 0;
border-radius: 0.5rem;
overflow: clip;
background-color: var(--sl-color-gray-7);
box-shadow: 0 0 0 1px var(--sl-color-gray-6);
transition: box-shadow 0.25s ease-in-out;

.media {
aspect-ratio: 16 / 9;
overflow: clip;
}

.body {
margin-block-start: 0;
padding-block-start: 1rem;
padding-block-end: 1rem;
padding-inline-start: 1rem;
padding-inline-end: 1rem;

h3 {
font-size: var(--sl-text-h4);
font-weight: 500;
color: var(--sl-color-gray-3);
}

p {
margin-block-start: 1rem;
font-size: var(--sl-text-base);
color: var(--sl-color-gray-3);
}
}
}
}

.endpage {
margin-top: 0;
Expand Down