From 229affca405ce77bf80bcea6a91891f689a3161b Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 2 Jun 2023 12:56:25 -0500 Subject: [PATCH] Add 'starlight' as template alias (#7277) * feat(create-astro): add starlight as template alias * chore: lint --- .changeset/chilled-insects-melt.md | 5 +++++ packages/create-astro/src/actions/template.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/chilled-insects-melt.md diff --git a/.changeset/chilled-insects-melt.md b/.changeset/chilled-insects-melt.md new file mode 100644 index 000000000000..27e8c7fe5f82 --- /dev/null +++ b/.changeset/chilled-insects-melt.md @@ -0,0 +1,5 @@ +--- +'create-astro': patch +--- + +Add `starlight` template alias diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts index aa0363694862..85b7d6f27b31 100644 --- a/packages/create-astro/src/actions/template.ts +++ b/packages/create-astro/src/actions/template.ts @@ -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) {