Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize SvelteKit and rewrite to in Svelte + Tailwind. #3

Open
wants to merge 40 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
48b3c1f
Initialize SvelteKit and rewrite to in Svelte + Tailwind.
liquidx Oct 27, 2024
71e4f5e
add instructions
liquidx Oct 27, 2024
bce54cc
Downgrade to use node18
liquidx Oct 27, 2024
e58c185
Properly create the og image url
liquidx Oct 27, 2024
45a3a9e
Convert from canvas to sharp
liquidx Oct 27, 2024
975f25a
Fix dup key in overrides
liquidx Oct 27, 2024
9c0552e
Update fonts
liquidx Oct 27, 2024
2ff9845
Fonts
liquidx Oct 27, 2024
91d6cf0
Add debug endpoint
liquidx Oct 27, 2024
df37a8e
Dump more info
liquidx Oct 27, 2024
d81d5b7
List out files in fonts
liquidx Oct 27, 2024
c0b9899
again
liquidx Oct 27, 2024
0f95e4e
List the other directory /var/task instead
liquidx Oct 27, 2024
79b24d1
Continue to debug /var/task
liquidx Oct 28, 2024
a4409d1
Add back the og edge function to see if it works
liquidx Oct 28, 2024
f84b842
Attempt to hook up the hold ogx
liquidx Oct 28, 2024
7323c40
Update to work on localhost
liquidx Oct 28, 2024
daaeefb
Fix bugs with the ogx
liquidx Oct 28, 2024
634e242
No zones
liquidx Oct 28, 2024
7ba8918
Try importing from other sources to see if it works.
liquidx Oct 28, 2024
c521909
Hook up the fake getZoneInfo
liquidx Oct 28, 2024
19d7844
zoneinfo fix
liquidx Oct 28, 2024
f7b6325
Check if colors is working
liquidx Oct 28, 2024
dfc10e1
Debugging colors
liquidx Oct 28, 2024
6ecc578
Fix syntax
liquidx Oct 28, 2024
9d66c0a
Return nothing if no path
liquidx Oct 28, 2024
89a9da3
Maybe fix a react error
liquidx Oct 28, 2024
4af91c1
Another fix
liquidx Oct 28, 2024
0ab9fd9
Zones element
liquidx Oct 28, 2024
741c867
Add zones
liquidx Oct 28, 2024
b7bc59f
stringify zone
liquidx Oct 28, 2024
1bebf51
Another fix for the netlify zone
liquidx Oct 28, 2024
c60e963
Update the style
liquidx Oct 28, 2024
39b0e41
A little bit more debugging
liquidx Oct 28, 2024
d38fedc
Update debug
liquidx Oct 28, 2024
3df6adb
Add build steps to force copy the fonts into the server deployment
liquidx Oct 28, 2024
4eebe95
Add back title
liquidx Oct 28, 2024
1515ef6
Trying to do a better job copying the files
liquidx Oct 28, 2024
3cdf06d
Make echo allow customizing where to point the readdir method
liquidx Nov 1, 2024
375bef4
Fix searchParams
liquidx Nov 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 18 additions & 83 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,97 +15,32 @@ pids
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/
# Local Netlify folder
.netlify

# DynamoDB Local files
.dynamodb/
# Svelte Output
.output
.vercel
/.svelte-kit
/build

# TernJS port file
.tern-port
# OS
.DS_Store
.firebase/**
functions/package-lock.json
package-lock.json
Thumbs.db

# Local Netlify folder
.netlify
# Env
.env
.env.*
!.env.example
!.env.test

# Vite
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Package Managers
package-lock.json
pnpm-lock.yaml
yarn.lock
15 changes: 15 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte", "prettier-plugin-tailwindcss"],
"overrides": [
{
"files": "*.svelte",
"options": {
"parser": "svelte"
}
}
]
}
38 changes: 38 additions & 0 deletions README copy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# create-svelte

Everything you need to build a Svelte project, powered by [`create-svelte`](https://github.com/sveltejs/kit/tree/main/packages/create-svelte).

## Creating a project

If you're seeing this, you've probably already done this step. Congrats!

```bash
# create a new project in the current directory
npx sv create

# create a new project in my-app
npx sv create my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

To create a production version of your app:

```bash
npm run build
```

You can preview the production build with `npm run preview`.

> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# timezone.fyi

Source for https://timezone.fyi

# development

````
pnpm install
pnpm run dev
```

23 changes: 23 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import prettier from 'eslint-config-prettier';
import js from '@eslint/js';
import svelte from 'eslint-plugin-svelte';
import globals from 'globals';

/** @type {import('eslint').Linter.Config[]} */
export default [
js.configs.recommended,
...svelte.configs['flat/recommended'],
prettier,
...svelte.configs['flat/prettier'],
{
languageOptions: {
globals: {
...globals.browser,
...globals.node
}
}
},
{
ignores: ['build/', '.svelte-kit/', 'dist/']
}
];
17 changes: 6 additions & 11 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
[build]
edge_functions = "./netlify/edge-functions-disabled"
command = "npm run build"
publish = "build"
edge_functions = "netlify/edge-functions"

[[redirects]]
from = "/og"
to = "/.netlify/functions/og"
status = 200
force = true

[[redirects]]
from = "/*"
to = "/.netlify/functions/index"
status = 200
[[edge_functions]]
path = "/ogx"
function = "ogx"
92 changes: 73 additions & 19 deletions netlify/edge-functions/og.tsx → netlify/edge-functions/ogx.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,80 @@
import type { Config, Context } from "@netlify/edge-functions";
import { ImageResponse } from "https://deno.land/x/og_edge/mod.ts";
import React from "https://esm.sh/react@18.2.0";
import {DateTime} from "https://esm.sh/luxon@2";

import { colors } from '../../src/lib/timezones.js'

export const emptyZoneInfo = (zone: string): any=> {
return {
description: '',
night: false,
zoneStart: DateTime.now().setZone(zone),
zoneEnd: null,
emoji: '',
niceZoneName: zone,
startString: DateTime.now().setZone(zone).toFormat('h:mm a'),
endString: '',
extraDay: false,
};
}

import { getZoneInfo, colors } from "../common.js";
const getZoneInfo = (path: string) : any => {
let zones : any[] = [];
if (!path) {
return {}
}
zones.push(emptyZoneInfo('EST'));
zones.push(emptyZoneInfo('PST'));
return {zones};
}


export default async (request: Request, context: Context) => {
let url = new URL(request.url);
let path = url.searchParams.get("path");
const info = getZoneInfo(path);

console.log("URL:", info);
const info = getZoneInfo(path);
if (!info.zones) {
return new ImageResponse(
<div
style={{
width: "100%",
height: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: 128,
backgroundImage: "linear-gradient(#e66465, #9198e5)"
}}
>
Hello!
</div>
);
}

const zones = info.zones;
console.log('Hours', zones.map(z => z.zoneStart.hour));
console.log('Colors', zones.map(z => colors[z.zoneStart.hour * 2]));

const zonesElements = zones.map((z: any, i: number) => {
const background = `linear-gradient(${colors[z.zoneStart.hour * 2]}, ${colors[z.zoneStart.hour * 2 + 1]})`;
const zoneStyle = {
backgroundImage: background,
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
fontSize: 128,
}
return (
<div key={`zone${i}`} style={zoneStyle}>
<div>Hello</div>
{/* <div>{z.niceZoneName}</div>
<div>{z.startString}</div> */}
</div>
)
});

return new ImageResponse(
(
Expand All @@ -19,31 +83,21 @@ export default async (request: Request, context: Context) => {
width: "100%",
height: "100%",
display: "flex",
flexDirection: "row",
alignItems: "center",
justifyContent: "center",
fontSize: 128,
backgroundImage: "linear-gradient(#e66465, #9198e5)"
backgroundImage: "linear-gradient(#9198e5, #9198e5)"
}}
>
{info?.zones.map((z, i) => (
<div key={i}
style={{
backgroundImage: `linear-gradient(${colors[z.zoneStart.hour() * 2]}, ${colors[z.zoneStart.hour() * 2 + 1]})`,
}}
>

<div>{z.niceZoneName}</div>
<div>{z.startString}</div>
</div>
))}
Hello!
${zonesElements}
</div>
)
);
}

export const config = {
path: "/og",
export const config : Config = {
path: "/ogx",
cache: "manual",
};

Expand Down Expand Up @@ -119,4 +173,4 @@ export const config = {

// export const config = {
// path: "/og.jpg*",
// };
// };
Loading