{"id":16259691,"url":"https://github.com/hetari/vuejs-code-block","last_synced_at":"2025-03-19T22:30:59.268Z","repository":{"id":257812718,"uuid":"864079674","full_name":"Hetari/vuejs-code-block","owner":"Hetari","description":"\u003c/\u003e Set of basic styled UI components to build powerful code blocks in Vue 🧩","archived":false,"fork":false,"pushed_at":"2024-11-16T15:42:03.000Z","size":1119,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T11:50:29.703Z","etag":null,"topics":["code-blocks","component","highlight","typescript","ui-components","unstyled","unstyled-components","vue","vue-typescript","vue3","vuejs","vuejs-components","vuejs-library","vuejs3"],"latest_commit_sha":null,"homepage":"https://hetari.github.io/vuejs-code-block/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hetari.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-27T13:04:12.000Z","updated_at":"2025-02-21T13:01:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"70edffd6-75f2-4896-94d0-65eb5d9ba129","html_url":"https://github.com/Hetari/vuejs-code-block","commit_stats":{"total_commits":68,"total_committers":2,"mean_commits":34.0,"dds":"0.014705882352941124","last_synced_commit":"3e05688364eb2d10092f5ef6f3bf6fd3d28cd4e8"},"previous_names":["hetari/vuejs-code-block"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hetari%2Fvuejs-code-block","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hetari%2Fvuejs-code-block/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hetari%2Fvuejs-code-block/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hetari%2Fvuejs-code-block/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hetari","download_url":"https://codeload.github.com/Hetari/vuejs-code-block/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244515624,"owners_count":20464923,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-blocks","component","highlight","typescript","ui-components","unstyled","unstyled-components","vue","vue-typescript","vue3","vuejs","vuejs-components","vuejs-library","vuejs3"],"created_at":"2024-10-10T16:04:21.605Z","updated_at":"2025-03-19T22:30:59.263Z","avatar_url":"https://github.com/Hetari.png","language":"TypeScript","readme":"# Vuejs Code Block\n\n## Enjoying my project? Please show your appreciation by starring it on GitHub! ⭐\n\n[![NPM version](https://img.shields.io/npm/v/vuejs-code-block.svg)](https://www.npmjs.com/package/vuejs-code-block)\n\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://hetari.github.io/vuejs-code-block/\"\u003e\n    \u003cimg src=\"./docs/public/logo.webp\" width=\"250\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\n\u003e [!IMPORTANT]\n\u003e For now this package has default themes, but in the future, it will be fully unstyled, allowing you to style it however you like.\n\n## Installation\n\nTo get started, install the package via npm:\n\n```bash\nnpm install vuejs-code-block\n```\n\nAlternatively, if you're using Yarn:\n\n```bash\nyarn add vuejs-code-block\n```\n\n## Basic Usage\n\nOnce installed, you can start using the `CodeBlock` component in your `Vue 3` app to display syntax-highlighted code. Here’s a simple example:\n\n```vue ts:line-numbers {1}\n\u003ctemplate\u003e\n  \u003cCodeBlock\n    :code=\"code\"\n    :numbered=\"true\"\n    :show-header=\"true\"\n    file-name=\"codeBlock.ts\"\n    language=\"ts\"\n    theme=\"dracula\"\u003e\n  \u003c/CodeBlock\u003e\n\u003c/template\u003e\n\n\u003cscript setup lang=\"ts\"\u003e\n  import { CodeBlock } from './components/code-block';\n  const code = `const name =  'Vuejs Code Block';\nconst usrls = {\n  github: 'https://github.com/hetari/vuejs-code-block',\n  docs: 'https://hetari.github.io/vuejs-code-block/'\n};`;\n\u003c/script\u003e\n```\n\n\u003e [!WARNING] WARNING ❗\n\u003e Make sure the content of the `codeExample` string does **NOT** have leading spaces.\n\u003e The code should be formatted like this:\n\u003e\n\u003e ```ts\n\u003e const codeExample = `\n\u003e function greet(name) {\n\u003e   console.log('Hello, ' + name);\n\u003e }\n\u003e \n\u003e greet('World');\n\u003e `;\n\u003e ```\n\u003e\n\u003e Avoid writing it with leading spaces like this:\n\u003e\n\u003e ```ts\n\u003e const codeExample = `\n\u003e   function greet(name) {\n\u003e     console.log('Hello, ' + name);\n\u003e   }\n\u003e \n\u003e   greet('World');\n\u003e `;\n\u003e ```\n\u003e\n\u003e Incorrect formatting may cause unexpected whitespace in the code block.\n\n\u003c!-- - **`codeClass`** (optional): A custom CSS class for the `\u003ccode\u003e` element inside the block. This allows you to style the code content specifically. --\u003e\n\u003c!-- - **`linesHighlighted`** (optional): An array of line numbers to be highlighted. Accepts an array of strings or numbers (e.g., `[1, 3]` to highlight the 1st and 3rd lines). --\u003e\n\u003c!-- - **`wordsHighlighted`** (optional): An array of specific words to be highlighted within the code. Accepts an array of strings (e.g., `['console', 'log']`). --\u003e\n\n## Props:\n\n| Prop         | Type      | Required | Default | Description                                                                                |\n| ------------ | --------- | -------- | ------- | ------------------------------------------------------------------------------------------ |\n| `code`       | `string`  | Yes      | N/A     | The code you want to display, passed as a string.                                          |\n| `language`   | `string`  | Yes      | N/A     | Specifies the programming language for syntax highlighting.                                |\n| `theme`      | `string`  | Yes      | N/A     | Specifies the theme to be used for syntax highlighting (light or dark).                    |\n| `asElement`  | `string`  | No       | `\u003cpre\u003e` | Defines the HTML element wrapping the code block (defaults to `\u003cpre\u003e`).                    |\n| `numbered`   | `boolean` | No       | `false` | Displays line numbers when set to `true`.                                                  |\n| `showHeader` | `boolean` | No       | `true`  | Displays the code block header (title, language icon, and copy button) when set to `true`. |\n| `file-name`  | `string`  | No       | N/A     | The name of the file to be displayed in the header.                                        |\n\n\u003c!-- ## Custom Styling\n\nOne of the key features of **vuejs-code-block** is that it provides **unstyled** components, allowing you to style them however you like. For example, using CSS or Tailwind classes:\n\n```vue\n\u003ctemplate\u003e\n  \u003cdiv class=\"p-4 bg-gray-800 rounded-lg\"\u003e\n    \u003cCodeBlock\n      theme=\"dark\"\n      :code=\"exampleCode\"\n      language=\"javascript\" /\u003e\n  \u003c/div\u003e\n\u003c/template\u003e\n\n\u003cscript setup\u003e\n  import { CodeBlock } from 'vuejs-code-block';\n\n  const exampleCode = `function greet(name) {\n  console.log('Hello, ' + name);\n}\n\ngreet('World');\n`;\n\u003c/script\u003e\n```\n--\u003e\n\n## Themes:\n\n| Theme Name                  | Image                                                                 |\n| --------------------------- | --------------------------------------------------------------------- |\n| Dracula                     | ![Dracula Theme](./docs/public/draculaTheme.webp)                     |\n| Duotone Dark                | ![Duotone Dark Theme](./docs/public/duotoneDarkTheme.webp)            |\n| Duotone Light               | ![Duotone Light Theme](./docs/public/duotoneLightTheme.webp)          |\n| GitHub                      | ![GitHub Theme](./docs/public/githubTheme.webp)                       |\n| Night Owl                   | ![Night Owl Theme](./docs/public/nightOwlTheme.webp)                  |\n| None                        | ![None](./docs/public/none.webp)                                      |\n| Oceanic Next                | ![Oceanic Next Theme](./docs/public/oceanicNextTheme.webp)            |\n| Prism Dark                  | ![Prism Dark Theme](./docs/public/prismDarkTheme.webp)                |\n| Prism Funky                 | ![Prism Funky Theme](./docs/public/prismFunkyTheme.webp)              |\n| Prism Okaidia               | ![Prism Okaidia Theme](./docs/public/prismOkaidiaTheme.webp)          |\n| Prism Solarized Light Theme | ![Prism Solarized Light](./docs/public/prismSolarizedLightTheme.webp) |\n| Prism                       | ![Prism Theme](./docs/public/prismTheme.webp)                         |\n| Prism Theme Coy             | ![Prism Theme Coy](./docs/public/prismThemeCoy.webp)                  |\n| Prism Tomorrow              | ![Prism Tomorrow Theme](./docs/public/prismTomorrowTheme.webp)        |\n| Prism Twilight              | ![Prism Twilight Theme](./docs/public/prismTwilightTheme.webp)        |\n| Shades of Purple            | ![Shades of Purple](./docs/public/shadesOfPurple.webp)                |\n| UltraMin                    | ![UltraMin Theme](./docs/public/ultraminTheme.webp)                   |\n| VS Dark                     | ![VS Dark Theme](./docs/public/vsDarkTheme.webp)                      |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhetari%2Fvuejs-code-block","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhetari%2Fvuejs-code-block","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhetari%2Fvuejs-code-block/lists"}