File tree 1 file changed +13
-0
lines changed
1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,7 @@ require(["core/pubsubhub"], (respecEvents) => {
177
177
require ( [ "core/pubsubhub" ] , ( respecEvents ) => {
178
178
"use strict" ;
179
179
respecEvents . sub ( 'end-all' , ( documentElement ) => {
180
+ // Add example button selection logic
180
181
for ( const button of document . querySelectorAll ( ".ds-selector-tabs .selectors button" ) ) {
181
182
button . onclick = ( ) => {
182
183
const ex = button . closest ( ".ds-selector-tabs" ) ;
@@ -186,6 +187,18 @@ require(["core/pubsubhub"], (respecEvents) => {
186
187
ex . querySelector ( "." + button . dataset . selects ) . classList . add ( "selected" ) ;
187
188
}
188
189
}
190
+
191
+ // Add playground links
192
+ for ( const link of document . querySelectorAll ( "a.playground" ) ) {
193
+ // First pre element of aside
194
+ const pre = link . closest ( "aside" ) . querySelector ( "pre" ) ;
195
+ const content = unComment ( document , pre . textContent )
196
+ . replace ( / ( \* \* \* \* | # # # # ) / g, '' ) ;
197
+ link . setAttribute ( 'aria-label' , 'playground link' ) ;
198
+ link . setAttribute ( 'href' ,
199
+ 'https://json-ld.org/playground-dev/#startTab=tab-expanded&json-ld=' +
200
+ encodeURI ( content ) ) ;
201
+ }
189
202
} ) ;
190
203
} ) ;
191
204
You can’t perform that action at this time.
0 commit comments