-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UPDATE: Delete guides, add Card Componennt with astro-icons, cleanup …
…command.
- Loading branch information
1 parent
a392534
commit 339783a
Showing
25 changed files
with
217 additions
and
1,347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
const fs = require('fs').promises; | ||
const path = require('path'); | ||
const kleur = require('kleur'); | ||
|
||
const apiPath = path.join(__dirname, '..', 'src', 'content', 'docs', 'api'); | ||
const guidePath = path.join(__dirname, '..', 'src', 'content', 'docs', 'guides'); | ||
async function deleteComponents(folderPath) { | ||
try { | ||
const files = await fs.readdir(folderPath); | ||
|
||
for (const file of files) { | ||
const filePath = path.join(folderPath, file); | ||
const extname = path.extname(filePath); | ||
|
||
if (extname === '.mdx') { | ||
await fs.unlink(filePath); | ||
console.log(kleur.red(`Deleted: ${filePath}`)); | ||
} | ||
} | ||
|
||
console.log(kleur.green('Deleted all .mdx files in the api folder.')); | ||
} catch (error) { | ||
console.error(kleur.red(`Error deleting .mdx files: ${error.message}`)); | ||
} | ||
} | ||
|
||
|
||
// Recursive function to delete all index.mdx files in a folder and its subfolders | ||
async function deleteGuides(folderPath) { | ||
try { | ||
const files = await fs.readdir(folderPath); | ||
|
||
for (const file of files) { | ||
const filePath = path.join(folderPath, file); | ||
const isDirectory = (await fs.stat(filePath)).isDirectory(); | ||
|
||
if (isDirectory) { | ||
// Recursively call the function for subfolders | ||
await deleteGuides(filePath); | ||
} else { | ||
const extname = path.extname(filePath); | ||
|
||
if (extname === '.mdx' && file.toLowerCase() === 'index.mdx') { | ||
// Delete the index.mdx file | ||
await fs.unlink(filePath); | ||
console.log(kleur.green(`Deleted: ${filePath}`)); | ||
} | ||
} | ||
} | ||
} catch (error) { | ||
console.error(kleur.red(`Error deleting Guide index files: ${error.message}`)); | ||
} | ||
} | ||
|
||
// Specify the root folder path | ||
const rootPath = path.join(__dirname, '..', 'src', 'content', 'docs', 'guides'); | ||
|
||
// Call the function to delete index.mdx files | ||
deleteComponents(apiPath); | ||
deleteGuides(guidePath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
import type { Props } from "@astrojs/starlight/props"; | ||
import { Icon } from 'astro-icon' | ||
const { icon, title } = Astro.props; | ||
--- | ||
|
||
<article class="card sl-flex"> | ||
<p class="title sl-flex"> | ||
{icon &&<Icon name={icon} class="icon" size="1.333em" />} | ||
<span set:html={title} /> | ||
</p> | ||
<div class="body"><slot /></div> | ||
</article> | ||
|
||
<style> | ||
.card { | ||
--sl-card-border: var(--sl-color-purple); | ||
--sl-card-bg: var(--sl-color-purple-low); | ||
border: 1px solid var(--sl-color-gray-5); | ||
background-color: var(--sl-color-black); | ||
padding: clamp(1rem, calc(0.125rem + 3vw), 2.5rem); | ||
flex-direction: column; | ||
gap: clamp(0.5rem, calc(0.125rem + 1vw), 1rem); | ||
} | ||
.card:nth-child(4n + 1) { | ||
--sl-card-border: var(--sl-color-orange); | ||
--sl-card-bg: var(--sl-color-orange-low); | ||
} | ||
.card:nth-child(4n + 3) { | ||
--sl-card-border: var(--sl-color-green); | ||
--sl-card-bg: var(--sl-color-green-low); | ||
} | ||
.card:nth-child(4n + 4) { | ||
--sl-card-border: var(--sl-color-red); | ||
--sl-card-bg: var(--sl-color-red-low); | ||
} | ||
.card:nth-child(4n + 5) { | ||
--sl-card-border: var(--sl-color-blue); | ||
--sl-card-bg: var(--sl-color-blue-low); | ||
} | ||
.title { | ||
font-weight: 600; | ||
font-size: var(--sl-text-h4); | ||
color: var(--sl-color-white); | ||
line-height: var(--sl-line-height-headings); | ||
gap: 1rem; | ||
align-items: center; | ||
} | ||
.card .icon { | ||
border: 1px solid var(--sl-card-border); | ||
background-color: var(--sl-card-bg); | ||
padding: 0.2em; | ||
border-radius: 0.25rem; | ||
} | ||
.card .body { | ||
margin: 0; | ||
font-size: clamp(var(--sl-text-sm), calc(0.5rem + 1vw), var(--sl-text-body)); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.