Add shorthand for Starlight templates to create astro (#7993)

* Add shorthand for Starlight templates to `create astro`

* Update packages/create-astro/src/actions/template.ts

* Update packages/create-astro/src/actions/template.ts

---------

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
This commit is contained in:
Chris Swithinbank 2023-08-08 19:08:46 +02:00 committed by GitHub
parent 4d160fa1e2
commit 315d58f27b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'create-astro': patch
---
Add support for more Starlight templates

View file

@ -67,9 +67,12 @@ const FILES_TO_UPDATE = {
};
function getTemplateTarget(tmpl: string, ref = 'latest') {
if (tmpl.startsWith('starlight')) {
const [, starter = 'basics'] = tmpl.split('/');
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}`;
}