mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 19:46: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 component = $page.title;
|
||||||
export let components = [component];
|
export let components = [component];
|
||||||
export let source = "";
|
|
||||||
export let unreleased = false;
|
export let unreleased = false;
|
||||||
export let unstable = 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
|
// TODO: [refactor] read from package.json value
|
||||||
$: sourceCode = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/src/${
|
$: sourceCode = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/${formatSourceURL(
|
||||||
source || `${$page.title}/${$page.title}.svelte`
|
multiple
|
||||||
}`;
|
)}`;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Content data-components>
|
<Content data-components>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue