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

Latestblog #201

Open
wants to merge 5 commits into
base: main
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
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Labs

Labs is the monorepo codebase for Leaning Technologies developer sites. It contains technical writing (documentation and blog posts) for Cheerp, CheerpJ, CheerpX and other projects.

Visit our sites:

- [Labs](https://labs.leaningtech.com/)
- [Cheerp.io](https://cheerp.io/)
- [CheerpX.io](https://cheerpx.io/)
- [CheerpJ.com](https://cheerpj.com/)

# Running locally

## Setup

Make sure you have [Node.js](https://nodejs.org/en/download/package-manager) and [pnpm](https://pnpm.io/installation) installed.

## Clone this repository

```shell
git clone https://github.com/leaningtech/labs.git
```

## Install dependencies

```shell
cd labs
pnpm install
```

## Run a site

The sites under this repository must be run individually. Pick a site you want to run, for example [Cheerp.io](https://cheerp.io/):

```shell
cd /sites/cheerp
pnpm start
```

# Contributing

For more information about contributing, please [visit this page](https://labs.leaningtech.com/docs/contributing)
11 changes: 10 additions & 1 deletion packages/astro-theme/components/BlogPostCard.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { getEntry, type CollectionEntry } from "astro:content";
import FormattedDate from "./FormattedDate.astro";
import { resolveAuthors } from "../lib/blog";
import { Image } from "astro:assets";
import { productFromUrl } from "../lib/products";

const product = productFromUrl(Astro.url);

interface Props {
post: CollectionEntry<"blog"> | CollectionEntry<"blog">["slug"];
Expand All @@ -16,6 +19,9 @@ const post =
? await getEntry("blog", postOrSlug)
: postOrSlug;
const authors = await resolveAuthors(post.data.authors);

//choose hover link color based on product
const productName = typeof product === "undefined" ? "Labs" : product.name;
---

<a
Expand All @@ -35,7 +41,10 @@ const authors = await resolveAuthors(post.data.authors);
}
<h3
class:list={{
"font-bold text-balance text-white group-hover:text-primary-400 grow": true,
"font-bold text-balance text-white grow": true,
"group-hover:text-cheerp grow": productName === "Cheerp",
"group-hover:text-[#6386a5] grow": productName === "CheerpX",
"group-hover:text-primary-400 grow": productName === "Labs",
"text-2xl leading-7": size === "wide",
"text-xl leading-6": size === "narrow",
}}
Expand Down
12 changes: 10 additions & 2 deletions packages/astro-theme/components/BlogPostCardSet.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import { getCollection, type CollectionEntry } from "astro:content";
import BlogPostCard from "./BlogPostCard.astro";
import { productFromUrl } from "../lib/products";

interface Props {
// Only show posts if they have at least one of these tags
Expand All @@ -11,6 +12,8 @@ interface Props {
}

const { tags, exclude } = Astro.props;
const product = productFromUrl(Astro.url);
const productName = typeof product === "undefined" ? "Labs" : product.name;

function sortCalc(post: CollectionEntry<"blog">): number {
let relevancy =
Expand All @@ -25,10 +28,15 @@ function sortCalc(post: CollectionEntry<"blog">): number {

const posts = (
await getCollection("blog", (post) => {
if (post.data.draft || exclude?.includes(post.id)) {
if (
post.data.draft ||
exclude?.includes(post.id) ||
!(post.data?.tags?.includes(productName) || productName === "Labs")
) {
return false;
} else {
return true;
}
return true;
})
)
.sort((a, b) => sortCalc(b) - sortCalc(a))
Expand Down
18 changes: 18 additions & 0 deletions sites/cheerp/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import IconLayers from "../assets/layers.png";
import DrawingSourcerer from "../assets/sourcerer.png";
import { Image } from "astro:assets";
import { DISCORD_URL } from "@leaningtech/astro-theme/consts";
import BlogPostCardSet from "@leaningtech/astro-theme/components/BlogPostCardSet.astro";
---

<ProductHome style="w-full pt-8 bg-gradient-to-b from-stone-900 to-cheerp">
Expand Down Expand Up @@ -181,6 +182,23 @@ import { DISCORD_URL } from "@leaningtech/astro-theme/consts";
</div>
</div>
</section>
<section class="bg-stone-900 py-16">
<div class="px-4 sm:p-8 md:px-16 lg:px-32 xl:px-56 2xl:px-60">
<div class="mb-8">
<p class="text-lg text-stone-400">Cheerp blog</p>
<h2 class="text-4xl font-bold text-white">Latest news</h2>
</div>
<BlogPostCardSet />
<div class="mt-8">
<LinkButton
type="secondary-cheerp"
href="/blog"
label="View all blog posts"
iconRight="mi:arrow-right"
/>
</div>
</div>
</section>
<section
class="bg-gradient-to-b from-stone-900 to-[#474484] pb-48 text-center pb-28 md:px-8 md:pt-16 lg:px-32 lg:pt-32 xl:pt-42 xl:px-28 2xl:px-60 2xl:pt-60"
>
Expand Down
18 changes: 18 additions & 0 deletions sites/cheerpx/src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Screenshot from "../assets/screenshots.png";
import { Image } from "astro:assets";
import { DISCORD_URL } from "@leaningtech/astro-theme/consts";
import MonitorDoodle from "../assets/hero_illustration.png";
import BlogPostCardSet from "@leaningtech/astro-theme/components/BlogPostCardSet.astro";
---

<ProductHome style="w-full pt-8 bg-gradient-to-b from-stone-900 to-[#00254d]">
Expand Down Expand Up @@ -213,6 +214,23 @@ import MonitorDoodle from "../assets/hero_illustration.png";
</div>
</div>
</section>
<section class="bg-black py-16">
<div class="px-4 sm:p-8 md:px-16 lg:px-32 xl:px-56 2xl:px-60">
<div class="mb-8">
<p class="text-lg text-stone-400">CheerpX blog</p>
<h2 class="text-4xl font-bold text-white">Latest news</h2>
</div>
<BlogPostCardSet />
<div class="mt-8">
<LinkButton
type="secondary-cheerpx"
href="/blog"
label="View all blog posts"
iconRight="mi:arrow-right"
/>
</div>
</div>
</section>
<section
class="bg-gradient-to-b from-black to-[#00254d] pb-48 text-center pb-28 md:px-8 md:pt-16 lg:px-32 pt-12 lg:pt-32 xl:pt-42 xl:px-28 2xl:px-60 2xl:pt-60"
>
Expand Down
Loading