forked from twbs/bootstrap
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation of ScssDocs.astro (#19)
- Loading branch information
1 parent
a93e888
commit c3bf637
Showing
69 changed files
with
258 additions
and
189 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
import fs from 'node:fs' | ||
import { Prism } from '@astrojs/prism' | ||
// Prints everything between `// scss-docs-start "name"` and `// scss-docs-end "name"` | ||
// comments in the docs. | ||
interface Props { | ||
/** | ||
* Reference name used to find the content to display within `file` | ||
* @default "" | ||
*/ | ||
name: string | ||
/** | ||
* File name that contains the content to display | ||
* @default "" | ||
*/ | ||
file: string | ||
/** | ||
* Remove the ` !default` flag from variable assignments | ||
* @default true | ||
*/ | ||
strip_default?: boolean | ||
} | ||
const { name, file, strip_default = true } = Astro.props | ||
if (!name || !file) { | ||
throw new Error(`Missing required parameters! Got: name=${name} file=${file}`) | ||
} | ||
let content; | ||
try { | ||
content = fs.readFileSync(file, 'utf8') | ||
content = content.substring( | ||
content.indexOf(`// scss-docs-start ${name}`), | ||
content.lastIndexOf(`// scss-docs-end ${name}`) | ||
) | ||
} catch (error) { | ||
throw new Error(`Failed to read ${file}`, { cause: error }) | ||
} | ||
--- | ||
|
||
{/* | ||
TODO: handle ALL the first part of this file with Hugo treatments | ||
TODO: double-check everything in this file but this first basic rendering could do the job temporarily | ||
*/} | ||
|
||
<div class="bd-example-snippet bd-code-snippet bd-scss-docs"> | ||
<div class="d-flex align-items-center highlight-toolbar ps-3 pe-2 py-1 border-bottom"> | ||
{/* TODO: Not yet handled ---> | replaceRE `\\` "/" */} | ||
<a class="font-monospace text-body-secondary text-decoration-none small" href={`[[param:repo]]/blob/v[[param:current_version]]/${file}`}> | ||
{file} | ||
</a> | ||
<div class="d-flex ms-auto"> | ||
<button type="button" class="btn-clipboard mt-0 me-0" title="Copy to clipboard"> | ||
<svg class="bi" aria-hidden="true"><use xlink:href="#clipboard"/></svg> | ||
</button> | ||
</div> | ||
</div> | ||
{/* TODO: Not yet handled ---> highlight $match "scss" "" */} | ||
{/* TODO: Use <Code> ? */} | ||
{/* TODO: Remove some extra-spaces */} | ||
<div class="highlight"> | ||
<Prism code={content} lang="scss" /> | ||
</div> | ||
</div> |
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
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
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
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
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
Oops, something went wrong.