Skip to content

Commit 333e537

Browse files
hmd-aliwiktoriavh
andauthored
feat: add /guides command and ability to sync all guides to a discord channel (#7)
* 🔨 refactor: Adjust "tailwind with vite" command title and file name * 🌟 feat: guides - add vue guide * 🌟 feat: guides - add accessibility guide * 🌟 feat: guides - add backend guide * 🌟 feat: guides - add css guide * 🌟 feat: guides - add frontend guide * 🌟 feat: guides - add javascript guide * 🌟 feat: add `guides-tracker.json` to gitignore * 🌟 feat: add new env vars * 🌟 feat: implement guide synchronization and management functionality * 🤖 ci: add GUIDES_CHANNEL_ID and GUIDES_TRACKER_PATH to deployment environment * 📚 docs: move guides docs to the docs folder --------- Co-authored-by: Wiktoria Van Harneveldt <w.dev+git@mailbox.org>
1 parent ee65b16 commit 333e537

File tree

16 files changed

+412
-14
lines changed

16 files changed

+412
-14
lines changed

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
DISCORD_TOKEN="" # Your bot token
22
CLIENT_ID="" # Your bot's application ID
3+
GUIDES_CHANNEL_ID="" # The ID of the channel where guides will be posted

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,7 @@ yarn-error.log*
1515
!.env.example
1616
.env
1717
.env.local
18-
.env.*.local
18+
.env.*.local
19+
20+
# guides tracker
21+
guides-tracker.json

docs/GUIDE_SYNC.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Guide Synchronization System
2+
3+
The bot automatically synchronizes guide markdown files from `src/commands/guides/subjects/` to a Discord channel when it starts up.
4+
5+
## Setup
6+
7+
Add to your `.env.local` file:
8+
```
9+
GUIDES_CHANNEL_ID=1234567890123456789
10+
```
11+
12+
## Commands
13+
14+
- `npm run sync-guides` - Manual sync (updates only changed guides)
15+
- `npm run sync-guides:init` - Force sync (posts all guides fresh)
16+
17+
## Guide Format
18+
19+
Guides need frontmatter with a `name` field:
20+
21+
```markdown
22+
---
23+
name: JavaScript
24+
---
25+
26+
Your guide content here...
27+
```

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"test": "pnpm run build:dev && node --test dist/**/*.test.js",
2121
"test:ci": "node --test dist/**/*.test.js",
2222
"prepare": "husky",
23-
"pre-commit": "lint-staged"
23+
"pre-commit": "lint-staged",
24+
"sync-guides": "tsx scripts/sync-guides.js",
25+
"sync-guides:init": "tsx scripts/sync-guides.js --initialize"
2426
},
2527
"keywords": [],
2628
"author": "",

scripts/sync-guides.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Standalone script for synchronizing guides to Discord channel
5+
* Usage: npm run sync-guides [--initialize]
6+
*/
7+
8+
import { Client, GatewayIntentBits } from 'discord.js';
9+
import { config } from '../src/env.js';
10+
import { syncGuidesToChannel, initializeGuidesChannel } from '../src/util/post-guides.js';
11+
12+
async function main() {
13+
const args = process.argv.slice(2);
14+
const shouldInitialize = args.includes('--initialize');
15+
16+
if (!config.guides.channelId) {
17+
console.error('❌ GUIDES_CHANNEL_ID environment variable is required');
18+
console.error('Please set it in your environment variables');
19+
process.exit(1);
20+
}
21+
22+
console.log(`🤖 Starting Discord client for guide sync...`);
23+
24+
const client = new Client({
25+
intents: [
26+
GatewayIntentBits.Guilds,
27+
GatewayIntentBits.GuildMessages,
28+
],
29+
});
30+
31+
try {
32+
await client.login(config.discord.token);
33+
console.log(`✅ Logged in as ${client.user?.tag}`);
34+
35+
if (shouldInitialize) {
36+
console.log('🚀 Initializing guides channel (will post all guides fresh)...');
37+
await initializeGuidesChannel(client, config.guides.channelId);
38+
} else {
39+
console.log('🔄 Synchronizing guides...');
40+
await syncGuidesToChannel(client, config.guides.channelId);
41+
}
42+
43+
console.log('✅ Guide synchronization completed successfully');
44+
} catch (error) {
45+
console.error('❌ Guide synchronization failed:', error);
46+
process.exit(1);
47+
} finally {
48+
await client.destroy();
49+
console.log('👋 Discord client disconnected');
50+
}
51+
}
52+
53+
main().catch((error) => {
54+
console.error('❌ Unexpected error:', error);
55+
process.exit(1);
56+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
name: Accessibility (A11y)
3+
---
4+
5+
Improve your web accessibility skills with these valuable free resources:
6+
7+
**Reference & Guidelines**
8+
- [**MDN Web Accessibility**](<https://developer.mozilla.org/en-US/docs/Learn/Accessibility>) - Comprehensive guides and best practices.
9+
- [**WAI (Web Accessibility Initiative)**](<https://www.w3.org/WAI/>) - Official guidelines and resources for web accessibility.
10+
- [**a11y Project**](<https://www.a11yproject.com/>) - Community-driven resources and checklists.
11+
- [**WebAIM**](<https://webaim.org/>) - Articles, tools, and training on web accessibility.
12+
- [**web.dev Accessibility**](<https://web.dev/accessibility/>) - Tutorials and best practices for building accessible web experiences.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Backend Development
3+
---
4+
5+
Boost your backend development skills with these top free resources:
6+
7+
**Structured Learning Paths**
8+
- [**Roadmap**](<https://roadmap.sh/backend>) - A comprehensive guide to backend technologies and concepts.
9+
10+
**Backends**
11+
- SQLlite (recommended) - Lightweight, disk-based database.
12+
- PostgreSQL (recommended) - Advanced, open-source relational database.
13+
- Mongodb (only pick if you have to.) - NoSQL database for flexible, JSON-like documents.
14+
- Redis - In-memory data structure store, used as a database, cache, and message broker.
15+
16+
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
---
2-
name: Css
2+
name: CSS
33
---
44

5-
CSS can be tricky to get right, especially with the various browsers and their quirks. Here are some common issues and solutions:
6-
1. **Box Model Issues**: Ensure you understand the CSS box model (content, padding, border, margin). Use `box-sizing: border-box;` to make width and height include padding and border.
7-
2. **Specificity Problems**: If your styles aren't applying, check the specificity of your selectors. More specific selectors override less specific ones.
8-
3. **Flexbox and Grid Layouts**: These modern layout systems can be complex. Make sure to understand their properties and how they interact.
5+
Level up your CSS skills with these free and practical resources:
6+
7+
**Reference & Guides**
8+
- [**MDN**](<https://developer.mozilla.org/en-US/docs/Web/CSS>) - Comprehensive CSS documentation.
9+
- [**web.dev**](<https://web.dev/css>) - Modern CSS best practices and tutorials.
10+
- [**CSS Tricks**](<https://css-tricks.com/category/articles/>) - Tips, tricks, and in-depth articles.
11+
12+
**Interactive Learning**
13+
- [**CSS Grid Garden**](<https://cssgridgarden.com/>) - Master CSS Grid with fun exercises.
14+
- [**Flexbox Froggy**](<https://flexboxfroggy.com/>) - Learn Flexbox by solving interactive challenges.
15+
- [**A Complete Guide to Flexbox**](<https://css-tricks.com/snippets/css/a-guide-to-flexbox/>) - Detailed reference and examples.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Frontend Development
3+
---
4+
5+
Sharpen your frontend skills with these curated free resources:
6+
7+
**Structured Learning Paths**
8+
- [**The Odin Project**](<https://www.theodinproject.com/paths/foundations/courses/foundations>) - A full curriculum from basics to projects.
9+
- [**Roadmap**](<https://roadmap.sh/frontend>) - Step-by-step guide of what to learn next in frontend development.
10+
11+
**Practice & Challenges**
12+
- [**Frontend Mentor**](<https://www.frontendmentor.io/>) - Build real projects and improve your coding skills.
13+
14+
**Reference & Guides**
15+
- [**JavaScript Info**](<https://javascript.info/>) - Deep dive into JavaScript concepts and examples.
16+
- [**CSS Tricks**](<https://css-tricks.com/>) - Tips, tricks, and guides for CSS and modern layouts.
17+
- [**MDN Web Docs**](<https://developer.mozilla.org/en-US/curriculum/>) - Comprehensive reference for HTML, CSS, and JS.
18+

src/commands/guides/subjects/html.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)