Skip to content

Commit

Permalink
DRY workflows (#101)
Browse files Browse the repository at this point in the history
* DRY workflows

* update deps

* add matbench discovery banner to landing page

* fix eslint

/code/src/routes/+layout.server.ts
  10:11  error  Strings must use backtick  @typescript-eslint/quotes

✖ 1 problem (1 error, 0 warnings)
  1 error and 0 warnings potentially fixable with the `--fix` option.

/code/src/routes/posts/+layout.svelte
  13:51  error  Strings must use backtick  @typescript-eslint/quotes
  13:59  error  Strings must use backtick  @typescript-eslint/quotes

✖ 2 problems (2 errors, 0 warnings)
  2 errors and 0 warnings potentially fixable with the `--fix` option.
  • Loading branch information
janosh committed Apr 14, 2023
1 parent d3547da commit 228c121
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 60 deletions.
40 changes: 1 addition & 39 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,44 +5,6 @@ on:
branches: [main]
workflow_dispatch:

# set permissions of GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v3

- name: Set up node
uses: actions/setup-node@v3
with:
node-version: 18
cache: npm
cache-dependency-path: package.json

- name: Install dependencies
run: npm install

- name: Build site
run: npm run build

- name: Upload build artifact
uses: actions/upload-pages-artifact@v1
with:
path: build

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: janosh/workflows/.github/workflows/nodejs-gh-pages.yml@main
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,35 +29,35 @@
"check": "svelte-check"
},
"devDependencies": {
"@iconify/svelte": "^3.1.0",
"@iconify/svelte": "^3.1.1",
"@rollup/plugin-yaml": "^4.0.1",
"@sveltejs/adapter-static": "^2.0.1",
"@sveltejs/kit": "^1.13.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"@sveltejs/adapter-static": "^2.0.2",
"@sveltejs/kit": "^1.15.5",
"@typescript-eslint/eslint-plugin": "^5.58.0",
"@typescript-eslint/parser": "^5.58.0",
"devalue": "^4.3.0",
"eslint": "^8.36.0",
"eslint": "^8.38.0",
"eslint-plugin-svelte3": "^4.0.0",
"hast-util-from-string": "^2.0.0",
"hast-util-select": "^5.0.5",
"hastscript": "^7.2.0",
"js-yaml": "^4.1.0",
"katex": "^0.16.4",
"mdsvex": "^0.10.6",
"prettier": "^2.8.6",
"prettier": "^2.8.7",
"prettier-plugin-svelte": "^2.10.0",
"rehype-autolink-headings": "^6.1.1",
"rehype-katex-svelte": "^1.1.2",
"rehype-slug": "^5.1.0",
"remark-math": "3.0.0",
"svelte": "^3.57.0",
"svelte-check": "^3.1.4",
"svelte": "^3.58.0",
"svelte-check": "^3.2.0",
"svelte-multiselect": "^8.6.0",
"svelte-preprocess": "^5.0.3",
"svelte-preprocess-import-assets": "^0.2.6",
"svelte-preprocess-import-assets": "^1.0.0",
"svelte-zoo": "^0.4.3",
"svelte2tsx": "^0.6.10",
"typescript": "^5.0.2",
"svelte2tsx": "^0.6.11",
"typescript": "^5.0.4",
"vite": "^4.2.1"
}
}
2 changes: 1 addition & 1 deletion src/routes/+layout.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const load = async ({ url }) => {
).map(([file, post]) => ({
...post.metadata,
slug: file.split(`/`)[2],
path: '/' + file.split(`/`).slice(1, -1).join(`/`),
path: `/` + file.split(`/`).slice(1, -1).join(`/`),
file,
}))

Expand Down
17 changes: 17 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
engineering & data viz.
</p>

<strong>
Check out my latest work at <a href="https://matbench-discovery.materialsproject.org">
matbench-discovery.materialsproject.org</a
>
</strong>

<address>
<a href="https://github.com/janosh" target="_blank" rel="noreferrer">
<Icon inline icon="octicon:mark-github" />
Expand Down Expand Up @@ -56,4 +62,15 @@
gap: 1em;
font-size: 16pt;
}
strong {
text-align: center;
margin: 2em auto 3em;
background-color: darkcyan;
padding: 2pt 9pt;
border-radius: 9pt;
}
strong a {
color: #191960;
text-decoration: none;
}
</style>
2 changes: 1 addition & 1 deletion src/routes/posts/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</script>

{#if dev}
{#await import(`./${slug}/${cover?.img?.replace('.svg', '')}.svg`) then { default: src }}
{#await import(`./${slug}/${cover?.img?.replace(`.svg`, ``)}.svg`) then { default: src }}
<img {src} alt={cover?.caption} />
{/await}
{:else}
Expand Down
10 changes: 3 additions & 7 deletions svelte.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import katex from 'rehype-katex-svelte'
import heading_slugs from 'rehype-slug'
import math from 'remark-math'
import preprocess from 'svelte-preprocess'
import relative_imports from 'svelte-preprocess-import-assets'
import { importAssets } from 'svelte-preprocess-import-assets'

const macros = {
// Infinitesimal differential (used in derivatives and integrals)
Expand Down Expand Up @@ -87,18 +87,14 @@ export default {
remarkPlugins: [math],
extensions: [`.svx`, `.md`],
}),
relative_imports({
importAssets({
sources: (default_sources) => {
return [
...default_sources,
{
tag: `a`,
srcAttributes: [`href`],
filter({ attributes }) {
if (!attributes.href) return false

return attributes.href.endsWith(`.pdf`)
},
filter: (node) => node.attributes?.href.endsWith(`.pdf`),
},
]
},
Expand Down

0 comments on commit 228c121

Please sign in to comment.