From a93af6b2d0a0ce80dd919a86bf2af0b1d1df32a9 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Tue, 8 Aug 2023 11:07:54 +0200 Subject: [PATCH] Add shorthand for Starlight templates to `create astro` --- .changeset/dry-pandas-flash.md | 5 +++++ packages/create-astro/src/actions/template.ts | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 .changeset/dry-pandas-flash.md diff --git a/.changeset/dry-pandas-flash.md b/.changeset/dry-pandas-flash.md new file mode 100644 index 000000000000..fb18de65dbe1 --- /dev/null +++ b/.changeset/dry-pandas-flash.md @@ -0,0 +1,5 @@ +--- +'create-astro': patch +--- + +Add support for more Starlight templates diff --git a/packages/create-astro/src/actions/template.ts b/packages/create-astro/src/actions/template.ts index f762b264f7c4..360dc758b7f6 100644 --- a/packages/create-astro/src/actions/template.ts +++ b/packages/create-astro/src/actions/template.ts @@ -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}`; }