File tree Expand file tree Collapse file tree 4 files changed +13
-1
lines changed
Expand file tree Collapse file tree 4 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ function getPackageJSON() {
3535 svelte : pkg . svelte ,
3636 description : pkg . description ,
3737 homepage : pkg . homepage ,
38+ repoUrl : pkg . repository ?. url ,
3839 } ;
3940 } catch ( error ) {
4041 console . log ( error ) ;
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ interface PreprocessReadmeOptions {
2222 svelte : string ;
2323 prefixUrl : string ;
2424 homepage : string ;
25+ repoUrl : string ;
2526}
2627
2728export function preprocessReadme ( opts : Partial < PreprocessReadmeOptions > ) : Pick < PreprocessorGroup , "markup" > {
@@ -67,6 +68,10 @@ export function preprocessReadme(opts: Partial<PreprocessReadmeOptions>): Pick<P
6768 markup : ( { content, filename } ) => {
6869 if ( / n o d e _ m o d u l e s / . test ( filename ) || ! filename . endsWith ( ".md" ) ) return null ;
6970
71+ if ( opts . repoUrl ) {
72+ content = content . replace ( "<!-- REPO_URL -->" , `[GitHub repo](${ opts . repoUrl } )` ) ;
73+ }
74+
7075 content = content . replace (
7176 "<!-- TOC -->" ,
7277 `
Original file line number Diff line number Diff line change 11# my-svelte-component
22
3+ <!-- REPO_URL -->
4+
35<!-- TOC -->
46
57Relative URL: [ Readme] ( ./ )
Original file line number Diff line number Diff line change 1919 "serve" : " ^11.3.2" ,
2020 "svelte" : " ^3.29.7"
2121 },
22- "homepage" : " https://github.com/metonym/svelte-readme"
22+ "homepage" : " https://github.com/metonym/svelte-readme" ,
23+ "repository" : {
24+ "type" : " git" ,
25+ "url" : " https://github.com/metonym/svelte-readme"
26+ }
2327}
You can’t perform that action at this time.
0 commit comments