Skip to content

Commit 0d1c79c

Browse files
authored
Merge pull request #2 from BJTheCod3r/chore/type-fixes
chore: type fixes
2 parents 76ba4f4 + 5f0a018 commit 0d1c79c

12 files changed

Lines changed: 77 additions & 7 deletions

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export default defineNuxtConfig({
3434
documentIdParam: 'document_id',
3535
backLink: '/',
3636
backLinkText: 'Back to dashboard',
37+
showBackLink: true,
3738
buttonColor: '#4f46e5',
3839
buttonHoverColor: '#4338ca',
3940
showDocument: true,
@@ -112,6 +113,7 @@ All response fields are treated as strings except the validity flag. If a status
112113
| `logo` | Logo URL displayed at the top of the page | `/logo.png` |
113114
| `verificationEndpoint` | API endpoint that validates a document | **required** |
114115
| `backLink` / `backLinkText` | Destination + label for the back button | `'/'` / `'Back to Home'` |
116+
| `showBackLink` | Toggle visibility of the back button | `true` |
115117
| `buttonColor` / `buttonHoverColor` | Primary button colours | `#4f46e5` / `#4338ca` |
116118
| `fields` | Array describing the detail rows (label, key, type, optional resolver) | Built-in defaults |
117119
| `showDocument` | Toggle document image section (hides it entirely when `false`) | `true` |
@@ -153,6 +155,8 @@ Only fields that resolve to a non-empty value are rendered. `type: 'status'` als
153155

154156
When `showDocument` is `false`, the asset block is skipped altogether even if the API responds with a URL. Use `showDocumentTitle` to hide the heading while keeping the preview itself, or override `displayTitle` to customise the heading copy. Set `displayType` to `'image'` or `'pdf'` when you know the asset format; otherwise the component falls back to inferring it from the URL (still supporting PDF detection). The `displayField` can point to an image or a PDF; PDFs render inside the viewer with a fallback link.
155157

158+
Turn off the footer back button entirely by setting `showBackLink: false`.
159+
156160
```ts
157161
documentVerification: {
158162
// ...

playground/nuxt.config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
import { defineNuxtConfig } from 'nuxt/config'
3+
24
export default defineNuxtConfig({
35
modules: ['../nuxt'],
46
documentVerification: {
57
logo: '/document-icon.png',
68
verificationEndpoint: '/api/verify-document',
79
backLink: '/',
810
backLinkText: 'Back to Home',
11+
showBackLink: false,
912
buttonColor: '#4f46e5',
1013
buttonHoverColor: '#4338ca',
1114
fields: [

playground/tsconfig.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"types": ["nuxt"]
5+
},
6+
"include": ["../src/types/**/*.d.ts", "./**/*"]
7+
}

src/types/runtime-config.ts renamed to playground/types/nuxt-document-verification.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import type { DocumentVerificationConfig } from '../runtime/composables/types'
1+
import type { DocumentVerificationConfig } from '../../src/runtime/composables/types'
22

3-
declare module '@nuxt/schema' {
3+
declare module 'nuxt/schema' {
44
interface NuxtConfig {
55
documentVerification?: DocumentVerificationConfig
66
}
7+
78
interface PublicRuntimeConfig {
89
documentVerification: DocumentVerificationConfig
910
}

src/module.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import './types/runtime-config'
2-
31
import { defineNuxtModule, createResolver, addComponent, addImportsDir, addPlugin } from '@nuxt/kit'
42
import type { DocumentVerificationConfig } from './runtime/composables/types'
53
import { BASE_FIELD_DEFINITIONS } from './runtime/composables/constants'
@@ -17,6 +15,7 @@ export default defineNuxtModule<DocumentVerificationConfig>({
1715
verificationEndpoint: '/api/verify-document',
1816
backLink: '/',
1917
backLinkText: 'Back to Home',
18+
showBackLink: true,
2019
buttonColor: '#4f46e5',
2120
buttonHoverColor: '#4338ca',
2221
fields: BASE_FIELD_DEFINITIONS,

src/runtime/components/DocumentFooter.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="dv-footer">
2+
<div v-if="showBackLink" class="dv-footer">
33
<a :href="backLink" class="dv-footer__link">{{ backLinkText }}</a>
44
</div>
55
</template>
@@ -15,5 +15,9 @@ defineProps({
1515
type: String,
1616
required: true,
1717
},
18+
showBackLink: {
19+
type: Boolean,
20+
default: true,
21+
},
1822
})
1923
</script>

src/runtime/components/DocumentVerification.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@
3030
/>
3131
</div>
3232

33-
<DocumentFooter :back-link="config.backLink" :back-link-text="config.backLinkText" />
33+
<DocumentFooter
34+
v-if="config.showBackLink !== false"
35+
:back-link="config.backLink"
36+
:back-link-text="config.backLinkText"
37+
:show-back-link="config.showBackLink"
38+
/>
3439
</div>
3540
</template>
3641

src/runtime/composables/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export interface DocumentVerificationConfig {
5353
verificationEndpoint: string
5454
backLink: string
5555
backLinkText: string
56+
showBackLink?: boolean
5657
buttonColor: string
5758
buttonHoverColor: string
5859
fields?: FieldDefinition[]

src/runtime/composables/useDocumentVerification.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const useDocumentVerification = () => {
3232
const cfg = $documentVerification as DocumentVerificationConfig
3333
const route = useRoute()
3434
const documentIdParam = cfg.documentIdParam || DEFAULT_DOCUMENT_ID_PARAM
35+
const showBackLink = cfg.showBackLink ?? true
3536
const showDocument = cfg.showDocument ?? true
3637
const displayTitle = cfg.displayTitle ?? 'Document Preview'
3738
const showDocumentTitle = cfg.showDocumentTitle ?? true
@@ -40,6 +41,7 @@ export const useDocumentVerification = () => {
4041
const resolvedConfig: DocumentVerificationConfig = {
4142
...cfg,
4243
documentIdParam,
44+
showBackLink,
4345
showDocument,
4446
showDocumentTitle,
4547
displayTitle,

src/runtime/plugins/document-verification.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export default defineNuxtPlugin<{ documentVerification: DocumentVerificationConf
1717
}
1818

1919
const documentIdParam = moduleConfig.documentIdParam ?? DEFAULT_DOCUMENT_ID_PARAM
20+
const showBackLink = moduleConfig.showBackLink ?? true
2021
const showDocument = moduleConfig.showDocument ?? true
2122
const displayTitle = moduleConfig.displayTitle ?? 'Document Preview'
2223
const showDocumentTitle = moduleConfig.showDocumentTitle ?? true
@@ -26,6 +27,7 @@ export default defineNuxtPlugin<{ documentVerification: DocumentVerificationConf
2627
const normalizedConfig: DocumentVerificationConfig = {
2728
...moduleConfig,
2829
documentIdParam,
30+
showBackLink,
2931
showDocument,
3032
displayTitle,
3133
showDocumentTitle,

0 commit comments

Comments
 (0)