From 0d5168b10ecbd40245c0de83afec84d6e2f6f8e6 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 2 Jun 2023 12:09:47 -0500 Subject: [PATCH 1/2] feat(create-astro): add starlight as template alias --- .changeset/chilled-insects-melt.md | 5 +++++ packages/create-astro/src/actions/template.ts | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 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..33a8b7881a92 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'; - const isThirdParty = tmpl.includes('/'); +function getTemplateTarget(template: string, ref: string = 'latest') { + const isThirdParty = template.includes('/'); + if (isThirdParty) return template; + if (template === 'starlight') return `withastro/starlight/examples/basics`; + return `github:withastro/astro/examples/${template}#${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) { From 2cc4af352936ce0788f69747ab404c8131096431 Mon Sep 17 00:00:00 2001 From: Nate Moore Date: Fri, 2 Jun 2023 12:13:44 -0500 Subject: [PATCH 2/2] chore: lint --- packages/create-astro/src/actions/template.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts index 33a8b7881a92..85b7d6f27b31 100644 --- a/packages/create-astro/src/actions/template.ts +++ b/packages/create-astro/src/actions/template.ts @@ -68,11 +68,11 @@ const FILES_TO_UPDATE = { }), }; -function getTemplateTarget(template: string, ref: string = 'latest') { - const isThirdParty = template.includes('/'); - if (isThirdParty) return template; - if (template === 'starlight') return `withastro/starlight/examples/basics`; - return `github:withastro/astro/examples/${template}#${ref}`; +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}`; } export default async function copyTemplate(tmpl: string, ctx: Context) {