This Gist is used in the Astro Embed documentation.
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
| // Fetch all themes from the Astro theme API. | |
| const allThemes = await fetch('https://portal.astro.build/api/themes').then((res) => res.json()); | |
| // Fetch all themes tagged as using Tailwind from the Astro theme API. | |
| const tailwindThemes = await fetch( | |
| 'https://portal.astro.build/api/themes?technology%5B%5D=tailwind' | |
| ).then((res) => res.json()); | |
| // Filter out themes using Tailwind from the list of all themes. | |
| const themesWithoutTailwind = allThemes.filter( | |
| (theme) => | |
| // Check that Tailwind isn’t mentioned in the theme’s description or body. |
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
| /** | |
| * Simple observable value store. | |
| * @template {any} T | |
| * @param {T | Promise<T>} initial | |
| */ | |
| export function Store(initial) { | |
| /** @type {Set<(newValue: T) => void>} */ | |
| const subscribers = new Set(); | |
| const store = { value: Promise.resolve(initial) }; | |
| return { |
This script is a quick way to migrate existing Astro-flavoured Markdown pages in an Astro project to MDX pages.
It does the following:
- Loads all
*.mdfiles in yoursrc/pages/directory - Parses each page’s frontmatter
- Moves the contents of
setupin frontmatter into the main file body as required for imports in MDX - Writes the updated contents of each page to the same location but as
.mdxinstead of.md - Deletes the original
.mdfile
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
| /** | |
| * Get a list of the moves that are currently available to a specific player. | |
| * | |
| * @param {import("boardgame.io").Game} game boardgame.io game object | |
| * @param {import("boardgame.io").Ctx} ctx current game context object | |
| * @param {import("boardgame.io").PlayerID} playerID the ID of the player to get moves for | |
| * @returns {string[]} an array of move names | |
| * | |
| * @example | |
| * const game = { |
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
| const plugin = require('tailwindcss/plugin'); | |
| const BevelPlugin = plugin(function bevelPlugin({ addUtilities, e }) { | |
| const base = 0.5; | |
| const absoluteSizes = Object.entries({ | |
| md: 1.5, | |
| lg: 2, | |
| xl: 3, | |
| '2xl': 4, |
You can extend a boardgame.io storage adapter to add custom functionality.
This example wraps the original setState method to accomplish some other task
when the game is over — in this case posting the game logs elsewhere via a
hypothetical dumpEndOfGameLog function.
(The example uses the FlatFile storage class, but should work with any other
boardgame.io storage class.)
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
| /** | |
| * Delete all (or some of) the scrobbles on a Last.fm library page | |
| * (e.g. https://www.last.fm/user/USERNAME/library) | |
| * | |
| * @param {Number} [count=0] Number of scrobbles on page to delete | |
| * @param {Number} [start=0] Index to start deleting from | |
| * | |
| * @example | |
| * // delete first 20 scrobbles on page | |
| * deleteScrobbles(20) |
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
| // ES7 with async/await and Promise.all | |
| async function loopIt(array) { | |
| await Promise.all(array.map(async member => { | |
| // asyncStuff() will be called in parallel for all array members | |
| let result = await asyncStuff(member) | |
| })) | |
| } |
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
| shasum -a 256 name-of-your-file | awk '{printf $1}' | pbcopy |
NewerOlder