diff --git a/astro.config.mjs b/astro.config.mjs index 002886c..1168d9a 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,17 +1,36 @@ +import rehypePrettyCode from "rehype-pretty-code"; import { defineConfig } from "astro/config"; import partytown from "@astrojs/partytown"; import tailwind from "@astrojs/tailwind"; import sitemap from "@astrojs/sitemap"; import compress from "astro-compress"; +import remarkToc from "remark-toc"; import mdx from "@astrojs/mdx"; +const options = { + theme: "one-dark-pro", + onVisitLine(node) { + // Prevent lines from collapsing in `display: grid` mode, and allow empty lines to be copy/pasted + if (node.children.length === 0) { + node.children = [{ type: "text", value: " " }]; + } + }, + onVisitHighlightedLine(node) { + node.properties.className.push("highlighted"); + }, + onVisitHighlightedWord(node) { + node.properties.className = ["word"]; + }, +}; + // https://astro.build/config export default defineConfig({ site: "https://nir.galons.io", integrations: [sitemap(), tailwind({ config: { applyBaseStyles: false } }), partytown(), mdx(), compress()], markdown: { - shikiConfig: { - theme: "dracula-soft", - }, + rehypePlugins: [[rehypePrettyCode, options]], + syntaxHighlight: false, + remarkPlugins: [remarkToc], + extendDefaultPlugins: true, // Preserve Astro's default plugins: GitHub-flavored Markdown and Smartypants }, }); diff --git a/package-lock.json b/package-lock.json index cc068b4..b75b8c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,6 +19,8 @@ "algoliasearch": "^4.14.2", "astro": "^1.2.6", "astro-compress": "^1.0.12", + "rehype-pretty-code": "^0.4.0", + "remark-toc": "^8.0.1", "tailwindcss": "^3.1.8" }, "devDependencies": { @@ -1318,6 +1320,16 @@ "@types/estree": "*" } }, + "node_modules/@types/extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/extend/-/extend-3.0.1.tgz", + "integrity": "sha512-R1g/VyKFFI2HLC1QGAeTtCBWCo6n75l41OnsVYNbmKG+kempOESaodf6BeJyUM3Q0rKa/NQcTHbB2+66lNnxLw==" + }, + "node_modules/@types/github-slugger": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@types/github-slugger/-/github-slugger-1.3.0.tgz", + "integrity": "sha512-J/rMZa7RqiH/rT29TEVZO4nBoDP9XJOjnbbIofg7GQKs4JIduEO3WLpte+6WeUz/TcrXKlY+bM7FYrp8yFB+3g==" + }, "node_modules/@types/hast": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz", @@ -5309,6 +5321,52 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/mdast-util-toc": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-toc/-/mdast-util-toc-6.1.0.tgz", + "integrity": "sha512-0PuqZELXZl4ms1sF7Lqigrqik4Ll3UhbI+jdTrfw7pZ9QPawgl7LD4GQ8MkU7bT/EwiVqChNTbifa2jLLKo76A==", + "dependencies": { + "@types/extend": "^3.0.0", + "@types/github-slugger": "^1.0.0", + "@types/mdast": "^3.0.0", + "extend": "^3.0.0", + "github-slugger": "^1.0.0", + "mdast-util-to-string": "^3.1.0", + "unist-util-is": "^5.0.0", + "unist-util-visit": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-toc/node_modules/unist-util-visit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", + "integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==", + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/mdast-util-toc/node_modules/unist-util-visit-parents": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", + "integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==", + "dependencies": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/mdn-data": { "version": "2.0.28", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", @@ -6456,6 +6514,11 @@ "url": "https://github.com/sponsors/wooorm" } }, + "node_modules/parse-numeric-range": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/parse-numeric-range/-/parse-numeric-range-1.3.0.tgz", + "integrity": "sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ==" + }, "node_modules/parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", @@ -7078,6 +7141,20 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/rehype-pretty-code": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/rehype-pretty-code/-/rehype-pretty-code-0.4.0.tgz", + "integrity": "sha512-Bp91nfo4blpgCXlvGP1hsG+kRFfjqBVU09o1RFcnNA62u+iIzJiJRGzpfBj4FaItq7CEQL5ASGB7vLxN5xCvyA==", + "dependencies": { + "parse-numeric-range": "^1.3.0" + }, + "engines": { + "node": "^12.16.0 || >=13.2.0" + }, + "peerDependencies": { + "shiki": "*" + } + }, "node_modules/rehype-raw": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-6.1.1.tgz", @@ -7230,6 +7307,20 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remark-toc": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/remark-toc/-/remark-toc-8.0.1.tgz", + "integrity": "sha512-7he2VOm/cy13zilnOTZcyAoyoolV26ULlon6XyCFU+vG54Z/LWJnwphj/xKIDLOt66QmJUgTyUvLVHi2aAElyg==", + "dependencies": { + "@types/mdast": "^3.0.0", + "mdast-util-toc": "^6.0.0", + "unified": "^10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", @@ -10412,6 +10503,16 @@ "@types/estree": "*" } }, + "@types/extend": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/extend/-/extend-3.0.1.tgz", + "integrity": "sha512-R1g/VyKFFI2HLC1QGAeTtCBWCo6n75l41OnsVYNbmKG+kempOESaodf6BeJyUM3Q0rKa/NQcTHbB2+66lNnxLw==" + }, + "@types/github-slugger": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@types/github-slugger/-/github-slugger-1.3.0.tgz", + "integrity": "sha512-J/rMZa7RqiH/rT29TEVZO4nBoDP9XJOjnbbIofg7GQKs4JIduEO3WLpte+6WeUz/TcrXKlY+bM7FYrp8yFB+3g==" + }, "@types/hast": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.4.tgz", @@ -13200,6 +13301,42 @@ "resolved": "https://registry.npmjs.org/mdast-util-to-string/-/mdast-util-to-string-3.1.0.tgz", "integrity": "sha512-n4Vypz/DZgwo0iMHLQL49dJzlp7YtAJP+N07MZHpjPf/5XJuHUWstviF4Mn2jEiR/GNmtnRRqnwsXExk3igfFA==" }, + "mdast-util-toc": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/mdast-util-toc/-/mdast-util-toc-6.1.0.tgz", + "integrity": "sha512-0PuqZELXZl4ms1sF7Lqigrqik4Ll3UhbI+jdTrfw7pZ9QPawgl7LD4GQ8MkU7bT/EwiVqChNTbifa2jLLKo76A==", + "requires": { + "@types/extend": "^3.0.0", + "@types/github-slugger": "^1.0.0", + "@types/mdast": "^3.0.0", + "extend": "^3.0.0", + "github-slugger": "^1.0.0", + "mdast-util-to-string": "^3.1.0", + "unist-util-is": "^5.0.0", + "unist-util-visit": "^3.0.0" + }, + "dependencies": { + "unist-util-visit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-3.1.0.tgz", + "integrity": "sha512-Szoh+R/Ll68QWAyQyZZpQzZQm2UPbxibDvaY8Xc9SUtYgPsDzx5AWSk++UUt2hJuow8mvwR+rG+LQLw+KsuAKA==", + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0", + "unist-util-visit-parents": "^4.0.0" + } + }, + "unist-util-visit-parents": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-4.1.1.tgz", + "integrity": "sha512-1xAFJXAKpnnJl8G7K5KgU7FY55y3GcLIXqkzUj5QF/QVP7biUm0K0O2oqVkYsdjzJKifYeWn9+o6piAK2hGSHw==", + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^5.0.0" + } + } + } + }, "mdn-data": { "version": "2.0.28", "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.28.tgz", @@ -13917,6 +14054,11 @@ "unist-util-visit-children": "^1.0.0" } }, + "parse-numeric-range": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/parse-numeric-range/-/parse-numeric-range-1.3.0.tgz", + "integrity": "sha512-twN+njEipszzlMJd4ONUYgSfZPDxgHhT9Ahed5uTigpQn90FggW4SA/AIPq/6a149fTbE9qBEcSwE3FAEp6wQQ==" + }, "parse-passwd": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/parse-passwd/-/parse-passwd-1.0.0.tgz", @@ -14336,6 +14478,14 @@ "unified": "^10.0.0" } }, + "rehype-pretty-code": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/rehype-pretty-code/-/rehype-pretty-code-0.4.0.tgz", + "integrity": "sha512-Bp91nfo4blpgCXlvGP1hsG+kRFfjqBVU09o1RFcnNA62u+iIzJiJRGzpfBj4FaItq7CEQL5ASGB7vLxN5xCvyA==", + "requires": { + "parse-numeric-range": "^1.3.0" + } + }, "rehype-raw": { "version": "6.1.1", "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-6.1.1.tgz", @@ -14446,6 +14596,16 @@ "unified": "^10.0.0" } }, + "remark-toc": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/remark-toc/-/remark-toc-8.0.1.tgz", + "integrity": "sha512-7he2VOm/cy13zilnOTZcyAoyoolV26ULlon6XyCFU+vG54Z/LWJnwphj/xKIDLOt66QmJUgTyUvLVHi2aAElyg==", + "requires": { + "@types/mdast": "^3.0.0", + "mdast-util-toc": "^6.0.0", + "unified": "^10.0.0" + } + }, "require-from-string": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz", diff --git a/package.json b/package.json index d29e8e2..732ee11 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,8 @@ "algoliasearch": "^4.14.2", "astro": "^1.2.6", "astro-compress": "^1.0.12", + "rehype-pretty-code": "^0.4.0", + "remark-toc": "^8.0.1", "tailwindcss": "^3.1.8" }, "devDependencies": { diff --git a/public/posts/2022/github-email/contributions-heat-map.webp b/public/posts/2022/github-email/contributions-heat-map.webp deleted file mode 100644 index 3885801..0000000 Binary files a/public/posts/2022/github-email/contributions-heat-map.webp and /dev/null differ diff --git a/public/posts/2022/github-email/github-contributions-graph.webp b/public/posts/2022/github-email/github-contributions-graph.webp new file mode 100644 index 0000000..e2b886f Binary files /dev/null and b/public/posts/2022/github-email/github-contributions-graph.webp differ diff --git a/public/posts/2022/github-email/github-private-email.webp b/public/posts/2022/github-email/github-private-email.webp new file mode 100644 index 0000000..a2b39b0 Binary files /dev/null and b/public/posts/2022/github-email/github-private-email.webp differ diff --git a/public/posts/2022/github-email/google-email.webp b/public/posts/2022/github-email/google-email.webp new file mode 100644 index 0000000..25e7493 Binary files /dev/null and b/public/posts/2022/github-email/google-email.webp differ diff --git a/public/terminal-dots.svg b/public/terminal-dots.svg new file mode 100644 index 0000000..5eef600 --- /dev/null +++ b/public/terminal-dots.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/components/Header.astro b/src/components/Header.astro index 96a6914..aa8a39e 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,18 +1,44 @@ -
- - Nir Galon - - -
- Blog +
+ +
diff --git a/src/layouts/BlogPost.astro b/src/layouts/BlogPost.astro index 680337d..0085499 100644 --- a/src/layouts/BlogPost.astro +++ b/src/layouts/BlogPost.astro @@ -14,6 +14,7 @@ export interface Props { const { content: { title, pubDate, author, authorLink, category, featuredImage }, + headings, } = Astro.props; const WORDS_PER_MINUTE = 200; @@ -69,13 +70,13 @@ const readTime = Math.ceil(numberOfWords / WORDS_PER_MINUTE);
-
+
- + > -->

CONTENTS

-

1. Request a Quota

-

2. Create the VM

-

3. Install CUDA and Hashcat

-

4. Let's get down to business

-

5. Summary

+ { + headings.map((header: Record<"depth" | "slug" | "text", string>) => ( + + {header.text} + + )) + }
@@ -109,57 +112,84 @@ const readTime = Math.ceil(numberOfWords / WORDS_PER_MINUTE); diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 372f66f..0b5fe5a 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -78,6 +78,7 @@ const { title } = Astro.props as Props; html { font-family: "Helvetica Neue", sans-serif !important; @apply h-full; + @apply scroll-smooth; } body { @apply h-full; diff --git a/src/pages/about.astro b/src/pages/about.astro index 3d3a7b6..131ac4c 100644 --- a/src/pages/about.astro +++ b/src/pages/about.astro @@ -425,7 +425,7 @@ repos = repos.sort((a, b) => Number(b.stars) - Number(a.stars));
{ repos.map((repo) => ( -
+

{repo.name}

diff --git a/src/pages/blog/2022/design-system.md b/src/pages/blog/2022/design-system.md index 061b438..a07d054 100644 --- a/src/pages/blog/2022/design-system.md +++ b/src/pages/blog/2022/design-system.md @@ -29,8 +29,8 @@ But first, what is a "Design System"? It's a little different if you ask a desig The first thing we need to do is actually create a regular [Vue.js](https://vuejs.org) project -```bash -$ npm init vue@latest +```bash showLineNumbers title=" " +npm init vue@latest ``` You'll be presented with prompts for a number of optional features, choose whatever you want, it's not importent for the rest of the tutorial. But, if you want to see my choices - they're in the screenshot below. @@ -43,14 +43,14 @@ After we have an empty vue.js project (I called mine `daisy` because Daisy the D The next setp is to install [Storybook](https://storybook.js.org). The current version is 6.x, but I choose to install the beta (7.x) version because it's close enough to release and there are a lot of changes that integrate well with our setup (like vite and typescript support out of the box). -```bash -$ npx sb@next init --builder=vite +```bash showLineNumbers title=" " +npx sb@next init --builder=vite ``` And once the Storybook CLI done running and doing it's thing, we can run it and see our storybook default components and documentation in action -```bash -$ npm run storybook +```bash showLineNumbers title=" " +npm run storybook ``` ![Storybook](/posts/2022/design-system/storybook.webp "Storybook") @@ -59,14 +59,14 @@ $ npm run storybook The last thing we need to do is to add [Tailwind CSS](https://tailwindcss.com) support to our Vue.js components and as well as our Storybook UI. Adding it to the vuejs project is really easy -```bash -$ npm install -D tailwindcss postcss autoprefixer -$ npx tailwindcss init -p +```bash showLineNumbers title=" " +npm install -D tailwindcss postcss autoprefixer +npx tailwindcss init -p ``` And all you have left to do is to edit your `content` section (in `tailwind.config.js` file) to include the vuejs files -```js +```js showLineNumbers title="tailwind.js" {3} /** @type {import('tailwindcss').Config} */ module.exports = { content: ["./src/**/*.{vue,js,ts,jsx,tsx}"], @@ -79,7 +79,7 @@ module.exports = { Lastly, include the Tailwind directives to our CSS by creating a new `style.css` file inside the `src` directory and add to it the @tailwind directives: -```css +```css showLineNumbers title="style.css" @tailwind base; @tailwind components; @tailwind utilities; @@ -91,13 +91,13 @@ Now if you'll lunch your Vue.js app (`npm run dev`) Tailwind class will work, bu To fix this we'll use a [Storybook addon](https://storybook.js.org/addons/@storybook/addon-postcss) to run the PostCSS preprocessor against our stories -```bash -$ npm install -D @storybook/addon-postcss +```bash showLineNumbers title=" " +npm install -D @storybook/addon-postcss ``` -then add it to the `.storybook/main.js` file +then add it -```js +```js showLineNumbers title=".storybook/main.js" {8-15} const path = require("path"); module.exports = { stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], @@ -121,9 +121,9 @@ module.exports = { }; ``` -and also import the `style.css` file in `.storybook/preview.js` +and also import the `style.css` file -```js +```js showLineNumbers title=".storybook/preview.js" {1} import "../src/style.css"; export const parameters = { @@ -145,14 +145,14 @@ Building our first component is just like building a regular Vue.js component, e I'll call my component `Foo` and create a directory with that name in the `components` directory (I'll actually call it `DyFoo` because [ESlint require component names to always be multi-word](https://eslint.vuejs.org/rules/multi-word-component-names.html), and `D` is the first letter of our Design System name, and `Y` is the last), and I'll also create a `.vue` and a `.stories.js` files with the same component name. -```bash -$ touch src/components/DyFoo/DyFoo.vue -$ touch src/components/DyFoo/DyFoo.stories.js +```bash showLineNumbers title=" " +touch src/components/DyFoo/DyFoo.vue +touch src/components/DyFoo/DyFoo.stories.js ``` My `DyFoo.vue` component will be fairly easy, it'll take `variant` prop with `primary` or `secondary` options and give the text `foo` some color based on them. -```vue +```vue showLineNumbers title="DyFoo.vue"