Skip to content

Instantly share code, notes, and snippets.

@delucis
Created November 5, 2024 15:34
Show Gist options
  • Save delucis/388af9ee3d707552f4ff09663ccbdebe to your computer and use it in GitHub Desktop.
Save delucis/388af9ee3d707552f4ff09663ccbdebe to your computer and use it in GitHub Desktop.
Find themes in the Astro themes catalogue that maybe don’t use Tailwind
// 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.
!/tailwind/i.test(theme.Theme.description) &&
!/tailwind/i.test(theme.Theme.body) &&
// Check that the theme is not included in the list of themes tagged as using Tailwind.
!tailwindThemes.find((tailwindTheme) => theme.Theme.id === tailwindTheme.Theme.id)
);
// Generate a Markdown list of themes with a small thumbnail image and links to the theme.
const summaries = themesWithoutTailwind.map(({ Theme }) => {
let summary = `- [<img src="${Theme.image}" alt="" width="100"> ${Theme.title}](https://astro.build/themes/details/${Theme.slug})`;
const links = [];
if (Theme.repoUrl) links.push(`[source code](${Theme.repoUrl})`);
if (Theme.demoUrl) links.push(`[view demo](${Theme.demoUrl})`);
if (Theme.buyUrl) links.push(`[buy theme](${Theme.buyUrl})`);
if (links.length) summary += ' — ' + links.join(' / ');
return summary;
});
console.log(summaries.join('\n'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment