diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..bc4348e --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +.vscode +eslint.config.js +eslint.ignores.js +commitlint.config.mjs diff --git a/docs/src/composables/use-content-headline.md b/docs/src/composables/use-content-headline.md index 533a609..d910ee8 100644 --- a/docs/src/composables/use-content-headline.md +++ b/docs/src/composables/use-content-headline.md @@ -6,7 +6,7 @@ Optionally, the component [``](../components/content-headline) can also be used as a wrapper. ::: -`useContentHEadline()` is used to display the headline structure. +`useContentHeadline()` is used to display the headline structure. Example: `h1`, `h2`, `h3`, `h4`, `h5`, `h6` diff --git a/package.json b/package.json index 7b1ef4b..458175c 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "1.0.0-next.2", "description": "Helper for semantic HTML structure.", "license": "MIT", + "private": true, "author": { "name": "Thorn-Welf Walli", "email": "lammpee@gmail.com" @@ -25,6 +26,9 @@ } }, "main": "./dist/index.js", + "files": [ + "dist" + ], "scripts": { "prepack": "unbuild", "dev": "vite playground", diff --git a/playground/src/App.vue b/playground/src/App.vue index c884861..841d8a4 100644 --- a/playground/src/App.vue +++ b/playground/src/App.vue @@ -1,188 +1,181 @@ - diff --git a/playground/src/components/composable/DebugContainer.vue b/playground/src/components/ArticleContentContainer.vue similarity index 57% rename from playground/src/components/composable/DebugContainer.vue rename to playground/src/components/ArticleContentContainer.vue index 826f836..2ca84b1 100644 --- a/playground/src/components/composable/DebugContainer.vue +++ b/playground/src/components/ArticleContentContainer.vue @@ -1,20 +1,23 @@ diff --git a/playground/src/components/composable/DebugHeadline.vue b/playground/src/components/composable/DebugHeadline.vue deleted file mode 100644 index 2990efb..0000000 --- a/playground/src/components/composable/DebugHeadline.vue +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/playground/src/style.css b/playground/src/style.css index 3bd425e..750bdd3 100644 --- a/playground/src/style.css +++ b/playground/src/style.css @@ -94,7 +94,7 @@ font-weight: bold; color: var(--tag-color-fg); pointer-events: none; - content: attr(data-debug-current-tag) ' - pLevel: ' attr(data-debug-parent-level) ' - Level: ' attr(data-debug-level); + content: attr(data-debug-current-tag) ' - pLevel: ' attr(data-debug-parent-level) ' - Level: ' attr(data-debug-current-level); background: var(--tag-color-bg); } } diff --git a/src/useContentContainer.js b/src/useContentContainer.js index 20575f8..02aa781 100644 --- a/src/useContentContainer.js +++ b/src/useContentContainer.js @@ -13,13 +13,14 @@ export default function useContentContainer({ tag, contentTags, rootTags, level if (tag) { return tag; } - if (rootTags[Number(parentLevel)] !== undefined) { + if (Number(parentLevel) in rootTags) { return rootTags[Number(parentLevel)]; } return contentTags[currentLevel.value % contentTags.length]; }); + provide('rootLevel', rootTags.length); provide('parentLevel', currentLevel.value); return { diff --git a/src/useContentHeadline.js b/src/useContentHeadline.js index 4c2c840..2b4e840 100644 --- a/src/useContentHeadline.js +++ b/src/useContentHeadline.js @@ -1,9 +1,10 @@ import { inject, computed } from 'vue'; -export default function useCOntentHeadline({ tag } = {}) { +export default function useContentHeadline({ tag } = {}) { const parentLevel = inject('parentLevel', 1) + 1; + const rootLevel = inject('rootLevel', 1); const getMax = number => Math.max(1, Math.min(number, 6)); - const currentLevel = computed(() => getMax((parentLevel - (parentLevel % 2)) / 2)); + const currentLevel = computed(() => getMax(parentLevel - rootLevel)); const currentTag = computed(() => tag || `h${currentLevel.value}`); return {