File tree 12 files changed +33
-52
lines changed 12 files changed +33
-52
lines changed Original file line number Diff line number Diff line change 8
8
} from './src/provide-core'
9
9
export * from './src/global-metadata'
10
10
export * from './src/global-metadata-image'
11
- export * from './src/global-metadata-key'
12
11
export * from './src/head-element-upsert-or-remove'
13
12
export * from './src/make-composed-meta-property'
14
13
export * from './src/make-metadata'
@@ -17,8 +16,6 @@ export * from './src/meta-property'
17
16
export * from './src/meta.service'
18
17
export * from './src/metadata'
19
18
export * from './src/metadata-provider'
20
- export * from './src/metadata-setter'
21
19
export * from './src/metadata-values'
22
20
export * from './src/metadata.service'
23
21
export * from './src/provide-metadata-factory'
24
- export * from './src/string-key-of'
Original file line number Diff line number Diff line change 1
- import { MetadataProvider } from '../metadata-provider'
2
1
import { makeMetadata } from '../make-metadata'
3
2
4
- export function makeMetadataProvider < T , Id extends string > (
3
+ export function makeMetadataProvider < Id extends string > (
5
4
opts : {
6
5
id ?: Id
7
6
spyName ?: string
8
7
} = { } ,
9
8
) {
10
- const id = opts . id ?? 'dummy'
11
- const metadata : MetadataProvider < T > = {
12
- metadata : makeMetadata ( [ id ] ) ,
13
- set : jasmine . createSpy ( opts . spyName ?? id ) ,
9
+ return {
10
+ metadata : makeMetadata ( [ opts . id ?? 'dummy' ] ) ,
11
+ set : jasmine . createSpy ( opts . spyName ?? opts . id ?? 'dummy' ) ,
14
12
}
15
- return metadata
16
13
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import { GlobalMetadataImage } from './global-metadata-image'
2
- import { GlobalMetadataKey } from './global-metadata-key'
3
2
4
3
export interface GlobalMetadata {
5
4
/**
@@ -72,11 +71,12 @@ export interface GlobalMetadata {
72
71
readonly image ?: GlobalMetadataImage | null
73
72
}
74
73
75
- export const GLOBAL_TITLE = 'title' satisfies GlobalMetadataKey
76
- export const GLOBAL_DESCRIPTION = 'description' satisfies GlobalMetadataKey
74
+ export const GLOBAL_TITLE = 'title' satisfies keyof GlobalMetadata
75
+ export const GLOBAL_DESCRIPTION = 'description' satisfies keyof GlobalMetadata
77
76
export const GLOBAL_APPLICATION_NAME =
78
- 'applicationName' satisfies GlobalMetadataKey
77
+ 'applicationName' satisfies keyof GlobalMetadata
79
78
80
- export const GLOBAL_CANONICAL_URL = 'canonicalUrl' satisfies GlobalMetadataKey
81
- export const GLOBAL_LOCALE = 'locale' satisfies GlobalMetadataKey
82
- export const GLOBAL_IMAGE = 'image' satisfies GlobalMetadataKey
79
+ export const GLOBAL_CANONICAL_URL =
80
+ 'canonicalUrl' satisfies keyof GlobalMetadata
81
+ export const GLOBAL_LOCALE = 'locale' satisfies keyof GlobalMetadata
82
+ export const GLOBAL_IMAGE = 'image' satisfies keyof GlobalMetadata
Original file line number Diff line number Diff line change 1
1
import { Metadata } from './metadata'
2
2
3
+ export type MetadataSetter < T > = ( value : T ) => void
4
+
3
5
export abstract class MetadataProvider < Value , Global extends string = string > {
4
6
abstract readonly metadata : Metadata < Global >
5
- abstract set ( value : Value | null ) : void
7
+ abstract readonly set : MetadataSetter < Value >
6
8
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import { MetadataProvider } from './metadata-provider'
1
+ import { MetadataProvider , MetadataSetter } from './metadata-provider'
2
2
import { FactoryProvider } from '@angular/core'
3
3
import { Metadata } from './metadata'
4
- import { MetadataSetter } from './metadata-setter'
5
4
6
5
export type MetadataSetterFactory < T > = (
7
6
...deps : Exclude < FactoryProvider [ 'deps' ] , undefined >
8
7
) => MetadataSetter < T >
9
8
10
- const makeMetadataProvider = < T > (
11
- metadata : Metadata ,
12
- set : MetadataSetter < T > ,
13
- ) : MetadataProvider < T > => ( {
14
- metadata,
15
- set,
16
- } )
17
-
18
9
export function provideMetadataFactory < T > (
19
10
definition : Metadata ,
20
11
setterFactory : MetadataSetterFactory < T > ,
@@ -28,3 +19,11 @@ export function provideMetadataFactory<T>(
28
19
deps,
29
20
}
30
21
}
22
+
23
+ const makeMetadataProvider = < T > (
24
+ metadata : Metadata ,
25
+ set : MetadataSetter < T > ,
26
+ ) : MetadataProvider < T > => ( {
27
+ metadata,
28
+ set,
29
+ } )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import {
2
- GlobalMetadataKey ,
2
+ GlobalMetadata ,
3
3
makeMetadata ,
4
4
MetadataSetterFactory ,
5
5
MetaService ,
6
6
provideMetadataFactory ,
7
- StringKeyOf ,
8
7
} from '@davidlj95/ngx-meta/core'
9
8
import { OpenGraph } from './open-graph'
10
9
import { FactoryProvider } from '@angular/core'
@@ -13,15 +12,13 @@ import { makeOpenGraphMetaProperty } from './make-open-graph-meta-property'
13
12
14
13
export const OPEN_GRAPH_KEY : keyof OpenGraphMetadata = 'openGraph'
15
14
16
- export const makeOpenGraphMetadataProvider = <
17
- Key extends StringKeyOf < OpenGraph > ,
18
- > (
15
+ export const makeOpenGraphMetadataProvider = < Key extends keyof OpenGraph > (
19
16
key : Key ,
20
17
opts : {
21
18
// Open Graph property name. Defaults to key
22
19
p ?: string
23
20
// Global key. Defaults to nothing
24
- g ?: GlobalMetadataKey
21
+ g ?: keyof GlobalMetadata
25
22
// Setter factory. Defaults to setting the property to the given value.
26
23
s ?: MetadataSetterFactory < OpenGraph [ typeof key ] >
27
24
} = { } ,
Original file line number Diff line number Diff line change 2
2
makeMetadata ,
3
3
MetaService ,
4
4
provideMetadataFactory ,
5
- StringKeyOf ,
6
5
} from '@davidlj95/ngx-meta/core'
7
6
import { FactoryProvider } from '@angular/core'
8
7
import { OpenGraphProfile } from './open-graph-profile'
@@ -13,7 +12,7 @@ import { OpenGraph } from './open-graph'
13
12
export const OPEN_GRAPH_PROFILE_KEY : keyof OpenGraph = 'profile'
14
13
15
14
export const makeOpenGraphProfileMetadataProvider = <
16
- Key extends StringKeyOf < OpenGraphProfile > ,
15
+ Key extends keyof OpenGraphProfile ,
17
16
> (
18
17
key : Key ,
19
18
opts : {
Original file line number Diff line number Diff line change 1
1
import {
2
- GlobalMetadataKey ,
2
+ GlobalMetadata ,
3
3
makeMetadata ,
4
4
MetadataSetterFactory ,
5
5
MetaService ,
6
6
provideMetadataFactory ,
7
- StringKeyOf ,
8
7
} from '@davidlj95/ngx-meta/core'
9
8
import { FactoryProvider } from '@angular/core'
10
9
import { Standard } from './standard'
@@ -13,13 +12,13 @@ import { makeStandardMetaProperty } from './make-standard-meta-property'
13
12
14
13
const STANDARD_KEY : keyof StandardMetadata = 'standard'
15
14
16
- export const makeStandardMetadataProvider = < Key extends StringKeyOf < Standard > > (
15
+ export const makeStandardMetadataProvider = < Key extends keyof Standard > (
17
16
key : Key ,
18
17
opts : {
19
18
// Standard metadata name. Defaults to key
20
19
n ?: string
21
20
// Global key. Defaults to nothing
22
- g ?: GlobalMetadataKey
21
+ g ?: keyof GlobalMetadata
23
22
// Setter factory. Defaults to setting the meta name to the given value.
24
23
s ?: MetadataSetterFactory < Standard [ typeof key ] >
25
24
// Deps for the setter factory
Original file line number Diff line number Diff line change 1
1
import {
2
- GlobalMetadataKey ,
2
+ GlobalMetadata ,
3
3
makeMetadata ,
4
4
MetadataSetterFactory ,
5
5
MetaService ,
6
6
provideMetadataFactory ,
7
- StringKeyOf ,
8
7
} from '@davidlj95/ngx-meta/core'
9
8
import { FactoryProvider } from '@angular/core'
10
9
import { TwitterCard } from './twitter-card'
@@ -13,15 +12,13 @@ import { makeTwitterCardMetaProperty } from './make-twitter-card-meta-property'
13
12
14
13
const TWITTER_KEY : keyof TwitterCardMetadata = `twitterCard`
15
14
16
- export const makeTwitterCardMetadataProvider = <
17
- Key extends StringKeyOf < TwitterCard > ,
18
- > (
15
+ export const makeTwitterCardMetadataProvider = < Key extends keyof TwitterCard > (
19
16
key : Key ,
20
17
opts : {
21
18
// Twitter card property name. Defaults to key
22
19
p ?: string
23
20
// Global key. Defaults to nothing
24
- g ?: GlobalMetadataKey
21
+ g ?: keyof GlobalMetadata
25
22
// Setter factory. Defaults to setting the property to the given value.
26
23
s ?: MetadataSetterFactory < TwitterCard [ typeof key ] >
27
24
} = { } ,
You can’t perform that action at this time.
0 commit comments