some blog work

This commit is contained in:
core 2023-06-30 20:38:42 -04:00
parent a5fb571fac
commit 85afa80eb4
Signed by: core
GPG Key ID: FDBF740DADDCEECF
7 changed files with 198 additions and 1 deletions

View File

@ -14,13 +14,16 @@
"devDependencies": { "devDependencies": {
"@sveltejs/adapter-auto": "^2.0.0", "@sveltejs/adapter-auto": "^2.0.0",
"@sveltejs/kit": "^1.5.0", "@sveltejs/kit": "^1.5.0",
"@types/prismjs": "^1.26.0",
"@typescript-eslint/eslint-plugin": "^5.45.0", "@typescript-eslint/eslint-plugin": "^5.45.0",
"@typescript-eslint/parser": "^5.45.0", "@typescript-eslint/parser": "^5.45.0",
"eslint": "^8.28.0", "eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0", "eslint-config-prettier": "^8.5.0",
"eslint-plugin-svelte": "^2.26.0", "eslint-plugin-svelte": "^2.26.0",
"mdsvex": "^0.11.0",
"prettier": "^2.8.0", "prettier": "^2.8.0",
"prettier-plugin-svelte": "^2.8.1", "prettier-plugin-svelte": "^2.8.1",
"prismjs": "^1.29.0",
"svelte": "^3.54.0", "svelte": "^3.54.0",
"svelte-check": "^3.0.1", "svelte-check": "^3.0.1",
"tslib": "^2.4.1", "tslib": "^2.4.1",

13
src/lib/PostLayout.svelte Normal file
View File

@ -0,0 +1,13 @@
<script lang="ts">
export let title = 'Untitled';
export let published = '';
</script>
<svelte:head>
<title>{title} - blog - coredoesdev</title>
</svelte:head>
<h1>{title}</h1>
<time>{new Date(published).toLocaleDateString()}</time>
<slot />

View File

@ -1,3 +1,51 @@
<script lang="ts">
// Prism core
import Prism from "prismjs";
// Prism theme
import "prismjs/themes/prism-twilight.css";
// Prism languages
import "prismjs/components/prism-rust.js";
import "prismjs/components/prism-diff.js";
// Prism plugins
import "prismjs/plugins/line-numbers/prism-line-numbers.js"; // Line numbers
import "prismjs/plugins/line-numbers/prism-line-numbers.css"; // Line numbers
import "prismjs/plugins/line-highlight/prism-line-highlight.js"; // Line highlight
import "prismjs/plugins/line-highlight/prism-line-highlight.css"; // Line highlight
import "prismjs/plugins/autolinker/prism-autolinker.js"; // Autolinker
import "prismjs/plugins/autolinker/prism-autolinker.css"; // Autolinker
import "prismjs/plugins/toolbar/prism-toolbar.css"; // Toolbar
import "prismjs/plugins/toolbar/prism-toolbar.js"; // Toolbar
import "prismjs/plugins/show-language/prism-show-language.js"; // Show Language (broken?)
import "prismjs/plugins/copy-to-clipboard/prism-copy-to-clipboard.js"; // Copy to Clipboard
import "prismjs/plugins/download-button/prism-download-button.js"; // Download Button
import "prismjs/plugins/match-braces/prism-match-braces.css"; // Match Braces
import "prismjs/plugins/match-braces/prism-match-braces.js"; // Match Braces
import "prismjs/plugins/diff-highlight/prism-diff-highlight.css"; // Diff Highlight
import "prismjs/plugins/diff-highlight/prism-diff-highlight.js"; // Diff Highlight
import "prismjs/plugins/treeview/prism-treeview.css"; // Treeview
import "prismjs/plugins/treeview/prism-treeview.js"; // Treeview
import {onMount} from "svelte";
onMount(() => {
window.Prism = window.Prism || {};
window.Prism.manual = true;
Prism.highlightAll();
})
</script>
<svelte:head> <svelte:head>
<link rel="stylesheet" href="/css/common.css"> <link rel="stylesheet" href="/css/common.css">
</svelte:head> </svelte:head>

View File

@ -0,0 +1,13 @@
<script lang="ts">
import PostContent from "./page.svx";
import Bar from "$components/Bar.svelte";
import Content from "$components/Content.svelte";
</script>
<Bar selected="none"/>
<Content offset="10">
<PostContent />
</Content>

View File

@ -0,0 +1,29 @@
---
title: Blog Test
published: 2023-06-30T22:22:19+0000
---
# Testing out the blog system
i wanted to make a new blog lol
so, uh Ahere we are!
```rust?lines=2-3
pub fn code_highlighting() {
// lines can be highlighted
println!("works!");
// links are converted: https://example.com
}
```
Diff's work too:
```diff-rust
pub fn code_highlighting() {
// lines can be highlighted
- println!("works!");
+ let foo = 1;
// links are converted: https://example.com
}
```

View File

@ -1,11 +1,57 @@
import adapter from '@sveltejs/adapter-auto'; import adapter from '@sveltejs/adapter-auto';
import { vitePreprocess } from '@sveltejs/kit/vite'; import { vitePreprocess } from '@sveltejs/kit/vite';
import {mdsvex} from "mdsvex";
function escapeBraces(unsafe)
{
return unsafe
.replace(/{/g, "&#123;")
.replace(/}/g, "&#125;");
}
function highlighter(code, lang) {
// Lang can be:
// just the lang ('rust')
// the lang, then in brackets lines to hightlight ('rust[1-5,9,21-23]')
let params = new URLSearchParams(lang.split('?')[1]);
let real_lang = lang.split('?')[0];
let classes = [`language-${real_lang}`];
let props = "";
if (params.has("lines")) {
props += `data-line="${params.get("lines")}" `;
}
if (params.has("src")) {
props += `data-src="${params.get("src")}" `;
}
if (params.has("enableDownload")) {
props += "data-download-link ";
}
if (params.has("downloadLabel")) {
props += `data-download-link-label="${params.get("downloadLabel")}" `;
}
return `<pre class="rainbow-braces diff-highlight line-numbers match-braces ${classes}" ${props}><code class="language-${real_lang}" ${props}>${escapeBraces(code)}</code></pre>`
}
/** @type {import('@sveltejs/kit').Config} */ /** @type {import('@sveltejs/kit').Config} */
const config = { const config = {
// Consult https://kit.svelte.dev/docs/integrations#preprocessors // Consult https://kit.svelte.dev/docs/integrations#preprocessors
// for more information about preprocessors // for more information about preprocessors
preprocess: vitePreprocess(), preprocess: [
vitePreprocess(),
mdsvex({
extensions: ['.svx'],
layout: './src/lib/PostLayout.svelte',
highlight: {
highlighter
}
})
],
extensions: ['.svelte', '.svx'],
kit: { kit: {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.

View File

@ -268,6 +268,11 @@
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb" resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.12.tgz#d70faba7039d5fca54c83c7dbab41051d2b6f6cb"
integrity sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA== integrity sha512-Hr5Jfhc9eYOQNPYO5WLDq/n4jqijdHNlDXjuAQkkt+mWdQR+XJToOHrsD4cPaMXpn6KO7y2+wM8AZEs8VpBLVA==
"@types/prismjs@^1.26.0":
version "1.26.0"
resolved "https://registry.yarnpkg.com/@types/prismjs/-/prismjs-1.26.0.tgz#a1c3809b0ad61c62cac6d4e0c56d610c910b7654"
integrity sha512-ZTaqn/qSqUuAq1YwvOFQfVW1AR/oQJlLSZVustdjwI+GZ8kr0MSHBj0tsXPW1EqHubx50gtBEjbPGsdZwQwCjQ==
"@types/pug@^2.0.6": "@types/pug@^2.0.6":
version "2.0.6" version "2.0.6"
resolved "https://registry.yarnpkg.com/@types/pug/-/pug-2.0.6.tgz#f830323c88172e66826d0bde413498b61054b5a6" resolved "https://registry.yarnpkg.com/@types/pug/-/pug-2.0.6.tgz#f830323c88172e66826d0bde413498b61054b5a6"
@ -278,6 +283,11 @@
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.0.tgz#591c1ce3a702c45ee15f47a42ade72c2fd78978a"
integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw== integrity sha512-G8hZ6XJiHnuhQKR7ZmysCeJWE08o8T0AXtk5darsCaTVsYZhhgUrq53jizaR2FvsoeCwJhlmwTjkXBY5Pn/ZHw==
"@types/unist@^2.0.0", "@types/unist@^2.0.2", "@types/unist@^2.0.3":
version "2.0.6"
resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d"
integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ==
"@typescript-eslint/eslint-plugin@^5.45.0": "@typescript-eslint/eslint-plugin@^5.45.0":
version "5.59.8" version "5.59.8"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz#1e7a3e5318ece22251dfbc5c9c6feeb4793cc509" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.59.8.tgz#1e7a3e5318ece22251dfbc5c9c6feeb4793cc509"
@ -1012,6 +1022,16 @@ magic-string@^0.30.0:
dependencies: dependencies:
"@jridgewell/sourcemap-codec" "^1.4.13" "@jridgewell/sourcemap-codec" "^1.4.13"
mdsvex@^0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/mdsvex/-/mdsvex-0.11.0.tgz#d6672406abbf341933d60c9bfebd39ffb893f851"
integrity sha512-gJF1s0N2nCmdxcKn8HDn0LKrN8poStqAicp6bBcsKFd/zkUBGLP5e7vnxu+g0pjBbDFOscUyI1mtHz+YK2TCDw==
dependencies:
"@types/unist" "^2.0.3"
prism-svelte "^0.4.7"
prismjs "^1.17.1"
vfile-message "^2.0.4"
merge2@^1.3.0, merge2@^1.4.1: merge2@^1.3.0, merge2@^1.4.1:
version "1.4.1" version "1.4.1"
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae"
@ -1196,6 +1216,16 @@ prettier@^2.8.0:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
prism-svelte@^0.4.7:
version "0.4.7"
resolved "https://registry.yarnpkg.com/prism-svelte/-/prism-svelte-0.4.7.tgz#fbc6709450b4e2ed660ddb82c3718817fc584cbe"
integrity sha512-yABh19CYbM24V7aS7TuPYRNMqthxwbvx6FF/Rw920YbyBWO3tnyPIqRMgHuSVsLmuHkkBS1Akyof463FVdkeDQ==
prismjs@^1.17.1, prismjs@^1.29.0:
version "1.29.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.29.0.tgz#f113555a8fa9b57c35e637bba27509dcf802dd12"
integrity sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==
punycode@^2.1.0: punycode@^2.1.0:
version "2.3.0" version "2.3.0"
resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.3.0.tgz#f67fa67c94da8f4d0cfff981aee4118064199b8f"
@ -1462,6 +1492,13 @@ undici@~5.22.0:
dependencies: dependencies:
busboy "^1.6.0" busboy "^1.6.0"
unist-util-stringify-position@^2.0.0:
version "2.0.3"
resolved "https://registry.yarnpkg.com/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz#cce3bfa1cdf85ba7375d1d5b17bdc4cada9bd9da"
integrity sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==
dependencies:
"@types/unist" "^2.0.2"
uri-js@^4.2.2: uri-js@^4.2.2:
version "4.4.1" version "4.4.1"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
@ -1469,6 +1506,14 @@ uri-js@^4.2.2:
dependencies: dependencies:
punycode "^2.1.0" punycode "^2.1.0"
vfile-message@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-2.0.4.tgz#5b43b88171d409eae58477d13f23dd41d52c371a"
integrity sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==
dependencies:
"@types/unist" "^2.0.0"
unist-util-stringify-position "^2.0.0"
vite@^4.3.0: vite@^4.3.0:
version "4.3.9" version "4.3.9"
resolved "https://registry.yarnpkg.com/vite/-/vite-4.3.9.tgz#db896200c0b1aa13b37cdc35c9e99ee2fdd5f96d" resolved "https://registry.yarnpkg.com/vite/-/vite-4.3.9.tgz#db896200c0b1aa13b37cdc35c9e99ee2fdd5f96d"