33 * @param {{
44 * width: number,
55 * height: number,
6- * horizontal_padding: number,
7- * vertical_padding: number,
8- * background_color: string,
9- * font_color: string,
10- * day_border_color: string,
11- * day_border_width: number,
12- * day_palette: string[],
136 * username: string,
14- * github_token: string
7+ * github_token: string,
8+ * weeks: number,
9+ * theme: {
10+ * horizontal_padding: number,
11+ * vertical_padding: number,
12+ * background_color: string,
13+ * font_color: string,
14+ * day_border_color: string,
15+ * day_border_width: number,
16+ * day_palette: string[],
17+ * }
1518 * }} input
1619 * @returns {Promise<{
1720 * data:{
3134 * jsx: string,
3235 * }> }
3336 */
34- export async function run ( input ) {
37+ export async function run ( input ) {
38+ let weeks = input . weeks || 52 ;
3539 let data = await getGitHubContributions (
3640 input . github_token || slipway_host . env ( 'GITHUB_TOKEN' ) ,
3741 input . username ,
42+ weeks ,
3843 ) ;
3944
4045 let theme = input . theme || { } ;
@@ -44,8 +49,8 @@ export async function run(input){
4449 const boxVerticalMargin = 1 ;
4550 const boxHorizontalMargin = 3 ;
4651 const borderWidth = theme . day_border_width || 1 ;
47- const drawWidth = input . width - drawMarginWidth * 2 ;
48- const drawHeight = input . height - drawMarginHeight * 2 ;
52+ const drawWidth = input . width - drawMarginWidth * 2 ;
53+ const drawHeight = input . height - drawMarginHeight * 2 ;
4954 const boxWidth = Math . floor ( drawWidth / ( data . weeks . length + 1 ) ) - borderWidth - boxHorizontalMargin ;
5055 const boxHeight = Math . min ( boxWidth , Math . floor ( drawHeight / 7 ) - borderWidth - boxVerticalMargin ) ;
5156
@@ -67,7 +72,8 @@ export async function run(input){
6772 ] ;
6873 data . backgroundColor = theme . background_color || '#ffffff' ;
6974 data . fontColor = theme . font_color || '#000000' ;
70-
75+ data . weekCount = weeks ;
76+
7177 return {
7278 data,
7379 jsx,
@@ -90,12 +96,12 @@ export async function run(input){
9096 * }[]
9197 * }> }
9298 */
93- export async function getGitHubContributions ( githubToken , username ) {
99+ export async function getGitHubContributions ( githubToken , username , weeks ) {
94100 const today = new Date ( ) ;
95- const oneYearAgo = new Date ( today ) ;
96- oneYearAgo . setFullYear ( today . getFullYear ( ) - 1 ) ;
101+ const weeksAgo = new Date ( today ) ;
102+ weeksAgo . setDate ( today . getDate ( ) - weeks * 7 ) ;
97103
98- const from = oneYearAgo . toISOString ( ) ;
104+ const from = weeksAgo . toISOString ( ) ;
99105 const to = today . toISOString ( ) ;
100106
101107 const query = `
0 commit comments