Use SvelteKit instead of stealing Codeberg

Signed-off-by: Sam Therapy <sam@samtherapy.net>
This commit is contained in:
Sam Therapy 2024-03-15 23:25:07 +01:00
parent b19759fa9f
commit fa4831709a
Signed by: sam
GPG key ID: 4D8B07C18F31ACBD
26 changed files with 3842 additions and 184 deletions

13
.eslintignore Normal file
View file

@ -0,0 +1,13 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

31
.eslintrc.cjs Normal file
View file

@ -0,0 +1,31 @@
/** @type { import("eslint").Linter.Config } */
module.exports = {
root: true,
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:svelte/recommended',
'prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
parserOptions: {
sourceType: 'module',
ecmaVersion: 2020,
extraFileExtensions: ['.svelte']
},
env: {
browser: true,
es2017: true,
node: true
},
overrides: [
{
files: ['*.svelte'],
parser: 'svelte-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser'
}
}
]
};

10
.gitignore vendored Normal file
View file

@ -0,0 +1,10 @@
.DS_Store
node_modules
/build
/.svelte-kit
/package
.env
.env.*
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*

1
.npmrc Normal file
View file

@ -0,0 +1 @@
engine-strict=true

4
.prettierignore Normal file
View file

@ -0,0 +1,4 @@
# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock

8
.prettierrc Normal file
View file

@ -0,0 +1,8 @@
{
"useTabs": true,
"singleQuote": true,
"trailingComma": "none",
"printWidth": 100,
"plugins": ["prettier-plugin-svelte"],
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
}

118
.vscode/settings.json vendored Normal file
View file

@ -0,0 +1,118 @@
{
"prettier.documentSelectors": ["**/*.svelte"],
"tailwindCSS.classAttributes": [
"class",
"accent",
"active",
"animIndeterminate",
"aspectRatio",
"background",
"badge",
"bgBackdrop",
"bgDark",
"bgDrawer",
"bgLight",
"blur",
"border",
"button",
"buttonAction",
"buttonBack",
"buttonClasses",
"buttonComplete",
"buttonDismiss",
"buttonNeutral",
"buttonNext",
"buttonPositive",
"buttonTextCancel",
"buttonTextConfirm",
"buttonTextFirst",
"buttonTextLast",
"buttonTextNext",
"buttonTextPrevious",
"buttonTextSubmit",
"caretClosed",
"caretOpen",
"chips",
"color",
"controlSeparator",
"controlVariant",
"cursor",
"display",
"element",
"fill",
"fillDark",
"fillLight",
"flex",
"flexDirection",
"gap",
"gridColumns",
"height",
"hover",
"inactive",
"indent",
"justify",
"meter",
"padding",
"position",
"regionAnchor",
"regionBackdrop",
"regionBody",
"regionCaption",
"regionCaret",
"regionCell",
"regionChildren",
"regionChipList",
"regionChipWrapper",
"regionCone",
"regionContent",
"regionControl",
"regionDefault",
"regionDrawer",
"regionFoot",
"regionFootCell",
"regionFooter",
"regionHead",
"regionHeadCell",
"regionHeader",
"regionIcon",
"regionInput",
"regionInterface",
"regionInterfaceText",
"regionLabel",
"regionLead",
"regionLegend",
"regionList",
"regionListItem",
"regionNavigation",
"regionPage",
"regionPanel",
"regionRowHeadline",
"regionRowMain",
"regionSummary",
"regionSymbol",
"regionTab",
"regionTrail",
"ring",
"rounded",
"select",
"shadow",
"slotDefault",
"slotFooter",
"slotHeader",
"slotLead",
"slotMessage",
"slotMeta",
"slotPageContent",
"slotPageFooter",
"slotPageHeader",
"slotSidebarLeft",
"slotSidebarRight",
"slotTrail",
"spacing",
"text",
"track",
"transition",
"width",
"zIndex"
]
}

38
README.md Normal file
View file

@ -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
npm create svelte@latest
# create a new project in my-app
npm create svelte@latest 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://kit.svelte.dev/docs/adapters) for your target environment.

103
froth-noire-skeleton.ts Normal file
View file

@ -0,0 +1,103 @@
import type { CustomThemeConfig } from '@skeletonlabs/tw-plugin';
export const frothNoire: CustomThemeConfig = {
name: 'froth-noire',
properties: {
// =~= Theme Properties =~=
"--theme-font-family-base": `system-ui`,
"--theme-font-family-heading": `system-ui`,
"--theme-font-color-base": "0 0 0",
"--theme-font-color-dark": "255 255 255",
"--theme-rounded-base": "4px",
"--theme-rounded-container": "4px",
"--theme-border-base": "1px",
// =~= Theme On-X Colors =~=
"--on-primary": "0 0 0",
"--on-secondary": "0 0 0",
"--on-tertiary": "0 0 0",
"--on-success": "0 0 0",
"--on-warning": "0 0 0",
"--on-error": "0 0 0",
"--on-surface": "255 255 255",
// =~= Theme Colors =~=
// primary | #A0A0A0
"--color-primary-50": "241 241 241", // #f1f1f1
"--color-primary-100": "236 236 236", // #ececec
"--color-primary-200": "231 231 231", // #e7e7e7
"--color-primary-300": "217 217 217", // #d9d9d9
"--color-primary-400": "189 189 189", // #bdbdbd
"--color-primary-500": "160 160 160", // #A0A0A0
"--color-primary-600": "144 144 144", // #909090
"--color-primary-700": "120 120 120", // #787878
"--color-primary-800": "96 96 96", // #606060
"--color-primary-900": "78 78 78", // #4e4e4e
// secondary | #bcbcbc
"--color-secondary-50": "245 245 245", // #f5f5f5
"--color-secondary-100": "242 242 242", // #f2f2f2
"--color-secondary-200": "238 238 238", // #eeeeee
"--color-secondary-300": "228 228 228", // #e4e4e4
"--color-secondary-400": "208 208 208", // #d0d0d0
"--color-secondary-500": "188 188 188", // #bcbcbc
"--color-secondary-600": "169 169 169", // #a9a9a9
"--color-secondary-700": "141 141 141", // #8d8d8d
"--color-secondary-800": "113 113 113", // #717171
"--color-secondary-900": "92 92 92", // #5c5c5c
// tertiary | #c0c0c0
"--color-tertiary-50": "246 246 246", // #f6f6f6
"--color-tertiary-100": "242 242 242", // #f2f2f2
"--color-tertiary-200": "239 239 239", // #efefef
"--color-tertiary-300": "230 230 230", // #e6e6e6
"--color-tertiary-400": "211 211 211", // #d3d3d3
"--color-tertiary-500": "192 192 192", // #c0c0c0
"--color-tertiary-600": "173 173 173", // #adadad
"--color-tertiary-700": "144 144 144", // #909090
"--color-tertiary-800": "115 115 115", // #737373
"--color-tertiary-900": "94 94 94", // #5e5e5e
// success | #12984f
"--color-success-50": "219 240 229", // #dbf0e5
"--color-success-100": "208 234 220", // #d0eadc
"--color-success-200": "196 229 211", // #c4e5d3
"--color-success-300": "160 214 185", // #a0d6b9
"--color-success-400": "89 183 132", // #59b784
"--color-success-500": "18 152 79", // #12984f
"--color-success-600": "16 137 71", // #108947
"--color-success-700": "14 114 59", // #0e723b
"--color-success-800": "11 91 47", // #0b5b2f
"--color-success-900": "9 74 39", // #094a27
// warning | #ffff0b
"--color-warning-50": "255 255 218", // #ffffda
"--color-warning-100": "255 255 206", // #ffffce
"--color-warning-200": "255 255 194", // #ffffc2
"--color-warning-300": "255 255 157", // #ffff9d
"--color-warning-400": "255 255 84", // #ffff54
"--color-warning-500": "255 255 11", // #ffff0b
"--color-warning-600": "230 230 10", // #e6e60a
"--color-warning-700": "191 191 8", // #bfbf08
"--color-warning-800": "153 153 7", // #999907
"--color-warning-900": "125 125 5", // #7d7d05
// error | #EA3000
"--color-error-50": "252 224 217", // #fce0d9
"--color-error-100": "251 214 204", // #fbd6cc
"--color-error-200": "250 203 191", // #facbbf
"--color-error-300": "247 172 153", // #f7ac99
"--color-error-400": "240 110 77", // #f06e4d
"--color-error-500": "234 48 0", // #EA3000
"--color-error-600": "211 43 0", // #d32b00
"--color-error-700": "176 36 0", // #b02400
"--color-error-800": "140 29 0", // #8c1d00
"--color-error-900": "115 24 0", // #731800
// surface | #262626
"--color-surface-50": "222 222 222", // #dedede
"--color-surface-100": "212 212 212", // #d4d4d4
"--color-surface-200": "201 201 201", // #c9c9c9
"--color-surface-300": "168 168 168", // #a8a8a8
"--color-surface-400": "103 103 103", // #676767
"--color-surface-500": "38 38 38", // #262626
"--color-surface-600": "34 34 34", // #222222
"--color-surface-700": "29 29 29", // #1d1d1d
"--color-surface-800": "23 23 23", // #171717
"--color-surface-900": "19 19 19", // #131313
}
}

File diff suppressed because one or more lines are too long

47
package.json Normal file
View file

@ -0,0 +1,47 @@
{
"name": "static-pages",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "prettier --check . && eslint .",
"format": "prettier --write .",
"predeploy": "pnpm run build",
"deploy": "gh-pages -d build -r git@git.froth.zone:sam/static-pages.git -b pages --cname pages.git.froth.zone"
},
"devDependencies": {
"@skeletonlabs/skeleton": "2.9.0",
"@skeletonlabs/tw-plugin": "0.3.1",
"@sveltejs/adapter-auto": "^3.0.0",
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/enhanced-img": "^0.1.9",
"@sveltejs/kit": "^2.0.0",
"@sveltejs/vite-plugin-svelte": "^3.0.0",
"@tailwindcss/forms": "^0.5.7",
"@tailwindcss/typography": "0.5.10",
"@types/eslint": "^8.56.0",
"@types/node": "20.11.27",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^7.0.0",
"autoprefixer": "10.4.18",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-svelte": "^2.35.1",
"gh-pages": "^6.1.1",
"postcss": "8.4.35",
"prettier": "^3.1.1",
"prettier-plugin-svelte": "^3.1.2",
"svelte": "^4.2.7",
"svelte-check": "^3.6.0",
"tailwindcss": "3.4.1",
"tslib": "^2.4.1",
"typescript": "^5.0.0",
"vite": "^5.0.3",
"vite-plugin-tailwind-purgecss": "0.2.0"
},
"type": "module"
}

3169
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load diff

6
postcss.config.cjs Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {}
}
};

9
src/app.d.ts vendored Normal file
View file

@ -0,0 +1,9 @@
// See https://kit.svelte.dev/docs/types#app
// for information about these interfaces
// and what to do when importing types
declare namespace App {
// interface Locals {}
// interface PageData {}
// interface Error {}
// interface Platform {}
}

13
src/app.html Normal file
View file

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en" class="dark">
<head>
<title>Froth Pages</title>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover" data-theme="froth-noire">
<div style="display: contents" class="h-full overflow-hidden">%sveltekit.body%</div>
</body>
</html>

9
src/app.postcss Normal file
View file

@ -0,0 +1,9 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
@tailwind variants;
html,
body {
@apply h-full overflow-hidden;
}

8
src/lib/index.ts Normal file
View file

@ -0,0 +1,8 @@
// place files you want to import through the `$lib` alias in this folder.
export const gitDomain = 'git.froth.zone';
export const gitName = 'Froth Git';
export const pagesDomain = 'pages.git.froth.zone';
export const pagesName = 'Froth Pages';
export const ipv4 = '150.136.112.69';
export const ipv6 = '2603:c020:4004:62ee:d84c:2488:5bdb:99c1';

18
src/routes/+layout.svelte Normal file
View file

@ -0,0 +1,18 @@
<script lang="ts">
import '../app.postcss';
import { AppShell, AppBar } from '@skeletonlabs/skeleton';
</script>
<!-- App Shell -->
<AppShell>
<svelte:fragment slot="header">
<!-- App Bar -->
<AppBar gridColumns="grid-cols-3" slotDefault="place-self-center" slotTrail="place-content-end">
<svelte:fragment slot="lead"><strong class="text-xl uppercase">Froth Pages</strong></svelte:fragment>
<noscript><strong>Hey, you! This page is interactive and currently requires JavaScript!</strong> <br /> Want a non-JS version? Bother <a class="anchor" href="https://matrix.to/#/@samme:schizo.cafe">Sam</a> about it!</noscript>
<svelte:fragment slot="trail"><a class="anchor" href="https://git.froth.zone/sam/static-pages">Source Code</a></svelte:fragment>
</AppBar>
</svelte:fragment>
<!-- Page Route Content -->
<slot />
</AppShell>

1
src/routes/+layout.ts Normal file
View file

@ -0,0 +1 @@
export const prerender = true;

159
src/routes/+page.svelte Normal file
View file

@ -0,0 +1,159 @@
<script lang="ts">
import { browser } from '$app/environment';
import { gitDomain, gitName, ipv4, ipv6, pagesDomain, pagesName } from '$lib';
import { Accordion, AccordionItem, CodeBlock, Step, Stepper } from '@skeletonlabs/skeleton';
let username = '';
let repository = '';
let branch = '';
$: navDomain = `https://${username}.${pagesDomain}${!repository ? '' : `/${repository}`}${!branch ? '' : `/@${branch}`}`;
$: dnsDomain = `${!branch ? '' : `${branch}.`}${!repository ? '' : `${repository}.`}${username}.${pagesDomain}`;
function codebergDocs() {
if (browser) {
window.open('https://docs.codeberg.org/codeberg-pages/', '_blank');
}
}
</script>
<div class="container mx-auto flex justify-center items-center w-full">
<div class="space-y-10 h-full text-center flex flex-col items-center w-full">
<br />
<h2 class="h2">Host <strong>static websites</strong> with {pagesName}!</h2>
<p>
It's quick, easy, free & fast - just put your project's homepage, developer blog or web
experiment into a Git repository at <a class="anchor" href="https://{gitDomain}">{gitName}</a>
and we'll do the rest.
</p>
<Stepper
on:complete={codebergDocs}
buttonCompleteLabel="Open Documentation"
buttonComplete="variant-filled-success"
>
<Step>
<svelte:fragment slot="navigation">
<a href="https://{gitDomain}/repo/create" target="_blank" class="btn variant-filled-secondary"
>Create a repository!</a
>
</svelte:fragment>
<svelte:fragment slot="header">1 - Make a repository</svelte:fragment>
<div class="space-y-2">
<p>
Create a public repository named <code class="code">pages</code> to make the site available
on the main subdomain.
</p>
<hr />
</div>
<p>Or, create a branch named <code class="code">pages</code> in any public repository.</p>
<p>
<code class="code">git switch --orphan pages</code><br /><code class="code"
>git rm --cached -r .</code
>
</p>
<CodeBlock
buttonCopied="Copied!"
lineNumbers={true}
language="shell"
code={`git switch --orphan pages
git rm --cached -r .`}
></CodeBlock>
</Step>
<Step>
<svelte:fragment slot="header">2 - Add your files</svelte:fragment>
<p>Push your static content. HTML, CSS, fonts, images or anything else.</p>
</Step>
<Step>
<svelte:fragment slot="header">3 - You're Done!</svelte:fragment>
<div class="space-y-4">
<p>Access your new website with this link:</p>
<code class="code">https://USERNAME.{pagesDomain}[/REPOSITORY][/@BRANCH]</code>
<p>or, use this handy form that can navigate for you!</p>
<div class="space-y-1">
<div class="input-group input-group-divider grid-cols-4">
<input
bind:value={username}
class="input variant-form-material {username ? '' : 'input-error'}"
title="Username"
type="text"
placeholder="Username (required)"
required
/>
<div class="input-group-shim">.{pagesDomain}/</div>
<input
bind:value={repository}
class="input variant-form-material"
title="Repository"
type="text"
placeholder="Repository"
/>
<input
bind:value={branch}
class="input variant-form-material"
title="Branch"
type="text"
placeholder="Branch"
/>
</div>
<a href={navDomain} class="btn variant-filled-secondary">Take me there!</a>
</div>
<hr />
<div>
<h3 class="h3">What about custom domains?</h3>
<p>
To use custom domains, create a <code class="code">.domains</code> in the root of your
repository with the domain name you would like to use.
</p>
<br />
<p>Then, add a DNS record for that domain:</p>
<em>(note): use the above form to auto-generate your DNS records!</em>
<Accordion autocollapse>
<AccordionItem open>
<svelte:fragment slot="summary">CNAME (Prefered)</svelte:fragment>
<svelte:fragment slot="content">
<code class="code">CNAME [[branch.]repo.]user.{pagesDomain}.</code>
<CodeBlock buttonCopied="Copied!" language="dns" code={`CNAME ${dnsDomain}.`}
></CodeBlock>
</svelte:fragment>
</AccordionItem>
<AccordionItem>
<svelte:fragment slot="summary">ALIAS (If available)</svelte:fragment>
<svelte:fragment slot="content">
<p>For apex domains where CNAME does not work.</p>
<p>
<code class="code">ALIAS {pagesDomain}.</code><br /><code class="code"
>TXT $[[branch.]repo.]user.{pagesDomain}</code
>
</p>
<CodeBlock
buttonCopied="Copied!"
language="dns"
code={`ALIAS ${pagesDomain}.
TXT ${dnsDomain}`}
></CodeBlock>
</svelte:fragment>
</AccordionItem>
<AccordionItem>
<svelte:fragment slot="summary">A/AAAA (Old reliable)</svelte:fragment>
<svelte:fragment slot="content">
<p>If CNAME will not work and ALIAS is not available</p>
<p>
<code class="code">A {ipv4}</code><br /><code class="code">AAAA {ipv6}</code><br
/><code class="code">TXT $[[branch.]repo.]user.{pagesDomain}</code>
</p>
<CodeBlock
buttonCopied="Copied!"
language="dns"
code={`A ${ipv4}
AAAA ${ipv6}
TXT ${dnsDomain}`}
></CodeBlock>
</svelte:fragment>
</AccordionItem>
</Accordion>
</div>
</div>
</Step>
</Stepper>
</div>
</div>

BIN
static/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 MiB

18
svelte.config.js Normal file
View file

@ -0,0 +1,18 @@
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
extensions: ['.svelte'],
// Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors
preprocess: [vitePreprocess()],
kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
}
};
export default config;

34
tailwind.config.ts Normal file
View file

@ -0,0 +1,34 @@
import { join } from 'path';
import type { Config } from 'tailwindcss';
import forms from '@tailwindcss/forms';
import typography from '@tailwindcss/typography';
import { skeleton } from '@skeletonlabs/tw-plugin';
import { frothNoire } from './froth-noire-skeleton';
export default {
darkMode: 'class',
content: [
'./src/**/*.{html,js,svelte,ts}',
join(require.resolve('@skeletonlabs/skeleton'), '../**/*.{html,js,svelte,ts}')
],
theme: {
extend: {}
},
plugins: [
forms,
typography,
skeleton({
themes: {
preset: [
{
name: 'skeleton',
enhancements: true
}
],
custom: [
frothNoire
]
}
})
]
} satisfies Config;

18
tsconfig.json Normal file
View file

@ -0,0 +1,18 @@
{
"extends": "./.svelte-kit/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"checkJs": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"sourceMap": true,
"strict": true,
"moduleResolution": "bundler"
}
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
//
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
// from the referenced tsconfig.json - TypeScript does not merge them in
}

7
vite.config.ts Normal file
View file

@ -0,0 +1,7 @@
import { purgeCss } from 'vite-plugin-tailwind-purgecss';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit(), purgeCss()]
});