Skip to content

Commit 1514f60

Browse files
KuinoxLPeter1997
andauthored
Initial Draco landing page. (#1)
* Initial Draco landing page. * Segmented code, buttons now looks like good buttons. * Push because I switch PCs. * Started to do second segment. * Added pages, community page. * Used autoformat, fixed some feedback. * Improve the coming soon pages. * Added formatting, linting. * Fixed build script. * Fixes trigger of github workflow. * Fixed build script. * Update .github/workflows/deploy.yml Co-authored-by: LPeter1997 <[email protected]> * PR Feedback. --------- Co-authored-by: LPeter1997 <[email protected]>
1 parent 2223776 commit 1514f60

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+35426
-1
lines changed

.eslintrc.js

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
module.exports = {
2+
"env": {
3+
"browser": true,
4+
"es2021": true,
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:react/recommended"
10+
],
11+
"overrides": [
12+
{
13+
"env": {
14+
"node": true
15+
},
16+
"files": [
17+
".eslintrc.{js,cjs}"
18+
],
19+
"parserOptions": {
20+
"sourceType": "script"
21+
}
22+
},
23+
{
24+
"env": {
25+
"node": true,
26+
"es2021": false,
27+
"amd": true
28+
},
29+
"files": [
30+
"generateAssets.js"
31+
],
32+
"rules": {
33+
"no-require-imports": "off",
34+
"@typescript-eslint/no-var-requires": "off"
35+
}
36+
}
37+
],
38+
"parser": "@typescript-eslint/parser",
39+
"parserOptions": {
40+
"ecmaVersion": "latest",
41+
"sourceType": "module"
42+
},
43+
"plugins": [
44+
"@typescript-eslint",
45+
"react",
46+
"import"
47+
],
48+
"rules": {
49+
"quotes": [
50+
"error",
51+
"double"
52+
],
53+
"semi": [
54+
"error",
55+
"always"
56+
],
57+
"no-multiple-empty-lines": [
58+
"error",
59+
{
60+
max: 1
61+
}
62+
],
63+
"react/react-in-jsx-scope": "off",
64+
"import/newline-after-import": "error",
65+
"padding-line-between-statements": [
66+
"error",
67+
{ "blankLine": "always", "prev": "if", "next": "*" }
68+
]
69+
}
70+
};

.github/workflows/deploy.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
on:
2+
workflow_dispatch:
3+
push:
4+
branches: [main]
5+
6+
permissions:
7+
contents: write
8+
pages: write
9+
id-token: write
10+
deployments: write
11+
12+
jobs:
13+
build-and-deploy:
14+
runs-on: ubuntu-latest
15+
environment:
16+
name: github-pages
17+
url: ${{ steps.deployment.outputs.page_url }}
18+
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v2
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v2
25+
with:
26+
node-version: '19'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Build the app
32+
run: npm run build
33+
34+
- name: Setup Pages
35+
uses: actions/configure-pages@v2
36+
37+
- name: Upload GitHub Pages artifact
38+
uses: actions/[email protected]
39+
with:
40+
path: 'build'
41+
42+
- name: Deploy GitHub Pages site
43+
uses: actions/[email protected]

.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*
24+
25+
/public/generated/

.stylelintrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "stylelint-config-standard",
3+
"rules": {
4+
"shorthand-property-no-redundant-values": null
5+
}
6+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"eslint.lintTask.enable": true
3+
}

CNAME

-1
This file was deleted.

generateAssets.js

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
const { Octokit } = require("@octokit/rest");
2+
const fs = require("fs");
3+
const createActionAuth = require("@octokit/auth-action");
4+
5+
const fullLogo = {
6+
light: "https://raw.githubusercontent.com/Draco-lang/Language-suggestions/main/Resources/Logo-Long.svg",
7+
dark: "https://raw.githubusercontent.com/Draco-lang/Language-suggestions/main/Resources/Logo-Long-Inverted.svg"
8+
};
9+
const shortLogo = {
10+
light: "https://raw.githubusercontent.com/Draco-lang/Language-suggestions/main/Resources/Logo-Short.svg",
11+
dark: "https://raw.githubusercontent.com/Draco-lang/Language-suggestions/main/Resources/Logo-Short-Inverted.svg"
12+
};
13+
const githubLogo = {
14+
light: "prebuild_assets/github-mark-white.svg",
15+
dark: "prebuild_assets/github-mark.svg"
16+
};
17+
const emojis = [];
18+
19+
async function main() {
20+
if (!fs.existsSync("public/generated")){
21+
fs.mkdirSync("public/generated", { recursive: true });
22+
}
23+
24+
downloadThemedImage(fullLogo, "public/generated/Logo-Long.svg", true);
25+
downloadThemedImage(shortLogo, "public/generated/Logo-Short.svg", true);
26+
downloadThemedImage(githubLogo, "public/generated/github-logo.svg", false);
27+
download("https://raw.githubusercontent.com/Draco-lang/Language-suggestions/main/Resources/Derpy-Outlined.svg", "public/generated/derpy.svg");
28+
emojis.push("derpy");
29+
let octokit;
30+
if (process.env.GITHUB_TOKEN !== undefined && process.env.GITHUB_TOKEN.length > 0) {
31+
const auth = createActionAuth();
32+
const authentication = await auth();
33+
octokit = new Octokit({
34+
auth: authentication.token
35+
});
36+
} else {
37+
octokit = new Octokit();
38+
}
39+
40+
const response = await octokit.repos.getContent({
41+
owner: "Draco-lang",
42+
repo: "Language-suggestions",
43+
path: "Resources/Emojis"
44+
});
45+
46+
for (let i = 0; i < response.data.length; i++) {
47+
const element = response.data[i];
48+
console.log(`Downloading ${element.name}...`);
49+
const resp = await fetch(element.download_url);
50+
const emoji = await resp.text();
51+
await fs.promises.writeFile(`public/generated/${element.name}`, emoji);
52+
}
53+
response.data
54+
.map(s => `${s.name.replace(/\.[^/.]+$/, "")}`)
55+
.forEach(s => emojis.push(s));
56+
await fs.promises.writeFile(
57+
"src/generated/emojiTypes.ts",
58+
`export type EmojiName = ${emojis.map(s => `"${s}"`).join(" | ")};`
59+
);
60+
}
61+
main();
62+
63+
async function download(url, path) {
64+
const resp = await fetch(url);
65+
const text = await resp.text();
66+
await fs.promises.writeFile(path, text);
67+
}
68+
69+
async function downloadThemedImage(urls, outputPath, isUrl) {
70+
const svg = await createThemeBasedLogo(urls.light, urls.dark, isUrl);
71+
await fs.promises.writeFile(outputPath, svg);
72+
console.log(`Image downloaded and saved as ${outputPath}`);
73+
}
74+
75+
function stripXMLHeader(xml) {
76+
const regex = /<\??xml[^>]*>/;
77+
return xml.replace(regex, "");
78+
}
79+
80+
function stripViewBox(xml) {
81+
const regex = /viewBox="[^"]*"/;
82+
return xml.replace(regex, "");
83+
}
84+
85+
function extractOpeningSvgTag(svgContent) {
86+
const openingSvgTagRegex = /<svg\b[^>]*>/;
87+
const openingSvgTagMatch = svgContent.match(openingSvgTagRegex);
88+
return openingSvgTagMatch ? openingSvgTagMatch[0] : "<svg xmlns=\"http://www.w3.org/2000/svg\">";
89+
}
90+
91+
async function createThemeBasedLogo(lightUrl, darkUrl, isUrl) {
92+
let bodyLight, bodyDark;
93+
if (isUrl) {
94+
const responseLight = await fetch(lightUrl);
95+
const responseDark = await fetch(darkUrl);
96+
bodyLight = await responseLight.text();
97+
bodyDark = await responseDark.text();
98+
} else {
99+
bodyLight = await fs.promises.readFile(lightUrl, "utf-8");
100+
bodyDark = await fs.promises.readFile(darkUrl, "utf-8");
101+
}
102+
103+
let logoLight = stripXMLHeader(bodyLight);
104+
logoLight = stripViewBox(logoLight);
105+
let logoDark = stripXMLHeader(bodyDark);
106+
logoDark = stripViewBox(logoDark);
107+
const openingSvgTag = extractOpeningSvgTag(bodyLight);
108+
const logoSvg =
109+
`<?xml version="1.0" encoding="UTF-8" standalone="no"?>
110+
${openingSvgTag}
111+
<style>
112+
@media (prefers-color-scheme: dark) {
113+
.light{
114+
visibility: hidden;
115+
}
116+
}
117+
118+
@media (prefers-color-scheme: light) {
119+
.dark{
120+
visibility: hidden;
121+
}
122+
}
123+
</style>
124+
<g class="dark">
125+
${logoDark}
126+
</g>
127+
<g class="light">
128+
${logoLight}
129+
</g>
130+
</svg>
131+
`;
132+
return logoSvg;
133+
}

0 commit comments

Comments
 (0)