Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
tsar-boomba committed May 1, 2024
1 parent 2117ebf commit d660597
Show file tree
Hide file tree
Showing 12 changed files with 12,966 additions and 8,526 deletions.
116 changes: 58 additions & 58 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
name: Deploy to Github Pages

on:
push:
branches:
- main
push:
branches:
- main

workflow_dispatch:
workflow_dispatch:

jobs:
pages-changes:
runs-on: ubuntu-latest
pages-changes:
runs-on: ubuntu-latest

outputs:
changed: ${{ contains(steps.changes.outputs.changes, 'not-api') && contains(steps.changes.outputs.changes, 'not-license') && contains(steps.changes.outputs.changes, 'not-readme') && contains(steps.changes.outputs.changes, 'not-vscode') }}
steps:
- uses: actions/checkout@v4
- name: Changes
id: changes
uses: dorny/paths-filter@v2
with:
base: "main"
# if a filter is false, it means that the only change matched it, so do not deploy
filters: |
not-license: '!LICENSE*'
not-readme: '!**/README*'
not-vscode: '!.vscode/**'
outputs:
changed: ${{ contains(steps.changes.outputs.changes, 'not-api') && contains(steps.changes.outputs.changes, 'not-license') && contains(steps.changes.outputs.changes, 'not-readme') && contains(steps.changes.outputs.changes, 'not-vscode') }}
steps:
- uses: actions/checkout@v4
- name: Changes
id: changes
uses: dorny/paths-filter@v2
with:
base: 'main'
# if a filter is false, it means that the only change matched it, so do not deploy
filters: |
not-license: '!LICENSE*'
not-readme: '!**/README*'
not-vscode: '!.vscode/**'
build-pages:
runs-on: ubuntu-latest
needs: pages-changes
if: ${{ needs.pages-changes.outputs.changed == 'true' }}
build-pages:
runs-on: ubuntu-latest
needs: pages-changes
if: ${{ needs.pages-changes.outputs.changed == 'true' }}

steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.2.2
with:
version: 8.15.3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "20"
cache: "pnpm"
- name: Build
run: |
pnpm i --frozen-lockfile
pnpm build
- name: Upload Artifact
uses: actions/upload-pages-artifact@v1
with:
path: dist/
retention-days: 2
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2.2.2
with:
version: 8.15.3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: '20'
cache: 'pnpm'
- name: Build
run: |
pnpm i --frozen-lockfile
pnpm build
- name: Upload Artifact
uses: actions/upload-pages-artifact@v1
with:
path: dist/
retention-days: 2

deploy-pages:
runs-on: ubuntu-latest
needs: [build-pages]
if: ${{ !failure() && !cancelled() && needs.build-pages.result == 'success' }}
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
deploy-pages:
runs-on: ubuntu-latest
needs: [build-pages]
if: ${{ !failure() && !cancelled() && needs.build-pages.result == 'success' }}
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pnpm-lock.yaml
4 changes: 2 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}
18 changes: 9 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"markdownlint.config": {
"hard_tab": false
}
}
}
62 changes: 37 additions & 25 deletions astro.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
import compress from 'astro-compress';
import mdx from '@astrojs/mdx';
import robotsTxt from 'astro-robots-txt';

Expand All @@ -10,7 +9,7 @@ import type { Root } from 'mdast';
import { createCssVariablesTheme, getHighlighter } from 'shiki';
import type { Highlighter, BuiltinLanguage } from 'shiki';
import { visit } from 'unist-util-visit';

import playformCompress from '@playform/compress';
const SUPPORTED_LANGS = [
'javascript',
'typescript',
Expand All @@ -23,19 +22,16 @@ const SUPPORTED_LANGS = [
'mdx',
'astro',
] as const satisfies BuiltinLanguage[];

type BlockParams = {
file?: string;
noBadge?: boolean;
};

const myTheme = createCssVariablesTheme({
name: 'css-variables',
variablePrefix: '--shiki-',
variableDefaults: {},
fontStyle: true,
});

let highlighterCache: Promise<Highlighter>;
const parseLangRe = /(?=(?:file=(?<file>\S*))?)(?=(?:noBadge=(?<noBadge>true|false))?)/g;
export const remarkCustomCodeBlock: () => Promise<Plugin<any[], Root>> = async () => {
Expand All @@ -45,39 +41,58 @@ export const remarkCustomCodeBlock: () => Promise<Plugin<any[], Root>> = async (
langs: SUPPORTED_LANGS,
});
const highlighter = await highlighterCache;

return () => (tree) => {
visit(tree, 'code', (node) => {
const rawLang = node.lang ?? 'plaintext';
const metaMatch = parseLangRe.exec(node.meta ?? '');

if (!metaMatch) {
return console.warn(
'Meta section of code fence should match format <file (optional)> <noBadge (true or false, optional)',
);
}

const { file, noBadge = false } = metaMatch.groups as unknown as BlockParams;

const langColorMap: { [K in BuiltinLanguage]?: { bg: string; fg: string } } = {
css: { bg: '#264de4', fg: '#fff' },
ts: { bg: '#007acc', fg: '#fff' },
tsx: { bg: '#007acc', fg: '#fff' },
java: { bg: '#ed8b00', fg: '#fff' },
rust: { bg: '#dea584', fg: '#fff' },
astro: { bg: '#ff5a03', fg: '#fff' },
toml: { bg: '#9c4221', fg: '#fff' },
const langColorMap: {
[K in BuiltinLanguage]?: {
bg: string;
fg: string;
};
} = {
css: {
bg: '#264de4',
fg: '#fff',
},
ts: {
bg: '#007acc',
fg: '#fff',
},
tsx: {
bg: '#007acc',
fg: '#fff',
},
java: {
bg: '#ed8b00',
fg: '#fff',
},
rust: {
bg: '#dea584',
fg: '#fff',
},
astro: {
bg: '#ff5a03',
fg: '#fff',
},
toml: {
bg: '#9c4221',
fg: '#fff',
},
};

const lang: BuiltinLanguage = (() => {
const lang = rawLang as BuiltinLanguage;

if (lang === 'typescript') return 'ts';
if (lang === 'javascript') return 'js';
if (lang === 'rs') return 'rust';
return lang;
})();

let codeHtml: string = highlighter.codeToHtml(node.value, {
lang,
theme: 'css-variables',
Expand All @@ -93,9 +108,7 @@ export const remarkCustomCodeBlock: () => Promise<Plugin<any[], Root>> = async (
!noBadge
? `<div
class='language-badge'
style='background-color:${langColorMap[lang]?.bg ?? '#888'};color:${
langColorMap[lang]?.fg ?? '#fff'
}'
style='background-color:${langColorMap[lang]?.bg ?? '#888'};color:${langColorMap[lang]?.fg ?? '#fff'}'
>
${lang.toUpperCase()}
</div>`
Expand All @@ -105,7 +118,6 @@ export const remarkCustomCodeBlock: () => Promise<Plugin<any[], Root>> = async (
</div>
</div>
`.trim();

node.value = html;
(node as any).type = 'html';
(node as any).children = [];
Expand All @@ -126,11 +138,11 @@ export default defineConfig({
// Enable Preact to support Preact JSX components.
integrations: [
sitemap(),
compress(),
mdx(),
robotsTxt({
sitemap: true,
}),
playformCompress(),
],
markdown: {
syntaxHighlight: false,
Expand Down
29 changes: 14 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,38 @@
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"format": "prettier --write .",
"astro": "astro"
},
"devDependencies": {
"@astrojs/mdx": "2.1.1",
"@astrojs/sitemap": "3.0.5",
"@astrojs/check": "^0.5.4",
"@astrojs/mdx": "2.3.1",
"@astrojs/sitemap": "3.1.4",
"@types/mdast": "4.0.3",
"@typescript-eslint/eslint-plugin": "7.0.1",
"@typescript-eslint/parser": "7.0.1",
"astro": "4.4.0",
"astro-compress": "2.2.10",
"@typescript-eslint/eslint-plugin": "7.8.0",
"@typescript-eslint/parser": "7.8.0",
"astro": "4.7.0",
"astro-robots-txt": "1.0.0",
"autoprefixer": "10.4.17",
"cssnano": "6.0.3",
"autoprefixer": "10.4.19",
"cssnano": "7.0.1",
"eslint": "8.56.0",
"eslint-config-prettier": "9.1.0",
"eslint-mdx": "3.1.5",
"eslint-plugin-astro": "0.31.4",
"eslint-plugin-jsx-a11y": "6.8.0",
"eslint-plugin-mdx": "3.1.5",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-react": "7.33.2",
"mdast": "3.0.0",
"postcss-preset-env": "9.3.0",
"prettier": "3.2.5",
"sass": "1.71.0",
"shiki": "1.1.3",
"shiki": "1.4.0",
"svgo": "3.2.0",
"unified": "11.0.4",
"@astrojs/check": "^0.5.4",
"unist-util-visit": "5.0.0"
"unist-util-visit": "5.0.0",
"@playform/compress": "^0.0.3",
"typescript": "^5.3.3"
},
"dependencies": {
"astro-icon": "1.1.0",
"typescript": "^5.3.3"
"astro-icon": "1.1.0"
}
}
Loading

0 comments on commit d660597

Please sign in to comment.