Skip to content

Commit ec565e2

Browse files
rajat1saxenaRajat
andauthored
Customizable slug for products and communities (#733)
* Editable slug for products and communities * Added docs * Added tests --------- Co-authored-by: Rajat <hi@rajatsaxena.dev>
1 parent 40fbe4c commit ec565e2

File tree

39 files changed

+1084
-287
lines changed

39 files changed

+1084
-287
lines changed
151 KB
Loading
166 KB
Loading
118 KB
Loading
155 KB
Loading

apps/docs/src/config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,10 @@ export const SIDEBAR: Sidebar = {
103103
],
104104
Website: [
105105
{ text: "Introduction", link: "en/website/introduction" },
106-
{ text: "Page blocks", link: "en/website/blocks" },
106+
{ text: "Create a page", link: "en/website/create-page" },
107+
{ text: "Sales pages", link: "en/website/sales-pages" },
107108
{ text: "Edit page", link: "en/website/edit" },
109+
{ text: "Page blocks", link: "en/website/blocks" },
108110
{ text: "Themes", link: "en/website/themes" },
109111
],
110112
Blog: [
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: Create a page
3+
description: Create a page
4+
layout: ../../../layouts/MainLayout.astro
5+
---
6+
7+
You can create custom pages in your CourseLit school. These pages can be used for various purposes, such as landing pages, email list builders, etc.
8+
9+
## Creating a page
10+
11+
1. Go to your school's dashboard and click on `Pages` in the left sidebar.
12+
2. Click on the `New page` button in the top right corner.
13+
3. On the `New page` screen, enter a name for your page. The slug will update automatically based on the name.
14+
4. Click on `Continue`.
15+
16+
![New page screen](/assets/pages/new-page-screen.png)
17+
18+
You will be taken to the [page builder](/en/website/edit) where you can start adding blocks to your page.
19+
20+
## Next step
21+
22+
[Learn about sales pages](/en/website/sales-pages).
23+
24+
## Stuck somewhere?
25+
26+
We are always here for you. Come chat with us in our <a href="https://discord.com/invite/GR4bQsN" target="_blank">Discord</a> channel or send a tweet at <a href="https://twitter.com/courselit" target="_blank">@CourseLit</a>.

apps/docs/src/pages/en/website/edit.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Before you can edit your page, you need to get to the page editor. Accessing the
3636

3737
Let's see how.
3838

39-
> All the edits you make to a page will be saved in a draft. In order to see the changes on a live page, you need to publish it. See the [publishing guide](#publish-page).
39+
> All the edits you make to a page will be saved in a draft. In order to see the changes on a live page, you need to publish it.
4040
4141
### To edit a website page
4242

@@ -95,7 +95,7 @@ Following are the step to delete a block.
9595

9696
## Next step
9797

98-
Explore all the blocks CourseLit has to offer.
98+
[Explore all the blocks CourseLit has to offer](/en/website/blocks).
9999

100100
## Stuck somewhere?
101101

apps/docs/src/pages/en/website/introduction.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,18 @@ description: Introduction to CourseLit's Build-in Website Builder
44
layout: ../../../layouts/MainLayout.astro
55
---
66

7-
CourseLit comes with a powerful website builder. Using the website builder, you can build all sorts of web pages for various use cases like landing pages, sales pages, email list builder etc.
7+
CourseLit comes with a powerful website builder. Using the website builder, you can build all sorts of web pages for various use cases like landing pages, [sales pages](/en/website/sales-pages), email list builder etc.
88

99
![CourseLit's Page builder](/assets/pages/page-builder-home.png)
1010

11+
## Understanding page URL
12+
13+
The page URL is structured as `/p/<slug>`.
14+
15+
## Understanding page slug
16+
17+
A slug is a unique identifier for your page. No two pages can have the same slug in a school. Hence, a slug is unique among product sales pages, community sales pages, and other custom pages you create.
18+
1119
## Default pages
1220

1321
When you create a new school, the following pages are automatically created for you.
@@ -20,21 +28,17 @@ This is your school's landing page hosted at `/`.
2028

2129
Your blog's homepage hosted at `/blog`. You can add additional blocks to the blog's home page.
2230

23-
2. Terms
31+
3. Terms
2432

2533
This is a page for hosting your terms and conditions for your school. This is hosted at `/terms`.
2634

27-
3. Privacy policy
35+
4. Privacy policy
2836

2937
This is a page for hosting the privacy policy for your school. This is hosted at `/privacy`.
3038

31-
## Sales pages
32-
33-
Each product that you create, gets its own sales page. This comes handy if you want to add additional information about your product for better conversion (and more sales).
34-
3539
## Next step
3640

37-
[Learn about page blocks](/en/website/blocks).
41+
[Learn how to create a page](/en/website/create-page).
3842

3943
## Stuck somewhere?
4044

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
title: Sales pages
3+
description: Introduction to CourseLit's Sales Pages
4+
layout: ../../../layouts/MainLayout.astro
5+
---
6+
7+
Every product and community that you create gets its own sales page. This comes in handy if you want to add additional information about your product for better conversion (and more sales).
8+
9+
## Sales page URL
10+
11+
If your product's title is `Demo Product`, the sales page's [slug](/en/website/introduction#understanding-page-slug) will be `demo-product` and the sales page's URL will be `/p/demo-product`.
12+
13+
## Obtaining a sales page's URL
14+
15+
Click on the **Share** icon next to your product/community's name in its dashboard to copy the sales page URL.
16+
17+
### Product's sales page URL
18+
19+
![Copy product's sales page URL](/assets/pages/product-copy-sales-page.png)
20+
21+
### Community's sales page URL
22+
23+
![Copy community's sales page URL](/assets/pages/community-copy-sales-page.png)
24+
25+
## Editing a product's sales page
26+
27+
1. Go to your products dashboard.
28+
29+
2. Select `Edit page` from the `Actions` dropdown. This will open up the [page builder](/en/website/edit).
30+
31+
3. Edit the page. You can add, remove, or reorder blocks as you like.
32+
33+
4. Hit `Publish` to make your changes visible on the public page. Before publishing, the changes are in draft mode and are only visible while editing.
34+
35+
## Editing a community's sales page
36+
37+
1. Go to your community's `Manage` section.
38+
39+
2. Click on the `Edit page` button. This will open up the [page builder](/en/website/edit).
40+
41+
3. Edit the page. You can add, remove, or reorder blocks as you like.
42+
43+
4. Hit `Publish` to make your changes visible on the public page. Before publishing, the changes are in draft mode and are only visible while editing.
44+
45+
### Changing the page slug
46+
47+
You can change the page slug for a product or community. It is located in the respective `Manage` sections, under the title.
48+
49+
![Edit page slug of community](/assets/pages/edit-page-slug.png)
50+
51+
## Next step
52+
53+
[Learn how to edit a page](/en/website/edit).
54+
55+
## Stuck somewhere?
56+
57+
We are always here for you. Come chat with us in our <a href="https://discord.com/invite/GR4bQsN" target="_blank">Discord</a> channel or send a tweet at <a href="https://twitter.com/courselit" target="_blank">@CourseLit</a>.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copies pageId to slug for all existing communities that don't have a slug.
3+
* Must run BEFORE deploying the new code, since `slug` is `required: true`
4+
* on the Community model.
5+
*
6+
* Usage: DB_CONNECTION_STRING=<mongodb-connection-string> node 24-02-26_00-00-copy-pageid-to-slug-communities.js
7+
*/
8+
import mongoose from "mongoose";
9+
10+
const DB_CONNECTION_STRING = process.env.DB_CONNECTION_STRING;
11+
if (!DB_CONNECTION_STRING) {
12+
throw new Error("DB_CONNECTION_STRING is not set");
13+
}
14+
15+
(async () => {
16+
try {
17+
await mongoose.connect(DB_CONNECTION_STRING);
18+
const db = mongoose.connection.db;
19+
if (!db) throw new Error("Could not connect to database");
20+
21+
const result = await db.collection("communities").updateMany(
22+
{ slug: { $exists: false } },
23+
[{ $set: { slug: "$pageId" } }], // aggregation pipeline: copy field value
24+
);
25+
26+
console.log(
27+
`✅ Updated ${result.modifiedCount} communities: copied pageId → slug`,
28+
);
29+
} finally {
30+
await mongoose.connection.close();
31+
}
32+
})();

0 commit comments

Comments
 (0)