Skip to content

Commit 724a7ff

Browse files
authored
Merge pull request #98 from basics/feature/typescript
fix(typescript): added typescript support
2 parents 2cbd13a + eb9044a commit 724a7ff

34 files changed

+2407
-1512
lines changed

build.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export default defineBuildConfig({
1414
jsxFactory: 'h'
1515
}
1616
},
17-
{ builder: 'mkdist', input: './src', pattern: ['**/*.js'], format: 'cjs', loaders: ['js'], ext: 'cjs' },
18-
{ builder: 'mkdist', input: './src', pattern: ['**/*.js'], format: 'esm', loaders: ['js'], ext: 'js' }
17+
{ builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'cjs', loaders: ['js'], ext: 'cjs' },
18+
{ builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'esm', loaders: ['js'], ext: 'js' }
1919
],
2020
declaration: true,
2121
clean: true,

docs/.vitepress/config.js renamed to docs/.vitepress/config.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
// import { defineConfig } from 'vitepress';
2-
3-
// // https://vitepress.dev/reference/site-config
4-
// export default defineConfig({
5-
// title: 'Vue Semantic Structure',
6-
// description: 'Helper for semantic HTML structure.',
7-
// themeConfig: {
8-
// // https://vitepress.dev/reference/default-theme-config
9-
// }
10-
// });
11-
121
import { fileURLToPath } from 'url';
13-
import { defineConfig } from 'vitepress';
2+
import { DefaultTheme, defineConfig, ThemeOptions, UserConfig } from 'vitepress';
143
import markdownItInlineComments from 'markdown-it-inline-comments';
154
import navigation from './navigation.js';
165

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

@@ -68,7 +56,12 @@ export default defineConfig(() => ({
6856
sitemap: {
6957
hostname: 'https://basics.github.io/vue-semantic-structure/'
7058
}
71-
}));
59+
} as UserConfig<DefaultTheme.Config> & {
60+
themeConfig: ThemeOptions & {
61+
logoComponent: boolean;
62+
socialLinks: { icon: string; link: string }[];
63+
};
64+
});
7265

7366
function getBaseUrl() {
7467
return process.env.npm_config_base_url || process.env.BASE_URL || '/';
File renamed without changes.
File renamed without changes.

docs/src/components/content-container.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ The appropriate HTML element for the page structure is determined based on the `
1818

1919
## Properties
2020

21+
```ts
22+
type Props = {
23+
tag?: string;
24+
rootTags?: string[];
25+
contentTags?: string[];
26+
level?: number;
27+
debug?: boolean;
28+
};
29+
```
30+
2131
### tag
2232

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

2838
### rootTags
2939

30-
- Type: `Array`
40+
- Type: `Array<String>`
3141
- Default: `inject('semanticStructure_rootTags', ['main'])`
3242

3343
Available tags for the root structure.
@@ -36,7 +46,7 @@ Available tags for the root structure.
3646

3747
### contentTags
3848

39-
- Type: `Array`
49+
- Type: `Array<String>`
4050
- Default: `inject('semanticStructure_contentTags', ['article', 'section'])`
4151

4252
Available tags for the content structure.

docs/src/components/content-headline.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ The deeper the nesting, the smaller the heading.
2020

2121
## Properties
2222

23+
```ts
24+
type Props = {
25+
tag: string;
26+
debug: boolean;
27+
};
28+
```
29+
2330
### tag
2431

2532
- Type: `String`

docs/src/composables/use-content-container.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ const { currentTag } = useContentContainer();
3434

3535
## Options
3636

37+
```ts
38+
type ContentContainerOptions = {
39+
tag?: string | undefined;
40+
contentTags?: Array<string>;
41+
rootTags?: Array<string>;
42+
level?: number;
43+
};
44+
```
45+
3746
| Property | Type | Description | Default Value |
3847
| ------------- | -------- | ----------------------------------------- | --------------------------------------------------------------- |
3948
| `tag` | `String` | Can be used to overwrite the tag. | `undefined` |
@@ -43,8 +52,16 @@ const { currentTag } = useContentContainer();
4352

4453
## Return
4554

46-
| Property | Type | Description |
47-
| -------------- | -------- | --------------------- |
48-
| `currentTag` | `String` | Get current html tag. |
49-
| `parentLevel` | `Number` | Get parent level. |
50-
| `currentLevel` | `Number` | Get current level. |
55+
```ts
56+
type ContentContainerReturn = {
57+
parentLevel: ComputedRef<number>;
58+
currentLevel: ComputedRef<number>;
59+
currentTag: ComputedRef<string>;
60+
};
61+
```
62+
63+
| Property | Type | Description |
64+
| -------------- | ---------------------- | --------------------- |
65+
| `parentLevel` | `ComputedRef<Number>;` | Get parent level. |
66+
| `currentLevel` | `ComputedRef<Number>` | Get current level. |
67+
| `currentTag` | `ComputedRef<String>` | Get current html tag. |

docs/src/composables/use-content-headline.md

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,28 @@ const { currentTag } = useContentHeadline();
3535

3636
## Options
3737

38-
| Property | Type | Description | Default Value |
39-
| -------- | -------- | ------------------- | ------------- |
40-
| `tag` | `String` | Tag for the element | `undefined` |
38+
```ts
39+
type ContentHeadlineOptions = {
40+
tag?: string | undefined;
41+
};
42+
```
43+
44+
| Property | Type | Description | Default Value |
45+
| -------- | --------------------- | ------------------- | ------------- |
46+
| `tag` | `String`\|`undefined` | Tag for the element | `undefined` |
4147

4248
## Return
4349

44-
| Property | Type | Description |
45-
| -------------- | -------- | --------------------- |
46-
| `currentTag` | `String` | Get current html tag. |
47-
| `currentLevel` | `Number` | Get current level. |
50+
```ts
51+
type ContentHeadlineReturn = {
52+
parentLevel: ComputedRef<number>;
53+
currentLevel: ComputedRef<number>;
54+
currentTag: ComputedRef<string>;
55+
};
56+
```
57+
58+
| Property | Type | Description |
59+
| -------------- | ---------------------- | --------------------- |
60+
| `parentLevel` | `ComputedRef<Number>;` | Get parent level. |
61+
| `currentLevel` | `ComputedRef<Number>` | Get current level. |
62+
| `currentTag` | `ComputedRef<String>` | Get current html tag. |

eslint.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import pluginJs from '@eslint/js';
33
import pluginVue from 'eslint-plugin-vue';
44
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
55
import eslintIgnores from './eslint.ignores.js';
6+
import tseslint from 'typescript-eslint';
67

78
export default [
89
eslintIgnores,
910
pluginJs.configs.recommended,
11+
...tseslint.configs.recommended,
1012
...pluginVue.configs['flat/essential'],
1113
eslintPluginPrettierRecommended,
1214
{

0 commit comments

Comments
 (0)