Skip to content

Commit ff9ac81

Browse files
authored
repo sync
2 parents 4d6f946 + efed031 commit ff9ac81

File tree

9 files changed

+175
-31
lines changed

9 files changed

+175
-31
lines changed

content/actions/guides/building-and-testing-nodejs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ We recommend that you have a basic understanding of Node.js, YAML, workflow conf
3333
To get started quickly, add the template to the `.github/workflows` directory of your repository.
3434

3535
{% raw %}
36-
```yaml
36+
```yaml{:copy}
3737
name: Node.js CI
3838
3939
on: [push]

content/actions/quickstart.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ You only need an existing {% data variables.product.prodname_dotcom %} repositor
2121
1. From your repository on {% data variables.product.prodname_dotcom %}, create a new file in the `.github/workflows` directory named `superlinter.yml`. For more information, see "[Creating new files](/github/managing-files-in-a-repository/creating-new-files)."
2222
2. Copy the following YAML contents into the `superlinter.yml` file. **Note:** If your default branch is not `main`, update the value of `DEFAULT_BRANCH` to match your repository's default branch name.
2323
{% raw %}
24-
```yaml
24+
```yaml{:copy}
2525
name: Super-Linter
2626
2727
# Run this workflow every time a new commit pushed to your repository

contributing/content-markup-reference.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,22 @@ To render syntax highlighting in command line instructions, we use triple backti
4040

4141
### Usage
4242

43-
\`\`\`shell
44-
git init <em>YOUR_REPO</em>
45-
\`\`\`
43+
```shell
44+
git init <em>YOUR_REPO</em>
45+
```
4646

4747
This syntax highlighting renders light text on a dark background, and should be reserved for command line instructions.
4848

4949
Within the command-line syntax, you can also use the `<em>` helper tag to indicate content that varies for each user, such as a user or repository name.
5050

51+
**Copy-able code blocks**
52+
53+
You can also add a header that includes the name of the language and a button to copy the contents of the code block:
54+
55+
```js{:copy}
56+
const copyMe = true
57+
```
58+
5159
## Octicons
5260

5361
Octicons are icons used across GitHub’s interface. We reference Octicons when documenting the user interface. Find the name of the Octicon on the [Octicons site](https://primer.style/octicons). For accessibility purposes, use [the `aria-label` option](https://primer.style/octicons/packages/javascript#aria-label) to describe the Octicon.

javascripts/copy-code.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import Clipboard from 'clipboard'
2+
3+
export default () => {
4+
const clipboard = new Clipboard('button.js-btn-copy')
5+
6+
clipboard.on('success', evt => {
7+
const btn = evt.trigger
8+
const beforeTooltip = btn.getAttribute('aria-label')
9+
btn.setAttribute('aria-label', 'Copied!')
10+
11+
setTimeout(() => {
12+
btn.setAttribute('aria-label', beforeTooltip)
13+
}, 2000)
14+
})
15+
}

javascripts/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import print from './print'
1313
import localization from './localization'
1414
import helpfulness from './helpfulness'
1515
import experiment from './experiment'
16+
import copyCode from './copy-code'
1617
import { fillCsrf } from './get-csrf'
1718
import initializeEvents from './events'
1819

@@ -31,5 +32,6 @@ document.addEventListener('DOMContentLoaded', async () => {
3132
await fillCsrf() // this must complete before any POST calls
3233
helpfulness()
3334
experiment()
35+
copyCode()
3436
initializeEvents()
3537
})

package-lock.json

Lines changed: 128 additions & 24 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"@babel/runtime": "^7.11.2",
1616
"@github-docs/data-directory": "^1.2.0",
1717
"@github-docs/frontmatter": "^1.3.1",
18-
"@github-docs/render-content": "^5.0.0",
18+
"@github-docs/render-content": "^5.1.0",
1919
"@github/rest-api-operations": "^3.1.3",
2020
"@octokit/rest": "^16.38.1",
2121
"@primer/css": "^15.1.0",
@@ -26,6 +26,7 @@
2626
"browser-date-formatter": "^3.0.3",
2727
"change-case": "^3.1.0",
2828
"cheerio": "^1.0.0-rc.3",
29+
"clipboard": "^2.0.6",
2930
"compression": "^1.7.4",
3031
"connect-slashes": "^1.4.0",
3132
"cookie-parser": "^1.4.5",

0 commit comments

Comments
 (0)