Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gatsby-remark-autolink-headers

Package Overview
Dependencies
Maintainers
2
Versions
535
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gatsby-remark-autolink-headers - npm Package Compare versions

Comparing version 1.5.0-alpha.22c8a6f1 to 1.5.0-alpha.2b695217

15

gatsby-browser.js

@@ -1,9 +0,9 @@

"use strict";
var scrollToHash = function scrollToHash(offsetY) {
// Make sure React has had a change to flush to DOM first.
// Make sure React has had a chance to flush to DOM first.
setTimeout(function () {
var hash = window.location.hash.replace("#", "");
var hash = window.decodeURI(window.location.hash.replace("#", ""));
if (hash !== "") {
var element = document.getElementById(hash);
if (element) {

@@ -19,7 +19,9 @@ var offset = element.offsetTop;

var offsetY = 0;
if (pluginOptions.offsetY) {
offsetY = pluginOptions.offsetY;
}
// This code is only so scrolling to header hashes works in development.
} // This code is only so scrolling to header hashes works in development.
// For production, the equivalent code is in gatsby-ssr.js.
if (process.env.NODE_ENV !== "production") {

@@ -32,2 +34,3 @@ scrollToHash(offsetY);

var offsetY = 0;
if (pluginOptions.offsetY) {

@@ -34,0 +37,0 @@ offsetY = pluginOptions.offsetY;

25

gatsby-ssr.js
"use strict";
var _react = require("react");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _react2 = _interopRequireDefault(_react);
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.onRenderBody = function (_ref, pluginOptions) {
var setHeadComponents = _ref.setHeadComponents;
var offsetY = 0;
var offsetY = 0;
if (pluginOptions.offsetY) {

@@ -18,13 +16,12 @@ offsetY = pluginOptions.offsetY;

var styles = "\n .anchor {\n float: left;\n padding-right: 4px;\n margin-left: -20px;\n }\n h1 .anchor svg,\n h2 .anchor svg,\n h3 .anchor svg,\n h4 .anchor svg,\n h5 .anchor svg,\n h6 .anchor svg {\n visibility: hidden;\n }\n h1:hover .anchor svg,\n h2:hover .anchor svg,\n h3:hover .anchor svg,\n h4:hover .anchor svg,\n h5:hover .anchor svg,\n h6:hover .anchor svg {\n visibility: visible;\n }\n ";
var script = "\n document.addEventListener(\"DOMContentLoaded\", function(event) {\n var hash = location.hash.replace('#', '')\n if (hash !== '') {\n var element = document.getElementById(hash)\n if (element) {\n var offset = element.offsetTop\n // Wait for the browser to finish rendering before scrolling.\n setTimeout((function() {\n window.scrollTo(0, offset - " + offsetY + ")\n }), 0)\n }\n }\n })\n ";
return setHeadComponents([_react2.default.createElement(
"style",
{ key: "gatsby-remark-autolink-headers-style", type: "text/css" },
styles
), _react2.default.createElement("script", {
var script = "\n document.addEventListener(\"DOMContentLoaded\", function(event) {\n var hash = window.decodeURI(location.hash.replace('#', ''))\n if (hash !== '') {\n var element = document.getElementById(hash)\n if (element) {\n var offset = element.offsetTop\n // Wait for the browser to finish rendering before scrolling.\n setTimeout((function() {\n window.scrollTo(0, offset - " + offsetY + ")\n }), 0)\n }\n }\n })\n ";
return setHeadComponents([_react.default.createElement("style", {
key: "gatsby-remark-autolink-headers-style",
type: "text/css"
}, styles), _react.default.createElement("script", {
key: "gatsby-remark-autolink-headers-script",
dangerouslySetInnerHTML: { __html: script }
dangerouslySetInnerHTML: {
__html: script
}
})]);
};

@@ -1,5 +0,5 @@

"use strict";
var toString = require("mdast-util-to-string");
var toString = require("mdast-util-to-string");
var visit = require("unist-util-visit");
var slugs = require("github-slugger")();

@@ -14,11 +14,9 @@

}
module.exports = function (_ref) {
var markdownAST = _ref.markdownAST;
slugs.reset();
visit(markdownAST, "heading", function (node) {
var id = slugs.slug(toString(node));
var data = patch(node, "data", {});
patch(data, "id", id);

@@ -29,3 +27,2 @@ patch(data, "htmlAttributes", {});

patch(data.hProperties, "id", id);
node.children.unshift({

@@ -48,4 +45,3 @@ type: "link",

});
return markdownAST;
};
{
"name": "gatsby-remark-autolink-headers",
"description": "Gatsby plugin to autolink headers in markdown processed by Remark",
"version": "1.5.0-alpha.22c8a6f1",
"version": "1.5.0-alpha.2b695217",
"author": "Kyle Mathews <mathews.kyle@gmail.com>",
"dependencies": {
"babel-runtime": "6.26.0",
"@babel/runtime": "^7.0.0-beta.38",
"github-slugger": "^1.1.1",

@@ -13,3 +13,5 @@ "mdast-util-to-string": "^1.0.2",

"devDependencies": {
"babel-cli": "^6.24.1"
"@babel/cli": "^7.0.0-beta.38",
"@babel/core": "^7.0.0-beta.38",
"cross-env": "^5.0.5"
},

@@ -24,5 +26,6 @@ "keywords": [

"scripts": {
"build": "babel src --out-dir . --ignore __tests__",
"watch": "babel -w src --out-dir . --ignore __tests__"
"build": "babel src --out-dir . --ignore ./**/__tests__/",
"watch": "babel -w src --out-dir . --ignore ./**/__tests__/",
"prepublish": "cross-env NODE_ENV=production npm run build"
}
}
# gatsby-remark-autolink-headers
Adds Github-style links to `MarkdownRemark` headers.
Adds GitHub-style links to `MarkdownRemark` headers.

@@ -17,8 +17,6 @@ ## Install

options: {
plugins: [
`gatsby-remark-autolink-headers`,
]
}
}
]
plugins: [`gatsby-remark-autolink-headers`],
},
},
];
```

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc