Skip to content

Commit fde1d97

Browse files
committed
Init
0 parents  commit fde1d97

File tree

162 files changed

+15290
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

162 files changed

+15290
-0
lines changed

.env.example

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
NEXT_PUBLIC_STRAPI_API_URL=https://your.herokuapp.com
2+
NEXT_PUBLIC_ASSETS_DOMAIN=example-s3-bucket.com
3+
NEXT_PUBLIC_APP_HOST=http://localhost:3000
4+
NEXT_PUBLIC_MARKETING_HOST=https://june.so

.eslintrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"rules": {
3+
"react/react-in-jsx-scope": 0,
4+
"jsx-a11y/anchor-is-valid": 0
5+
},
6+
"extends": ["react-app", "prettier"]
7+
}

.gitignore

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
############################
2+
# OS X
3+
############################
4+
5+
.DS_Store
6+
.AppleDouble
7+
.LSOverride
8+
.Spotlight-V100
9+
.Trashes
10+
._*
11+
12+
13+
############################
14+
# Linux
15+
############################
16+
17+
*~
18+
19+
20+
############################
21+
# Windows
22+
############################
23+
24+
Thumbs.db
25+
ehthumbs.db
26+
Desktop.ini
27+
$RECYCLE.BIN/
28+
*.cab
29+
*.msi
30+
*.msm
31+
*.msp
32+
.env
33+
34+
35+
############################
36+
# Packages
37+
############################
38+
39+
*.7z
40+
*.csv
41+
*.dat
42+
*.dmg
43+
*.gz
44+
*.iso
45+
*.jar
46+
*.rar
47+
*.tar
48+
*.com
49+
*.class
50+
*.dll
51+
*.exe
52+
*.o
53+
*.seed
54+
*.so
55+
*.swo
56+
*.swp
57+
*.swn
58+
*.swm
59+
*.out
60+
*.pid
61+
62+
63+
############################
64+
# Logs and databases
65+
############################
66+
67+
.tmp
68+
*.log
69+
*.sql
70+
*.sqlite
71+
*.sqlite3
72+
73+
74+
############################
75+
# Misc.
76+
############################
77+
78+
*#
79+
ssl
80+
.idea
81+
nbproject
82+
public/uploads/*
83+
!public/uploads/.gitkeep
84+
85+
############################
86+
# Node.js
87+
############################
88+
89+
lib-cov
90+
lcov.info
91+
pids
92+
logs
93+
results
94+
node_modules
95+
.node_history
96+
97+
98+
############################
99+
# Tests
100+
############################
101+
102+
testApp
103+
coverage
104+
105+
############################
106+
# Strapi
107+
############################
108+
109+
exports
110+
.cache
111+
build
112+
113+
# Custom
114+
115+
.vscode
116+
.next
117+
.env.*
118+
!.env.example
119+
120+
frontend/out/*

.node-version

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12.19.0

.prettierrc

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"arrowParens": "always",
3+
"bracketSpacing": true,
4+
"singleAttributePerLine": false,
5+
"bracketSameLine": false,
6+
"jsxSingleQuote": false,
7+
"printWidth": 100,
8+
"proseWrap": "preserve",
9+
"quoteProps": "as-needed",
10+
"semi": true,
11+
"singleQuote": false,
12+
"tabWidth": 2,
13+
"trailingComma": "es5",
14+
"useTabs": false
15+
}

README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Weekly Changelog Blog
2+
3+
Set-up a blog and share what you ship as easy as 1-2-3!
4+
5+
![screenshot](/changelog.png)
6+
7+
A Next.js blog starter project built with MDX and Chakra UI. Fully-customizable and open source, so don't hesitate to add new features and report bugs!
8+
9+
## Features
10+
11+
- A stylish changelog
12+
- Celebrate your team's achievements - with team credits on each post
13+
- Easy-to-use admin panel
14+
15+
## Getting started
16+
17+
The easiest way to try this starter is to run it locally on your computer.
18+
19+
First, you'll need to create your own copy of this starter. You can do so by clicking the ["Use this template"](https://github.com/ferrucc-io/weekly-changelog/generate) button on GitHub and filling out the [form](https://docs.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template).
20+
21+
Once you've cloned the repository, make sure you're in the `frontend` directory:
22+
23+
```bash
24+
cd frontend
25+
```
26+
27+
Install dependencies and start the Next.js server:
28+
29+
```bash
30+
# Using yarn
31+
yarn install
32+
yarn dev
33+
34+
# Using npm
35+
npm install
36+
npm run dev
37+
```
38+
39+
If you want to change the default environment variables, create a `.env.local` file like this:
40+
41+
```
42+
cp .env.local.example .env.local
43+
```
44+
45+
## Routes
46+
47+
- `/pages/:pageNumber` - displays paginated articles
48+
- `/` - redirects to `/pages/0`
49+
- `/changelogs/:id` - displays one article
50+
51+
## File structure
52+
53+
```bash
54+
frontend
55+
├─ bin # Scripts
56+
├─ components # Reusable components
57+
│ ├─ core
58+
│ ├─ mdx-layout.tsx
59+
│ └─ ...
60+
├─ lib # Types, theme, utilities, services
61+
├─ pages
62+
│ ├─ changelogs # MDX articles
63+
│ ├─ page
64+
│ │ └─ [page].tsx # Paginated articles
65+
│ ├─ _app.tsx
66+
│ └─ _middleware.ts
67+
└─ ...
68+
```
69+
70+
## Writing articles
71+
72+
To write a new blog post, create a new `.mdx` file in the `/pages/changelogs` directory.
73+
74+
### Anatomy of an MDX article
75+
76+
MDX is a superset of markdown that lets you write JSX directly in your markdown files. It is a powerful way to add dynamic interactivity, and embed components within your content, helping you to bring your pages to life.
77+
78+
![mdx-preview](/mdx-preview.png)
79+
80+
Learn more 👉 [Next.js: Using MDX](https://nextjs.org/docs/advanced-features/using-mdx), [Using MDX](https://mdxjs.com/docs/using-mdx/)
81+
82+
## Branding customization
83+
84+
Most of the branding elements can be found in `<Navbar>` and `<Footer>` components. To customize these components, update the code in these directories:
85+
86+
- [`frontend/components/core/navbar/index.tsx`](https://github.com/juneHQ/weekly-changelog/tree/master/frontend/components/core/navbar)
87+
- [`frontend/components/core/footer/index.tsx`](https://github.com/juneHQ/weekly-changelog/tree/master/frontend/components/core/footer)

bin/package.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "bin",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "strapi-to-mdx.mjs",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"start": "node strapi-to-mdx.mjs"
9+
},
10+
"author": "",
11+
"license": "ISC",
12+
"dependencies": {
13+
"axios": "^1.2.1"
14+
}
15+
}

bin/strapi-to-mdx.mjs

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
import axios from "axios";
2+
import { exec } from "child_process";
3+
import fs from "fs";
4+
5+
export const MDX_OUTPUT_FOLDER = `../pages/changelogs`; // in relative path
6+
7+
/**
8+
* Fetches articles from strapi and converts them to MDX files
9+
*
10+
* Usage:
11+
* ```bash
12+
* # Run the following in the terminal
13+
* cd bin && node strapi-to-mdx.mjs
14+
* ```
15+
*/
16+
async function strapiToMdx() {
17+
const response = await axios.get(
18+
"https://content.june.so/articles?status=published&_sort=publishedAt:DESC"
19+
);
20+
21+
if (response.status === 200) {
22+
const articles = response.data;
23+
24+
const promises = articles.map((article) => {
25+
const meta = {
26+
slug: article.slug,
27+
publishedAt: article.publishedAt,
28+
title: article.title,
29+
headerImage: article.image.url,
30+
authors: article.authors.map((author) => ({
31+
name: author.name,
32+
description: author.bio,
33+
avatarUrl: author.picture.url,
34+
})),
35+
};
36+
37+
const content = [
38+
'import { MdxLayout } from "components/mdx-layout.tsx";',
39+
"",
40+
`export const meta = ${JSON.stringify(meta)}`,
41+
"",
42+
];
43+
44+
const markdown = article.content.replace(/<br>/gi, "");
45+
content.push(markdown);
46+
content.push("");
47+
content.push(
48+
"export default ({ children, ...rest }) => <MdxLayout meta={meta} {...rest}>{children}</MdxLayout>;"
49+
);
50+
content.push("");
51+
52+
if (!fs.existsSync(MDX_OUTPUT_FOLDER)) {
53+
fs.mkdirSync(MDX_OUTPUT_FOLDER);
54+
}
55+
56+
const outputPath = `${MDX_OUTPUT_FOLDER}/${article.slug}.mdx`;
57+
58+
return new Promise((resolve, reject) => {
59+
fs.writeFile(outputPath, content.join("\n"), (error) => {
60+
if (error) {
61+
reject(`Failed to write ${article.slug} - ${error}`);
62+
} else {
63+
resolve(`Written ${article.slug}`);
64+
}
65+
});
66+
});
67+
});
68+
69+
const results = await Promise.allSettled(promises);
70+
results.forEach((result) => {
71+
console.log(`${result.status} - ${result.value}`);
72+
});
73+
console.log("\nDone!");
74+
console.log("\nFormatting result with prettier...");
75+
exec(`npx prettier --write ${MDX_OUTPUT_FOLDER}`, (error, stdout, stderr) => {
76+
console.log(stdout);
77+
});
78+
}
79+
}
80+
81+
strapiToMdx();

0 commit comments

Comments
 (0)