Skip to content

Commit

Permalink
feat(create-astro): add starlight as template alias
Browse files Browse the repository at this point in the history
  • Loading branch information
natemoo-re committed Jun 2, 2023
1 parent c64dfdd commit 0d5168b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 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
12 changes: 8 additions & 4 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';
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) {
Expand Down

0 comments on commit 0d5168b

Please sign in to comment.