Skip to content

Commit a406f48

Browse files
committed
fix: highlight links and styles
1 parent 82c0ce4 commit a406f48

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

example/nuxt.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export default {
6767
// Library
6868
css: [
6969
'modern-normalize/modern-normalize.css',
70-
'highlight.js/styles/github.css',
7170
'~assets/style.css',
7271
],
7372
head: {

example/pages/index.vue

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,12 @@
3838
computed: {
3939
readme: () => markdown,
4040
},
41-
mounted() {
41+
async mounted() {
4242
43-
this.$nextTick(
44-
() => {
43+
await this.$nextTick();
4544
46-
this.initHighlight();
47-
this.initReadmeLinks();
48-
49-
},
50-
);
45+
this.initReadmeLinks();
46+
this.initHighlight();
5147
5248
},
5349
methods: {
@@ -66,34 +62,34 @@
6662
},
6763
initReadmeLinks() {
6864
69-
const links = document.querySelectorAll(
70-
'.readme > article a, .readme > article pre',
65+
const LINKS = document.querySelectorAll(
66+
'.readme > article a',
7167
);
7268
73-
for( let i = 0; i < links.length; i ++ ) {
74-
75-
if( links[ i ].tagName === 'A' ) {
69+
LINKS.forEach(
70+
link => {
7671
77-
links[ i ].setAttribute(
72+
link.setAttribute(
7873
'target',
7974
'_blank',
8075
);
8176
82-
links[ i ].setAttribute(
77+
link.setAttribute(
8378
'rel',
8479
'noopener',
8580
);
8681
87-
links[ i ].setAttribute(
82+
link.setAttribute(
8883
'title',
89-
links[ i ].textContent,
84+
link.textContent,
9085
);
9186
9287
}
93-
94-
}
88+
);
9589
9690
},
9791
},
9892
};
9993
</script>
94+
95+
<style src="highlight.js/styles/github.css"></style>

0 commit comments

Comments
 (0)