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

Fix actions #28

Merged
merged 3 commits into from
Jul 22, 2024
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
32 changes: 12 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,42 +1,34 @@
name: Build
on: [push, pull_request]

env:
PNPM_CACHE_FOLDER: .pnpm-store

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.PNPM_CACHE_FOLDER }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
path: ~/.bun/install/cache
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-pnpm-

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '17'
check-latest: true

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6
- name: Install bun
uses: oven-sh/setup-bun@v2

- name: Install Dependencies
run: pnpm i
run: bun i

- name: Check style
run: bun run lint

- name: Check for errors
run: pnpm check
run: bun run check

- name: Build
run: pnpm build
run: bun run build
31 changes: 13 additions & 18 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
name: Build
on: [pull_request]

env:
PNPM_CACHE_FOLDER: .pnpm-store

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
submodules: true

- name: Cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.PNPM_CACHE_FOLDER }}
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
path: ~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('**/bun.lockb') }}
restore-keys: |
${{ runner.os }}-pnpm-
${{ runner.os }}-bun-

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: '17'
check-latest: true
- name: Install bun
uses: oven-sh/setup-bun@v2

- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 6
- name: Install dependencies
run: bun i

- name: Check types
run: bun run check

- name: Check style
run: pnpm lint
run: bun run lint
Binary file modified bun.lockb
Binary file not shown.
100 changes: 53 additions & 47 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
{
"name": "westrom.xyz",
"private": true,
"license": "AGPL-3.0-or-later",
"type": "module",
"scripts": {
"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",
"dev": "vite dev",
"lint": "prettier --ignore-path .gitignore --check .",
"format": "prettier --ignore-path .gitignore --write .",
"ci": "pnpm check && pnpm lint && pnpm build"
},
"pre-commit": [
"format"
],
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.0",
"@sveltejs/kit": "^1.0.1",
"@types/highlight.js": "^10.1.0",
"@types/html-minifier": "^4.0.2",
"@types/showdown": "^2.0.6",
"autoprefixer": "^10.4.13",
"html-minifier": "^4.0.0",
"postcss": "^8.4.20",
"postcss-load-config": "^4.0.1",
"postcss-nested": "^5.0.6",
"postcss-scss": "^4.0.6",
"prettier": "^2.8.1",
"prettier-plugin-svelte": "^2.9.0",
"remark-frontmatter": "^5.0.0",
"remark-html": "^16.0.1",
"sass": "^1.57.1",
"showdown": "^2.1.0",
"svelte": "^3.55.0",
"svelte-check": "^2.10.2",
"svelte-loader": "^3.1.4",
"svelte-preprocess": "^4.10.7",
"typescript": "^4.9.4",
"vite": "^4.0.2",
"yaml": "^2.4.5"
},
"dependencies": {
"highlight.js": "^11.7.0",
"modern-normalize": "^1.1.0"
}
"name": "westrom.xyz",
"private": true,
"license": "AGPL-3.0-or-later",
"type": "module",
"scripts": {
"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",
"dev": "vite dev",
"lint": "prettier --ignore-path .gitignore --check .",
"format": "prettier --ignore-path .gitignore --write .",
"ci": "bun run check && bun run lint && bun run build"
},
"pre-commit": [
"format"
],
"devDependencies": {
"@sveltejs/adapter-static": "^1.0.0",
"@sveltejs/kit": "^1.0.1",
"@types/highlightjs": "^9.12.6",
"@types/html-minifier": "^4.0.2",
"@types/showdown": "^2.0.6",
"autoprefixer": "^10.4.13",
"html-minifier": "^4.0.0",
"postcss": "^8.4.20",
"postcss-load-config": "^4.0.1",
"postcss-nested": "^5.0.6",
"postcss-scss": "^4.0.6",
"prettier": "^2.8.1",
"prettier-plugin-svelte": "^2.9.0",
"rehype-highlight": "^7.0.0",
"rehype-raw": "^7.0.0",
"rehype-shift-heading": "^2.0.0",
"rehype-stringify": "^10.0.0",
"remark-frontmatter": "^5.0.0",
"remark-html": "^16.0.1",
"remark-parse": "^11.0.0",
"remark-rehype": "^11.1.0",
"sass": "^1.57.1",
"showdown": "^2.1.0",
"svelte": "^3.55.0",
"svelte-check": "^2.10.2",
"svelte-loader": "^3.1.4",
"svelte-preprocess": "^4.10.7",
"typescript": "^4.9.4",
"vite": "^4.0.2",
"yaml": "^2.4.5"
},
"dependencies": {
"highlight.js": "^11.7.0",
"modern-normalize": "^1.1.0"
}
}
2 changes: 1 addition & 1 deletion posts
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface BlogPost extends VFile {
}

export interface BlogPostMetadata extends VFileData {
filePath?: PathLike;
filepath?: PathLike;
title?: string;
tags?: string;
subtitle?: string;
Expand Down
32 changes: 18 additions & 14 deletions src/lib/process-md.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import fs from 'fs';
import path from 'path';
import type { VFile } from 'vfile';

import langClojure from 'highlight.js/lib/languages/clojure';
import type { Options as RehypeHighlightOptions } from 'rehype-highlight';

import yaml from 'yaml';

import { unified } from 'unified';
import { unified, type Plugin } from 'unified';
import type { Literal, Node, Parent } from 'unist';

import remarkParse from 'remark-parse';
import remarkFrontmatter from 'remark-frontmatter';
import remarkRehype from 'remark-rehype';
Expand All @@ -21,18 +24,19 @@ const options: RehypeHighlightOptions = {
}
};

function extractMetadata() {
return (tree: { children: any[]; }, file: { data: any; }) => {
const yamlNode = tree.children.find(node => node.type === 'yaml')
if (yamlNode) {
file.data = yaml.parse(yamlNode.value)
}
}
function extractMetadataFromFrontmatter() {
return (tree: Parent, file: VFile) => {
const yamlNode = tree.children.find((node: Node) => node.type === 'yaml') as Literal;
if (yamlNode) {
file.data = yaml.parse(yamlNode.value as string);
}
};
}

const processor = unified()
.use(remarkParse)
.use(remarkFrontmatter, ['yaml'])
.use(extractMetadata)
.use(remarkParse as Plugin)
.use(remarkFrontmatter as Plugin)
.use(extractMetadataFromFrontmatter)
.use(remarkRehype)
.use(rehypeRaw)
.use(rehypeHighlight, options)
Expand All @@ -41,11 +45,11 @@ const processor = unified()

import type { BlogPost } from '..';
// converts markdown document into html and js.
export function processMd(filepath: fs.PathLike) {
export function processMd(filepath: fs.PathLike): BlogPost {
const markdown_doc = fs.readFileSync(filepath, 'utf8');
const processed_document = processor.processSync(markdown_doc);

processed_document.data.filepath = path.basename(filepath as string, ".md");
processed_document.data.filepath = path.basename(filepath as string, '.md');

return processed_document;
return processed_document as BlogPost;
}
4 changes: 2 additions & 2 deletions src/routes/contact/ContactLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<li>
<span>{name}</span>
<ExternalLink {href}>
<svg><use href="/icons/{icon}.svg#icon" /></svg>
<img src="icons/{icon}.svg" alt="{name} Link" />
</ExternalLink>
</li>

Expand All @@ -21,7 +21,7 @@
justify-items: center;
}

svg {
img {
align-self: center;
width: 4rem;
height: 4rem;
Expand Down
15 changes: 9 additions & 6 deletions src/routes/portfolio/PortfolioLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@

<li class="portfoliolink_container">
<ExternalLink {href} {target} isPortfolioLink>
<svg class="before"><use href="/icons/{icon}.svg#icon" /></svg><slot /><svg class="after"
><use href="/icons/external-link.svg#icon" /></svg
>
</ExternalLink>
<img src="/icons/{icon}.svg" class="before" alt="icon" />
<span id="content"
><slot /><span>
<img src="/icons/external-link.svg" class="after" alt="link icon" />
</span></span
></ExternalLink
>
</li>

<style lang="postcss">
:global(li.portfoliolink_container > a.portfolio) {
:global(li.portfoliolink_container > .portfolio) {
display: flex;
grid-auto-flow: column;
align-items: center;
margin: 0.25rem 0;
}

svg {
img {
width: 1.5em;
height: 1.5em;

Expand Down