-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathstackbit.js
More file actions
executable file
·91 lines (81 loc) · 3.41 KB
/
stackbit.js
File metadata and controls
executable file
·91 lines (81 loc) · 3.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env node
const urlSlug = require('url-slug');
const {getThemeKey, getRepoName} = require('./utils');
const ora = require('ora');
const spinner = ora('Loading')
const allowedSsg = []
const allowedCms = []
const generateStackbit = (frontmatter) => {
const themeKey = getThemeKey(frontmatter.github)
spinner.text = `${frontmatter.file}`
let stackbitData = {
theme_key: themeKey
};
const ssgArray = frontmatter.ssg || []
const cmsArray = frontmatter.cms || []
if (ssgArray.some(ssg => allowedSsg.includes(urlSlug(ssg))) && cmsArray.some(cms => allowedCms.includes(urlSlug(cms)))) {
if (ssgArray.length > 1) {
stackbitData.createUrl = `https://app.stackbit.com/create?theme=${frontmatter.github}`
} else {
stackbitData.createUrl = `https://app.stackbit.com/create?theme=${frontmatter.github}&ssg=${urlSlug(ssgArray)}`
}
} else {
stackbitData.createUrl = null;
}
// manual overrides
const manualDisabled = [
'https://github.com/runbytech/gatsby-theme-ultronele',
'https://github.com/YoussefRaafatNasry/portfolYOU',
'https://github.com/qwtel/hydejack',
'https://github.com/joshgerdes/jekyll-uno',
'https://github.com/GDGToulouse/devfest-theme-hugo',
'https://github.com/h-enk/doks',
'https://github.com/ahmadiqbal1/jekyll-webpack-boilerplate',
'https://github.com/SupunKavinda/jekyll-theme-leaf.git',
'https://github.com/techonomics69/gatsby-netlify-form-example',
'https://github.com/lawrencecchen/headless-comments',
'https://github.com/Joy3Luo/Joy3luo.github.io',
'https://github.com/chrisbobbe/jekyll-theme-prologue',
'https://github.com/adityatelange/hugo-PaperMod/',
'https://github.com/Kentico/kontent-jekyll-blog',
'https://github.com/longpdo/neumorphism',
'https://github.com/puresyntax71/hugo-theme-chunky-poster',
'https://github.com/sharadcodes/jekyll-theme-dark-reader',
'https://github.com/wkocjan/gatsby-theme-intro',
'https://github.com/jameshamann/jekyll-material-theme',
'https://github.com/fncnt/vncnt-hugo',
'https://github.com/wizlee/gatsby-portfolio',
'https://github.com/EmaSuriano/gatsby-starter-mate',
'https://github.com/guangmean/Niello',
'https://github.com/fabien0102/gatsby-starter',
'https://github.com/netlify-templates/one-click-hugo-cms'
];
manualDisabled.forEach(url => {
if (url === frontmatter.github) {
if (stackbitData.createUrl) {
delete stackbitData.createUrl
}
}
})
const manualEnabled = ['https://github.com/stackbit-themes/minimal-nextjs-theme']
manualEnabled.forEach(url => {
if (url === frontmatter.github) {
stackbitData.createUrl = `https://app.stackbit.com/create?theme=${frontmatter.github}&ssg=${urlSlug(frontmatter.ssg)}&cms=${urlSlug(frontmatter.cms)}`
}
})
if (stackbitData.createUrl) {
return stackbitData;
}
return false;
};
const generateStackbitData = (markdownData) => {
spinner.start("Fetching Stackbit Data");
const stackbitData = markdownData.map(theme => {
return generateStackbit(theme)
}).filter(stackbit => stackbit.createUrl);
spinner.succeed("Success - Fetching Stackbit Data");
return stackbitData;
};
module.exports = {
generateStackbitData
}