Skip to content

Commit df95662

Browse files
committed
Added custom color
1 parent f5f9b8c commit df95662

File tree

2 files changed

+38
-6
lines changed

2 files changed

+38
-6
lines changed

dist/index.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21013,6 +21013,14 @@ module.exports = require("path");;
2101321013

2101421014
/***/ }),
2101521015

21016+
/***/ 1191:
21017+
/***/ ((module) => {
21018+
21019+
"use strict";
21020+
module.exports = require("querystring");;
21021+
21022+
/***/ }),
21023+
2101621024
/***/ 2413:
2101721025
/***/ ((module) => {
2101821026

@@ -21104,6 +21112,7 @@ const core = __nccwpck_require__(2186);
2110421112
const { NotionEndpoints } = __nccwpck_require__(1109);
2110521113
const fs = __nccwpck_require__(5747);
2110621114
const { commitFile } = __nccwpck_require__(1608);
21115+
const qs = __nccwpck_require__(1191);
2110721116

2110821117
const ColorMap = {
2110921118
default: '505558',
@@ -21198,12 +21207,21 @@ async function main() {
2119821207
([, schema_entry_value]) =>
2119921208
schema_entry_value.type === 'multi_select' &&
2120021209
schema_entry_value.name === 'Category'
21210+
),
21211+
color_schema_entry = schema_entries.find(
21212+
([, schema_entry_value]) =>
21213+
schema_entry_value.type === 'text' &&
21214+
schema_entry_value.name === 'Color'
2120121215
);
2120221216

2120321217
if (!category_schema_entry)
2120421218
return core.setFailed(
2120521219
"Couldn't find Category named multi_select type column in the database"
2120621220
);
21221+
if (!category_schema_entry)
21222+
return core.setFailed(
21223+
"Couldn't find Color named text type column in the database"
21224+
);
2120721225

2120821226
const rows = Object.values(recordMap.block)
2120921227
.filter((block) => block.value.id !== databaseId)
@@ -21240,13 +21258,15 @@ async function main() {
2124021258

2124121259
for (const [category, category_info] of categories_map) {
2124221260
const content = [
21243-
`<div><img height="20px" src="https://img.shields.io/badge/${category}-${
21261+
`<h3><img height="20px" src="https://img.shields.io/badge/${category}-${
2124421262
ColorMap[category_info.color]
21245-
}"/></div>`
21263+
}"/></h3>`
2124621264
];
2124721265
category_info.items.forEach((item) =>
2124821266
content.push(
21249-
`<img src="https://img.shields.io/badge/-${item}-black?style=flat-square&amp;logo=${item}" alt="${item}">`
21267+
`<img src="https://img.shields.io/badge/-${qs.stringify(item)}-${
21268+
item.properties[color_schema_entry[0]][0][0]
21269+
}?style=flat-square&amp;logo=${qs.stringify(item)}" alt="${item}"/>`
2125021270
)
2125121271
);
2125221272
newLines.push(...content, '<hr>');

src/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ const core = require('@actions/core');
22
const { NotionEndpoints } = require('@nishans/endpoints');
33
const fs = require('fs');
44
const { commitFile } = require('./utils');
5+
const qs = require('querystring');
56

67
const ColorMap = {
78
default: '505558',
@@ -96,12 +97,21 @@ async function main() {
9697
([, schema_entry_value]) =>
9798
schema_entry_value.type === 'multi_select' &&
9899
schema_entry_value.name === 'Category'
100+
),
101+
color_schema_entry = schema_entries.find(
102+
([, schema_entry_value]) =>
103+
schema_entry_value.type === 'text' &&
104+
schema_entry_value.name === 'Color'
99105
);
100106

101107
if (!category_schema_entry)
102108
return core.setFailed(
103109
"Couldn't find Category named multi_select type column in the database"
104110
);
111+
if (!category_schema_entry)
112+
return core.setFailed(
113+
"Couldn't find Color named text type column in the database"
114+
);
105115

106116
const rows = Object.values(recordMap.block)
107117
.filter((block) => block.value.id !== databaseId)
@@ -138,13 +148,15 @@ async function main() {
138148

139149
for (const [category, category_info] of categories_map) {
140150
const content = [
141-
`<div><img height="20px" src="https://img.shields.io/badge/${category}-${
151+
`<h3><img height="20px" src="https://img.shields.io/badge/${category}-${
142152
ColorMap[category_info.color]
143-
}"/></div>`
153+
}"/></h3>`
144154
];
145155
category_info.items.forEach((item) =>
146156
content.push(
147-
`<img src="https://img.shields.io/badge/-${item}-black?style=flat-square&amp;logo=${item}" alt="${item}">`
157+
`<img src="https://img.shields.io/badge/-${qs.stringify(item)}-${
158+
item.properties[color_schema_entry[0]][0][0]
159+
}?style=flat-square&amp;logo=${qs.stringify(item)}" alt="${item}"/>`
148160
)
149161
);
150162
newLines.push(...content, '<hr>');

0 commit comments

Comments
 (0)