Skip to content

Instantly share code, notes, and snippets.

@reatlat
Last active October 4, 2025 18:18
Show Gist options
  • Select an option

  • Save reatlat/61759cbec52fbfe779c39fa8fd9a09e6 to your computer and use it in GitHub Desktop.

Select an option

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
// Code Snippet (GitHub Gist) by FreshJuice 🍊
function hello(name = 'world') {
const msg = `Hello, ${name}!`;
console.log(msg);
return msg;
}
// 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
// visually distinct demo
export const box = (text='Fresh & Clean') => `[ ${text} ]`;
// 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
/**
* 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