Skip to content

Commit

Permalink
Add 'starlight' as template alias (#7277)
Browse files Browse the repository at this point in the history
* feat(create-astro): add starlight as template alias

* chore: lint
  • Loading branch information
natemoo-re authored Jun 2, 2023
1 parent c64dfdd commit 229affc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-insects-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'create-astro': patch
---

Add `starlight` template alias
10 changes: 7 additions & 3 deletions packages/create-astro/src/actions/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 229affc

Please sign in to comment.