Skip to content

Commit

Permalink
feat: add anchor links to headers in posts
Browse files Browse the repository at this point in the history
  • Loading branch information
zanechua committed Jul 27, 2021
1 parent d4a60c7 commit 5fec9d0
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
11 changes: 11 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ module.exports = {
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-autolink-headers`,
options: {
offsetY: `100`,
icon: `<svg id="header-anchor-icon" aria-hidden="true" height="20" version="1.1" viewBox="0 0 16 16" width="20"><path d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg>`,
className: `remark-header-anchor`,
maintainCase: true,
removeAccents: true,
isIconAfterHeader: true,
},
},
{
resolve: `gatsby-remark-images`,
options: {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"gatsby-plugin-react-helmet": "^4.8.0",
"gatsby-plugin-sharp": "^3.8.0",
"gatsby-plugin-sitemap": "^4.6.0",
"gatsby-remark-autolink-headers": "^4.7.0",
"gatsby-remark-external-links": "^0.0.4",
"gatsby-remark-images": "^5.5.0",
"gatsby-remark-prismjs": "^5.5.0",
Expand Down
9 changes: 9 additions & 0 deletions src/css/markdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@
@apply mb-6;
}

.markdown a.remark-header-anchor {
@apply -mb-0.5;
}

.markdown a #header-anchor-icon {
@apply fill-current;
@apply text-blue-500;
}

/* Images */
.markdown img {
}
Expand Down
2 changes: 1 addition & 1 deletion src/posts/04-macos-windows-proxmox.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ I think for most of us, we have the front IO on our case for easy usb access and

All in all, this was a fun side project to work on and make usable. I am sure I'll still be making small improvements here and there but the gist of the information is here. I was wrecking my brains out at how to get all of this working at the start but this should serve as a good summary/build log for my future self when I revisit this topic again. If you've made it this far, thanks for reading! If you've any questions, ping me on twitter [@zanejchua][10] as I still haven't gotten comments set-up on my site.

#### References:
#### References
* [https://gist.github.com/tavinus/08a63e7269e0f70d27b8fb86db596f0d][1]
* [https://pve.proxmox.com/wiki/Package_Repositories#sysadmin_no_subscription_repo][2]
* [https://www.nicksherlock.com/2020/04/installing-macos-catalina-on-proxmox-with-opencore/][3]
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7243,6 +7243,17 @@ gatsby-recipes@^0.20.0:
xstate "^4.9.1"
yoga-layout-prebuilt "^1.9.6"

gatsby-remark-autolink-headers@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/gatsby-remark-autolink-headers/-/gatsby-remark-autolink-headers-4.7.0.tgz#d9ec2b106d88dfdf350f5019da62c1b8959baacc"
integrity sha512-afBTKEoBUBakmS48QKrjSuTWUrmx5KDXGexIbbl3sP8ty3/dsAe2XWs8HJPKSrSqa/KOSF3R6WQ6Iis7l7q5Ew==
dependencies:
"@babel/runtime" "^7.14.6"
github-slugger "^1.3.0"
lodash "^4.17.21"
mdast-util-to-string "^2.0.0"
unist-util-visit "^2.0.3"

gatsby-remark-external-links@^0.0.4:
version "0.0.4"
resolved "https://registry.yarnpkg.com/gatsby-remark-external-links/-/gatsby-remark-external-links-0.0.4.tgz#85b98c1e9dacfaa58085319648c904ff3cab42f0"
Expand Down Expand Up @@ -7701,7 +7712,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/github-from-package/-/github-from-package-0.0.0.tgz#97fb5d96bfde8973313f20e8288ef9a167fa64ce"
integrity sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4=

github-slugger@^1.2.1:
github-slugger@^1.2.1, github-slugger@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/github-slugger/-/github-slugger-1.3.0.tgz#9bd0a95c5efdfc46005e82a906ef8e2a059124c9"
integrity sha512-gwJScWVNhFYSRDvURk/8yhcFBee6aFjye2a7Lhb2bUyRulpIoek9p0I9Kt7PT67d/nUlZbFu8L9RLiA0woQN8Q==
Expand Down

0 comments on commit 5fec9d0

Please sign in to comment.