astro-accelerator 0.0.74 → 0.0.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.74",
2
+ "version": "0.0.76",
3
3
  "author": "Steve Fenton",
4
4
  "name": "astro-accelerator",
5
5
  "description": "A super-lightweight, accessible, SEO-friendly starter project for Astro",
@@ -26,7 +26,7 @@
26
26
  "dependencies": {
27
27
  "@astrojs/mdx": "^0.18.2",
28
28
  "astro": "^2.1.7",
29
- "astro-accelerator-utils": "^0.2.23",
29
+ "astro-accelerator-utils": "^0.2.24",
30
30
  "hast-util-from-selector": "^2.0.1",
31
31
  "remark-directive": "^2.0.1",
32
32
  "sharp": "^0.31.3"
@@ -892,6 +892,31 @@ pre.astro-code code {
892
892
  transform: rotate(4deg);
893
893
  }
894
894
 
895
+ .bookmark-link {
896
+ margin-inline-start: 0.2em;
897
+ border-radius: var(--block-radius);
898
+ font-size: 0.5em;
899
+ text-decoration: none;
900
+ position: relative;
901
+ top: -0.5em;
902
+ color: var(--fore-link);
903
+ float: right;
904
+ overflow: hidden;
905
+ display: block;
906
+ width: 1.2em;
907
+ height: 1.5em;
908
+ opacity: 0.5;
909
+ }
910
+
911
+ .bookmark-link::before {
912
+ content: '🔗 ';
913
+ }
914
+
915
+ .bookmark-link:hover,
916
+ .bookmark-link:focus {
917
+ background-color: unset;
918
+ opacity: 1;
919
+ }
895
920
 
896
921
  .magnify-container {
897
922
  max-height: 0px;
package/public/js/main.js CHANGED
@@ -47,3 +47,8 @@ if (enabled(f.figures, 'enlarge')) {
47
47
  const figures = await import('./modules/figures.js');
48
48
  figures.enhanceFigures();
49
49
  }
50
+
51
+ if (enabled(f.headers, 'link')) {
52
+ const headers = await import('./modules/headers.js');
53
+ headers.enhanceHeaders();
54
+ }
@@ -0,0 +1,21 @@
1
+ import { qsa } from './query.js';
2
+
3
+ /**
4
+ * Enables copy on code blocks (<pre><code>...)
5
+ */
6
+ function enhanceHeaders() {
7
+
8
+ // Make code blocks focusable, so they can be keyboard scrolled
9
+ qsa('h2[id], h3[id], h4[id], h5[id], h6[id]').forEach((elem) => {
10
+ const linkContainer = document.createElement('a');
11
+ linkContainer.href = `#${elem.id}`;
12
+ linkContainer.className = 'bookmark-link';
13
+ linkContainer.innerHTML = 'Bookmark'
14
+ console.log(elem, typeof elem);
15
+ elem.appendChild(linkContainer);
16
+ });
17
+
18
+
19
+ }
20
+
21
+ export { enhanceHeaders }
package/src/config.ts CHANGED
@@ -35,6 +35,7 @@ const SITE: Site = {
35
35
  codeBlocks: ['copy'],
36
36
  figures: ['enlarge'],
37
37
  youTubeLinks: ['embed'],
38
+ headers: ['link'],
38
39
  },
39
40
  images: {
40
41
  // Generated using https://ausi.github.io/respimagelint/