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

switch to netlify adapter #32

Merged
merged 16 commits into from
Dec 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:

- uses: actions/setup-node@v2
with:
node-version: '16'
node-version: "16"

# Runs a single command using the runners shell
- name: cypress
uses: cypress-io/github-action@v2
with:
record: true
build: yarn export
start: yarn serve -l 3000 build/
build: yarn build
start: yarn preview
browser: electron
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
Expand Down
6 changes: 6 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build]
command = "yarn build"
publish = "build"

[functions]
included_files = ["pieces/**"]
102 changes: 52 additions & 50 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
{
"name": "writing",
"description": "zach's writing",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "svelte-kit dev",
"export": "svelte-kit build",
"start": "node build",
"validate": "svelte-check",
"new": "node scripts/newPiece.js"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
},
"dependencies": {
"directory-tree": "^2.2.5",
"yaml": "^1.10.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/runtime": "^7.0.0",
"@rollup/plugin-babel": "^5.0.0",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@rollup/plugin-typescript": "^6.0.0",
"@sveltejs/adapter-static": "^1.0.0-next.21",
"@sveltejs/kit": "^1.0.0-next.196",
"@tsconfig/svelte": "^2.0.1",
"@types/compression": "^1.7.0",
"@types/node": "^14.11.1",
"@types/polka": "^0.5.1",
"cypress": "^9.0.0",
"cypress-cucumber-preprocessor": "^4.3.0",
"node-fetch": "^3.1.0",
"rollup": "^2.3.4",
"rollup-plugin-svelte": "^6.0.0",
"rollup-plugin-terser": "^7.0.0",
"serve": "^13.0.2",
"svelte": "^3.44.2",
"svelte-check": "^2.2.4",
"svelte-preprocess": "^4.7.4",
"tslib": "^2.0.1",
"typescript": "^4.0.3",
"vite": "^2.3.7"
}
}
"name": "writing",
"description": "zach's writing",
"version": "0.0.1",
"type": "module",
"scripts": {
"dev": "svelte-kit dev",
"build": "svelte-kit build",
"preview": "svelte-kit preview",
"netlify": "netlify dev -d build/ -f ./netlify/functions-internal",
"start": "node build",
"validate": "svelte-check",
"new": "node scripts/newPiece.js"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
},
"dependencies": {
"@sveltejs/adapter-netlify": "^1.0.0-next.35",
"directory-tree": "^2.2.5",
"yaml": "^1.10.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/runtime": "^7.0.0",
"@rollup/plugin-babel": "^5.0.0",
"@rollup/plugin-commonjs": "^14.0.0",
"@rollup/plugin-node-resolve": "^8.0.0",
"@rollup/plugin-replace": "^2.2.0",
"@rollup/plugin-typescript": "^6.0.0",
"@sveltejs/kit": "^1.0.0-next.201",
"@tsconfig/svelte": "^2.0.1",
"@types/compression": "^1.7.0",
"@types/node": "^14.11.1",
"@types/polka": "^0.5.1",
"cypress": "^9.0.0",
"cypress-cucumber-preprocessor": "^4.3.0",
"node-fetch": "^3.1.0",
"rollup": "^2.61.1",
"rollup-plugin-svelte": "^7.1.0",
"rollup-plugin-terser": "^7.0.0",
"serve": "^13.0.2",
"svelte": "^3.44.2",
"svelte-check": "^2.2.10",
"svelte-preprocess": "^4.9.8",
"tslib": "^2.0.1",
"typescript": "^4.0.3",
"vite": "^2.7.1"
}
}
5 changes: 4 additions & 1 deletion src/components/Directory.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<script context="module" lang="ts">
export const router = false;
export const hydrate = false;

// query params from apache index directory
type Sort = {
column:
Expand Down Expand Up @@ -141,7 +144,7 @@
</tbody>
</table>
<address>
{directory.meta.description || "SvelteKit/1.0.0-next.196 Server"}
{directory.meta.description || "SvelteKit/1.0.0-next.201 Server"}
</address>
</div>

Expand Down
5 changes: 5 additions & 0 deletions src/components/Piece.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
<script context="module" lange="ts">
export const router = false;
export const prerender = true;
</script>

<script lang="ts">
import BookPlaylist from "../plugins/BookPlaylist.svelte";
import {
Expand Down
18 changes: 16 additions & 2 deletions src/routes/_pieces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,19 @@ export function find(
return find(found, slug.slice(1));
}

// a very bad replacement for node 16 string.replaceAll
function replaceAll(str: string, regex: RegExp, replacer: (substring: string, ...args: any[]) => string): string {
let prev = str;
for (let i = 0; i < 1000; i++) {
let curr = prev.replace(regex, replacer);
if (prev === curr) {
return curr;
}
prev = curr;
}
throw new Error("we may be recurring")
}

// ideally this would go in the svelte code, i guess? but i want this preprocessing
// to always happen on the backend, or, more specifically, i don't want it to happen
// on the browser.
Expand All @@ -284,15 +297,16 @@ export function processScene(scene: Scene): ProcessedScene {

scene.sections.forEach((section) => {
let index = 0;
let content = section.content.replaceAll(
let content = replaceAll(
section.content,
footnoteRegex,
(_, group): string => {
index++;
footnotes.push(group);
return `<sup class="footnote-ref">${index}</sup>`;
}
);
content = content.replaceAll(/\*([^=*]+?)\*/g, "<i>$1</i>")
content = content.replace(/\*([^=*]+?)\*/g, "<i>$1</i>")

processedSections.push({
...section,
Expand Down
5 changes: 3 additions & 2 deletions svelte.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import adapter from '@sveltejs/adapter-static';
import adapter from '@sveltejs/adapter-netlify';
import preprocess from 'svelte-preprocess';

/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter(),
target: '#svelte'
target: '#svelte',
router: false,
},
preprocess: preprocess(),
};
Expand Down
Loading