Last active
October 4, 2025 18:18
-
-
Save reatlat/61759cbec52fbfe779c39fa8fd9a09e6 to your computer and use it in GitHub Desktop.
Placeholder gist for the FreshJuice GitHub Gist module demo page. Demo here: https://demo.freshjuice.dev/modules/code-snippet-github-gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Code Snippet (GitHub Gist) by FreshJuice 🍊 | |
| function hello(name = 'world') { | |
| const msg = `Hello, ${name}!`; | |
| console.log(msg); | |
| return msg; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // region: header | |
| const API = '/v1'; | |
| function get(u){ return fetch(API + u).then(r=>r.json()); } | |
| // endregion | |
| // region: main | |
| export async function loadUser(id){ | |
| const profile = await get(`/users/${id}`); | |
| const posts = await get(`/users/${id}/posts`); | |
| return { profile, posts }; | |
| } | |
| // endregion | |
| // region: footer | |
| console.log('ready'); | |
| // endregion |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // visually distinct demo | |
| export const box = (text='Fresh & Clean') => `[ ${text} ]`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tiny util | |
| export const sum = (a, b) => a + b; | |
| // usage example: | |
| console.log(sum(2, 3)); // 5 | |
| // edge case: | |
| console.log(sum(-1, 1)); // 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Theme demo | |
| * Try data-theme="system" | "light" | "dark" | |
| */ | |
| export const demo = (theme='system') => `Theme: ${theme}`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment