Skip to content

fix(typescript): added typescript support #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default defineBuildConfig({
jsxFactory: 'h'
}
},
{ builder: 'mkdist', input: './src', pattern: ['**/*.js'], format: 'cjs', loaders: ['js'], ext: 'cjs' },
{ builder: 'mkdist', input: './src', pattern: ['**/*.js'], format: 'esm', loaders: ['js'], ext: 'js' }
{ builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'cjs', loaders: ['js'], ext: 'cjs' },
{ builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'esm', loaders: ['js'], ext: 'js' }
],
declaration: true,
clean: true,
Expand Down
23 changes: 8 additions & 15 deletions docs/.vitepress/config.js → docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
// import { defineConfig } from 'vitepress';

// // https://vitepress.dev/reference/site-config
// export default defineConfig({
// title: 'Vue Semantic Structure',
// description: 'Helper for semantic HTML structure.',
// themeConfig: {
// // https://vitepress.dev/reference/default-theme-config
// }
// });

import { fileURLToPath } from 'url';
import { defineConfig } from 'vitepress';
import { DefaultTheme, defineConfig, ThemeOptions, UserConfig } from 'vitepress';
import markdownItInlineComments from 'markdown-it-inline-comments';
import navigation from './navigation.js';

// https://vitepress.dev/reference/site-config
export default defineConfig(() => ({
export default defineConfig({
head: [
['link', { rel: 'apple-touch-icon', sizes: '180x180', href: '/apple-touch-icon.png' }],

Expand Down Expand Up @@ -68,7 +56,12 @@ export default defineConfig(() => ({
sitemap: {
hostname: 'https://basics.github.io/vue-semantic-structure/'
}
}));
} as UserConfig<DefaultTheme.Config> & {
themeConfig: ThemeOptions & {
logoComponent: boolean;
socialLinks: { icon: string; link: string }[];
};
});

function getBaseUrl() {
return process.env.npm_config_base_url || process.env.BASE_URL || '/';
Expand Down
File renamed without changes.
File renamed without changes.
14 changes: 12 additions & 2 deletions docs/src/components/content-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ The appropriate HTML element for the page structure is determined based on the `

## Properties

```ts
type Props = {
tag?: string;
rootTags?: string[];
contentTags?: string[];
level?: number;
debug?: boolean;
};
```

### tag

- Type: `String`
Expand All @@ -27,7 +37,7 @@ Tag for the element.

### rootTags

- Type: `Array`
- Type: `Array<String>`
- Default: `inject('semanticStructure_rootTags', ['main'])`

Available tags for the root structure.
Expand All @@ -36,7 +46,7 @@ Available tags for the root structure.

### contentTags

- Type: `Array`
- Type: `Array<String>`
- Default: `inject('semanticStructure_contentTags', ['article', 'section'])`

Available tags for the content structure.
Expand Down
7 changes: 7 additions & 0 deletions docs/src/components/content-headline.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ The deeper the nesting, the smaller the heading.

## Properties

```ts
type Props = {
tag: string;
debug: boolean;
};
```

### tag

- Type: `String`
Expand Down
27 changes: 22 additions & 5 deletions docs/src/composables/use-content-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ const { currentTag } = useContentContainer();

## Options

```ts
type ContentContainerOptions = {
tag?: string | undefined;
contentTags?: Array<string>;
rootTags?: Array<string>;
level?: number;
};
```

| Property | Type | Description | Default Value |
| ------------- | -------- | ----------------------------------------- | --------------------------------------------------------------- |
| `tag` | `String` | Can be used to overwrite the tag. | `undefined` |
Expand All @@ -43,8 +52,16 @@ const { currentTag } = useContentContainer();

## Return

| Property | Type | Description |
| -------------- | -------- | --------------------- |
| `currentTag` | `String` | Get current html tag. |
| `parentLevel` | `Number` | Get parent level. |
| `currentLevel` | `Number` | Get current level. |
```ts
type ContentContainerReturn = {
parentLevel: ComputedRef<number>;
currentLevel: ComputedRef<number>;
currentTag: ComputedRef<string>;
};
```

| Property | Type | Description |
| -------------- | ---------------------- | --------------------- |
| `parentLevel` | `ComputedRef<Number>;` | Get parent level. |
| `currentLevel` | `ComputedRef<Number>` | Get current level. |
| `currentTag` | `ComputedRef<String>` | Get current html tag. |
29 changes: 22 additions & 7 deletions docs/src/composables/use-content-headline.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,28 @@ const { currentTag } = useContentHeadline();

## Options

| Property | Type | Description | Default Value |
| -------- | -------- | ------------------- | ------------- |
| `tag` | `String` | Tag for the element | `undefined` |
```ts
type ContentHeadlineOptions = {
tag?: string | undefined;
};
```

| Property | Type | Description | Default Value |
| -------- | --------------------- | ------------------- | ------------- |
| `tag` | `String`\|`undefined` | Tag for the element | `undefined` |

## Return

| Property | Type | Description |
| -------------- | -------- | --------------------- |
| `currentTag` | `String` | Get current html tag. |
| `currentLevel` | `Number` | Get current level. |
```ts
type ContentHeadlineReturn = {
parentLevel: ComputedRef<number>;
currentLevel: ComputedRef<number>;
currentTag: ComputedRef<string>;
};
```

| Property | Type | Description |
| -------------- | ---------------------- | --------------------- |
| `parentLevel` | `ComputedRef<Number>;` | Get parent level. |
| `currentLevel` | `ComputedRef<Number>` | Get current level. |
| `currentTag` | `ComputedRef<String>` | Get current html tag. |
2 changes: 2 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import pluginJs from '@eslint/js';
import pluginVue from 'eslint-plugin-vue';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import eslintIgnores from './eslint.ignores.js';
import tseslint from 'typescript-eslint';

export default [
eslintIgnores,
pluginJs.configs.recommended,
...tseslint.configs.recommended,
...pluginVue.configs['flat/essential'],
eslintPluginPrettierRecommended,
{
Expand Down
Loading
Loading