docs: link source code to folder for multiple components (#1582)

* docs: link source code to folder for multiple components

* chore(docs): remove unused `source` from frontmatter
This commit is contained in:
metonym 2022-12-10 17:49:42 -08:00 committed by GitHub
commit 27da2a0f8b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 21 additions and 31 deletions

View file

@ -22,7 +22,6 @@
export let component = $page.title;
export let components = [component];
export let source = "";
export let unreleased = false;
export let unstable = false;
@ -42,10 +41,28 @@
}
});
function formatSourceURL(multiple) {
const filePath = api_components[0]?.filePath ?? "";
if (multiple) {
/**
* Link to folder for doc with multiple components.
* @example "src/Breadcrumb"
*/
return filePath.split("/").slice(0, -1).join("/");
}
/**
* Else, link to the component source.
* @example "src/Tile/ClickableTile.svelte"
*/
return filePath;
}
// TODO: [refactor] read from package.json value
$: sourceCode = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/src/${
source || `${$page.title}/${$page.title}.svelte`
}`;
$: sourceCode = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/${formatSourceURL(
multiple
)}`;
</script>
<Content data-components>

View file

@ -1,7 +1,3 @@
---
source: Button/ButtonSet.svelte
---
<script>
import { Button, ButtonSet } from "carbon-components-svelte";
import Login from "carbon-icons-svelte/lib/Login.svelte";

View file

@ -1,7 +1,3 @@
---
source: Tile/ClickableTile.svelte
---
<script>
import { ClickableTile } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";

View file

@ -1,7 +1,3 @@
---
source: Tile/ExpandableTile.svelte
---
<script>
import { ExpandableTile, Button } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";

View file

@ -1,6 +1,5 @@
---
components: ["InlineNotification", "NotificationActionButton"]
source: Notification/InlineNotification.svelte
---
<script>

View file

@ -1,7 +1,3 @@
---
source: TextInput/PasswordInput.svelte
---
<script>
import { PasswordInput } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";

View file

@ -1,6 +1,5 @@
---
components: ["TileGroup", "RadioTile"]
source: Tile/RadioTile.svelte
---
<script>

View file

@ -1,6 +1,5 @@
---
components: ["SelectableTile"]
source: Tile/SelectableTile.svelte
---
<script>

View file

@ -1,7 +1,3 @@
---
source: Tile/Tile.svelte
---
<script>
import { Tile } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";

View file

@ -1,7 +1,3 @@
---
source: Notification/ToastNotification.svelte
---
<script>
import { ToastNotification } from "carbon-components-svelte";
import Preview from "../../components/Preview.svelte";