Add 'starlight' as template alias (#7277)

* feat(create-astro): add starlight as template alias

* chore: lint
This commit is contained in:
Nate Moore 2023-06-02 12:56:25 -05:00 committed by GitHub
parent c64dfdd3d8
commit 229affca40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'create-astro': patch
---
Add `starlight` template alias

View file

@ -68,11 +68,15 @@ const FILES_TO_UPDATE = {
}),
};
export default async function copyTemplate(tmpl: string, ctx: Context) {
const ref = ctx.ref || 'latest';
function getTemplateTarget(tmpl: string, ref = 'latest') {
const isThirdParty = tmpl.includes('/');
if (isThirdParty) return tmpl;
if (tmpl === 'starlight') return `withastro/starlight/examples/basics`;
return `github:withastro/astro/examples/${tmpl}#${ref}`;
}
const templateTarget = isThirdParty ? tmpl : `github:withastro/astro/examples/${tmpl}#${ref}`;
export default async function copyTemplate(tmpl: string, ctx: Context) {
const templateTarget = getTemplateTarget(tmpl, ctx.ref);
// Copy
if (!ctx.dryRun) {