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

Add blog sections and components #104

Merged
merged 35 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
44d34fc
Add eslint rule to avoid underscored unused vars
calvellido Mar 17, 2023
914ffac
Split custom css in diverse files
calvellido Mar 17, 2023
18df3c0
Add html-react-parser to inject JSX from data file
calvellido Mar 17, 2023
fb9771a
Add new Banner component
calvellido Mar 17, 2023
54ce3af
Refactor and parametrize Hero component
calvellido Mar 17, 2023
2edd498
Refactor SimpleCard transforming it in LinkCard
calvellido Mar 17, 2023
a73f7d0
Improve BorderlessCard to have two behaviours
calvellido Mar 17, 2023
e791099
Add more params and conditions to ImageCard
calvellido Mar 17, 2023
1b899e2
Use parametrized Hero in index
calvellido Mar 17, 2023
d124dfa
Add Training page
calvellido Mar 17, 2023
2e3c94b
Add PartiallyOptional generic types
calvellido Mar 17, 2023
35c1a3a
Rename Projects section to Libraries
calvellido Mar 20, 2023
d97d8e1
Fix some typos on Training page
calvellido Mar 20, 2023
d8e536c
Add Libraries page
calvellido Mar 20, 2023
71f623e
Add support page
calvellido Mar 20, 2023
a07411e
Add Events page
calvellido Mar 20, 2023
2f3aad3
Merge branch 'main' into calvellido-training-page
calvellido Mar 20, 2023
49c8617
Fix gap property names
calvellido Mar 23, 2023
a1b69ca
Add some front matter to the current posts
calvellido Mar 23, 2023
4b9d65a
Swizzle Tag component
calvellido Mar 23, 2023
6c268a6
Create BlogListPage custom component
calvellido Mar 23, 2023
6439500
Create BlogTagsPostsPage custom component
calvellido Mar 23, 2023
3e8480d
Modify Docusaurus blog plugin config
calvellido Mar 23, 2023
8a198de
Swizzle BlogLayout component
calvellido Mar 23, 2023
88645f3
Swizzle BlogPostItem Header component
calvellido Mar 23, 2023
c6a250d
Swizzle BlogPostItem Header Author component
calvellido Mar 23, 2023
e1a0f1b
Create BlogPostItem Header Image custom component
calvellido Mar 23, 2023
82fd2e6
Create BlogPostItem Header Tags custom component
calvellido Mar 23, 2023
2c70c71
Swizzle BlogPostItem Footer component
calvellido Mar 23, 2023
33a5237
Refactor ImageCard to implement landscape mode
calvellido Mar 23, 2023
14a2ec8
Refactor Hero component improving responsive view
calvellido Mar 23, 2023
705fa78
General styling changes for the blog
calvellido Mar 23, 2023
0da5e89
Merge branch 'main' into calvellido-blog
calvellido Mar 23, 2023
523f786
Fix style for blog avatars photos spacing
calvellido Mar 23, 2023
00e02cb
Merge branch 'main' into calvellido-blog
calvellido Mar 24, 2023
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
1 change: 1 addition & 0 deletions content/blog/2019-05-28-first-blog-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ authors:
title: Docusaurus Core Team
url: https://github.com/wgao19
image_url: https://github.com/wgao19.png
image: https://docusaurus.io/img/docusaurus-social-card.jpg
tags: [hola, docusaurus]
---

Expand Down
1 change: 1 addition & 0 deletions content/blog/2019-05-29-long-blog-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
slug: long-blog-post
title: Long Blog Post
authors: endi
image: https://repository-images.githubusercontent.com/94911145/de889380-2905-11eb-9e9b-9332f0537e38
tags: [hello, docusaurus]
---

Expand Down
1 change: 1 addition & 0 deletions content/blog/2021-08-01-mdx-blog-post.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
slug: mdx-blog-post
title: MDX Blog Post
authors: [slorber]
image: https://docusaurus.io/img/docusaurus-social-card.jpg
tags: [docusaurus]
---

Expand Down
1 change: 1 addition & 0 deletions content/blog/2021-08-26-welcome/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
slug: welcome
title: Welcome
authors: [slorber, yangshun]
image: https://repository-images.githubusercontent.com/94911145/de889380-2905-11eb-9e9b-9332f0537e38
tags: [arrow-kt, hello, docusaurus]
---

Expand Down
13 changes: 10 additions & 3 deletions content/blog/2022-02-13-first-kotlin-blog-post.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
---
authors: vergauwen_simon
description: This is my first post on Docusaurus 2. And this is more text for the description. I just want this to be broken.
image: /img/sample-image.jpg
tags: [arrow, kotlin]
---

# My first Kotlin Blogpost

This document includes some code snippets and some other stuff.
Expand All @@ -6,7 +13,7 @@ and two ways you can get them to generate both the example **and** the test.

<!--- TEST_NAME BasicTest -->

# Verifying the output of System.out
## Verifying the output of System.out

We can quite simply verify the output of a snippet by writing a snippet like this,
and writing an accompanying text block with the output below.
Expand Down Expand Up @@ -41,7 +48,7 @@ Hello World 2!
```
<!--- TEST -->

# Verifying the output using custom logic
## Verifying the output using custom logic

We can also verify the output using custom logic, by specifying it inside of `TEST` directive.
This can be useful for asserting output that is very long, or non-deterministic.
Expand All @@ -59,7 +66,7 @@ suspend fun example() {
<!--- KNIT example-basic-03.kt -->
<!--- TEST lines.all { it.startsWith("DefaultDispatcher-worker") } && lines.size == 100 -->

# Verifying the snippet using assertions
## Verifying the snippet using assertions

And we can have a final example where we use assertions, instead of verifying the output.
We in this case add an import for `shouldBe`, and specify the `TEST assert` param.
Expand Down
8 changes: 7 additions & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ const createConfig = async () => {
path: 'content/blog',
routeBasePath: 'community/blog',
showReadingTime: true,
blogSidebarCount: 0,
blogListComponent: '@site/src/components/Blog/BlogListPage',
blogTagsPostsComponent:
'@site/src/components/Blog/BlogTagsPostsPage',
postsPerPage: 8,
archiveBasePath: null,
editUrl: 'https://github.com/arrow-kt/arrow-website/edit/main/',
},
theme: {
Expand Down Expand Up @@ -341,7 +347,7 @@ const createConfig = async () => {
postcssOptions.plugins.push(
// @ts-ignore
require('@csstools/postcss-global-data')({
files: ['./src/css/custom.css'],
files: ['./src/css/vars.css'],
}),
);
postcssOptions.plugins.push(require('postcss-custom-media'));
Expand Down
82 changes: 82 additions & 0 deletions src/components/Blog/BlogListPage/BlogListPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react';

import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
import {
PageMetadata,
HtmlClassNameProvider,
ThemeClassNames,
} from '@docusaurus/theme-common';
import Layout from '@theme/Layout';
import BlogListPaginator from '@theme/BlogListPaginator';
import SearchMetadata from '@theme/SearchMetadata';
import type { Props } from '@theme/BlogListPage';

import { Hero } from '@site/src/components/Hero';
import { ImageCard, ImageCardProps } from '@site/src/components/ImageCard';
import { Banner } from '@site/src/components/Banner';

import data from './blog-list-page.yml';
import styles from './blog-list-page.module.css';

function BlogListPageMetadata(props: Props): JSX.Element {
const { metadata } = props;
const {
siteConfig: { title: siteTitle },
} = useDocusaurusContext();
const { blogDescription, blogTitle, permalink } = metadata;
const isBlogOnlyMode = permalink === '/';
const title = isBlogOnlyMode ? siteTitle : blogTitle;
return (
<>
<PageMetadata title={title} description={blogDescription} />
<SearchMetadata tag="blog_posts_list" />
</>
);
}

function BlogListPageContent(props: Props): JSX.Element {
const { metadata, items } = props;

const posts = items.map((item) => ({
title: item.content.metadata.title,
subtitle: `${item.content.metadata.authors[0].name}, ${item.content.metadata.formattedDate}`,
image: item.content.frontMatter.image,
body: item.content.metadata.description,
href: item.content.metadata.permalink,
}));

return (
<Layout>
<Hero
title={data.hero.title}
subtitle={data.hero.subtitle}
ctaList={data.hero.ctaList}
className={styles.verticalRhythm}
/>
<main>
<section
className={`container ${styles.projectsContainer} ${styles.verticalRhythm}`}>
{posts.map((post: ImageCardProps) => (
<ImageCard key={post.title} {...post} />
))}
</section>
<section className={`container ${styles.verticalRhythm}`}>
<BlogListPaginator metadata={metadata} />
</section>
<section>
<Banner title={data.banner.title} ctaList={data.banner.ctaList} />
</section>
</main>
</Layout>
);
}

export default function BlogListPage(props: Props): JSX.Element {
return (
<HtmlClassNameProvider
className={`${ThemeClassNames.wrapper.blogPages} ${ThemeClassNames.page.blogListPage}`}>
<BlogListPageMetadata {...props} />
<BlogListPageContent {...props} />
</HtmlClassNameProvider>
);
}
9 changes: 9 additions & 0 deletions src/components/Blog/BlogListPage/blog-list-page.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.verticalRhythm {
margin-bottom: calc(2 * var(--ifm-spacing-vertical));
}

.projectsContainer {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
gap: var(--ifm-spacing-vertical) var(--ifm-spacing-horizontal);
}
12 changes: 12 additions & 0 deletions src/components/Blog/BlogListPage/blog-list-page.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
hero:
title: Blog
subtitle: Morbi ornare arcu massa, a sodales augue vulputate quis. Nunc faucibus lectus augue, posuere pulvina
ctaList:
- title: Learn about our courses
href: /learn/overview

banner:
title: Do you want to publish a new post?
ctaList:
- title: Contact us
href: /learn/overview
1 change: 1 addition & 0 deletions src/components/Blog/BlogListPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './BlogListPage';
108 changes: 108 additions & 0 deletions src/components/Blog/BlogTagsPostsPage/BlogTagsPostsPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
import React from 'react';

import { translate } from '@docusaurus/Translate';
import {
PageMetadata,
HtmlClassNameProvider,
ThemeClassNames,
usePluralForm,
} from '@docusaurus/theme-common';
import Layout from '@theme/Layout';
import BlogListPaginator from '@theme/BlogListPaginator';
import SearchMetadata from '@theme/SearchMetadata';
import type { Props } from '@theme/BlogTagsPostsPage';

import { Hero } from '@site/src/components/Hero';
import { ImageCard, ImageCardProps } from '@site/src/components/ImageCard';

import styles from './blog-tags-posts-page.module.css';

// Very simple pluralization: probably good enough for now
function useBlogPostsPlural() {
const { selectMessage } = usePluralForm();
return (count: number) =>
selectMessage(
count,
translate(
{
id: 'theme.blog.post.plurals',
description:
'Pluralized label for "{count} posts". Use as much plural forms (separated by "|") as your language support (see https://www.unicode.org/cldr/cldr-aux/charts/34/supplemental/language_plural_rules.html)',
message: 'One post|{count} posts',
},
{ count },
),
);
}

function useBlogTagsPostsPageTitle(tag: Props['tag']): string {
const blogPostsPlural = useBlogPostsPlural();
return translate(
{
id: 'theme.blog.tagTitle',
description: 'The title of the page for a blog tag',
message: '{nPosts} tagged with “{tagName}”',
},
{ nPosts: blogPostsPlural(tag.count), tagName: tag.label },
);
}

function BlogTagsPostsPageMetadata({ tag }: Props): JSX.Element {
const title = useBlogTagsPostsPageTitle(tag);
return (
<>
<PageMetadata title={title} />
<SearchMetadata tag="blog_tags_posts" />
</>
);
}

function BlogTagsPostsPageContent(props: Props): JSX.Element {
const { tag, listMetadata, items } = props;

const title = useBlogTagsPostsPageTitle(tag);
const cta = {
title: 'View All Tags',
href: tag.allTagsPath,
};

const posts = items.map((item) => ({
title: item.content.metadata.title,
subtitle: `${item.content.metadata.authors[0].name}, ${item.content.metadata.formattedDate}`,
image: item.content.frontMatter.image,
body: item.content.metadata.description,
href: item.content.metadata.permalink,
}));

return (
<Layout>
<Hero
title={tag.label}
subtitle={title}
ctaList={[cta]}
className={styles.verticalRhythm}
/>
<main>
<section
className={`container ${styles.projectsContainer} ${styles.verticalRhythm}`}>
{posts.map((post: ImageCardProps) => (
<ImageCard key={post.title} {...post} />
))}
</section>
<section className={`container ${styles.verticalRhythm}`}>
<BlogListPaginator metadata={listMetadata} />
</section>
</main>
</Layout>
);
}

export default function BlogTagsPostsPage(props: Props): JSX.Element {
return (
<HtmlClassNameProvider
className={`${ThemeClassNames.wrapper.blogPages} ${ThemeClassNames.page.blogTagPostListPage}`}>
<BlogTagsPostsPageMetadata {...props} />
<BlogTagsPostsPageContent {...props} />
</HtmlClassNameProvider>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.verticalRhythm {
margin-bottom: calc(2 * var(--ifm-spacing-vertical));
}

.projectsContainer {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
gap: var(--ifm-spacing-vertical) var(--ifm-spacing-horizontal);
}
1 change: 1 addition & 0 deletions src/components/Blog/BlogTagsPostsPage/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './BlogTagsPostsPage';
27 changes: 25 additions & 2 deletions src/components/Hero/hero.module.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
.hero {
position: relative;
z-index: 1;
}

.hero::before {
background-image: url('@site/static/img/arrow-brand-icon.svg');
background-repeat: no-repeat;
background-size: auto 150%;
background-position: max(-400px, calc(100vw - 3000px)) bottom;
z-index: 1;
width: 100%;
height: 100%;
content: '';
position: absolute;
left: 0;
pointer-events: none;
z-index: -1;
transition: opacity var(--ifm-transition-fast);
}

.hero::after {
Expand All @@ -17,9 +28,21 @@
position: absolute;
right: 0;
pointer-events: none;
z-index: -1;
z-index: -2;
transition: opacity var(--ifm-transition-fast);
}

@media (--ifm-narrow-window) {
.hero::before {
opacity: 0.1;
}

.hero::after {
opacity: 0.5;
}
}


.container {
max-width: 700px;
}
Expand Down
Loading