Skip to content

Commit

Permalink
Add shorthand for Starlight templates to create astro
Browse files Browse the repository at this point in the history
  • Loading branch information
delucis committed Aug 8, 2023
1 parent 4d160fa commit a93af6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/dry-pandas-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Add support for more Starlight templates
7 changes: 6 additions & 1 deletion packages/create-astro/src/actions/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ const FILES_TO_UPDATE = {
};

function getTemplateTarget(tmpl: string, ref = 'latest') {
if (tmpl === 'starlight') tmpl = 'starlight/basics';
const starlightMatches = tmpl.match(/^starlight\/(.+)$/);
if (starlightMatches) {
const [, starter] = starlightMatches;
return `withastro/starlight/examples/${starter}`;
}
const isThirdParty = tmpl.includes('/');
if (isThirdParty) return tmpl;
if (tmpl === 'starlight') return `withastro/starlight/examples/basics`;
return `github:withastro/astro/examples/${tmpl}#${ref}`;
}

Expand Down

0 comments on commit a93af6b

Please sign in to comment.