mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
docs: link source code to folder for multiple components
This commit is contained in:
parent
f7969c64e8
commit
8f37f09374
1 changed files with 21 additions and 4 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue