docs: copy to clipboard support

This commit is contained in:
Divyansh Singh 2023-03-23 14:45:23 +05:30
parent 0a72c67c6c
commit 66d2f49f18
3 changed files with 7 additions and 1 deletions

View file

@ -1,4 +1,5 @@
const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight"); const pluginSyntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const codeClipboard = require("eleventy-plugin-code-clipboard");
const inclusiveLangPlugin = require("@11ty/eleventy-plugin-inclusive-language"); const inclusiveLangPlugin = require("@11ty/eleventy-plugin-inclusive-language");
const navigationPlugin = require("@11ty/eleventy-navigation"); const navigationPlugin = require("@11ty/eleventy-navigation");
@ -6,6 +7,7 @@ module.exports = function(eleventyConfig) {
eleventyConfig.addPlugin(pluginSyntaxHighlight); eleventyConfig.addPlugin(pluginSyntaxHighlight);
eleventyConfig.addPlugin(inclusiveLangPlugin); eleventyConfig.addPlugin(inclusiveLangPlugin);
eleventyConfig.addPlugin(navigationPlugin); eleventyConfig.addPlugin(navigationPlugin);
eleventyConfig.addPlugin(codeClipboard);
let markdownIt = require("markdown-it"); let markdownIt = require("markdown-it");
let markdownItAnchor = require("markdown-it-anchor"); let markdownItAnchor = require("markdown-it-anchor");
@ -31,6 +33,7 @@ module.exports = function(eleventyConfig) {
markdownIt(markdownItOptions) markdownIt(markdownItOptions)
.use(markdownItAnchor, markdownItAnchorOptions) .use(markdownItAnchor, markdownItAnchorOptions)
.use(markdownItReplaceLink) .use(markdownItReplaceLink)
.use(codeClipboard.markdownItCopyButton)
); );
eleventyConfig.addPassthroughCopy({"docs/static": "static"}); eleventyConfig.addPassthroughCopy({"docs/static": "static"});

View file

@ -18,6 +18,7 @@ RUN npm install @11ty/eleventy \
@11ty/eleventy-plugin-syntaxhighlight \ @11ty/eleventy-plugin-syntaxhighlight \
@11ty/eleventy-plugin-inclusive-language \ @11ty/eleventy-plugin-inclusive-language \
@11ty/eleventy-navigation \ @11ty/eleventy-navigation \
eleventy-plugin-code-clipboard \
markdown-it \ markdown-it \
markdown-it-anchor \ markdown-it-anchor \
markdown-it-replace-link markdown-it-replace-link

View file

@ -18,10 +18,12 @@
{% if feedTitle and feedUrl %} {% if feedTitle and feedUrl %}
<link rel="alternate" href="{{ feedUrl }}" title="{{ feedTitle }}" type="application/atom+xml"> <link rel="alternate" href="{{ feedUrl }}" title="{{ feedTitle }}" type="application/atom+xml">
{% endif %} {% endif %}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@6.5.95/css/materialdesignicons.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Primer/19.1.1/tooltips.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head> </head>
<body> <body>
{{ content | safe }} {{ content | safe }}
{% initClipboardJS %}
</body> </body>
</html> </html>