Skip to content

perf: remove composable meta property class #167

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 1 commit into from
Jan 15, 2024
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
2 changes: 1 addition & 1 deletion projects/ngx-meta/src/core/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export {
provideCore as provideNgxMetaCore,
withDefaults as withNgxMetaDefaults,
} from './src/provide-core'
export * from './src/composable-meta-property'
export * from './src/global-metadata'
export * from './src/global-metadata-image'
export * from './src/global-metadata-key'
export * from './src/make-composed-meta-property'
export * from './src/make-global-metadata'
export * from './src/make-metadata'
export * from './src/meta-content'
Expand Down
25 changes: 0 additions & 25 deletions projects/ngx-meta/src/core/src/composable-meta-property.ts

This file was deleted.

19 changes: 19 additions & 0 deletions projects/ngx-meta/src/core/src/make-composed-meta-property.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { MetaProperty } from './meta-property'

type MetaPropertyOpts = ConstructorParameters<typeof MetaProperty>[0]
type ComposedMetaPropertyOpts = Omit<MetaPropertyOpts, 'keyName'> & {
separator?: string
}

export const makeComposedMetaProperty = (
opts: ComposedMetaPropertyOpts,
names: ReadonlyArray<string>,
) =>
new MetaProperty({
...opts,
keyName: names.join(
opts.separator ?? DEFAULT_COMPOSED_META_PROPERTY_SEPARATOR,
),
})

export const DEFAULT_COMPOSED_META_PROPERTY_SEPARATOR = ':'
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
ComposableMetaProperty,
KEY_ATTRIBUTE_PROPERTY,
makeComposedMetaProperty,
} from '@davidlj95/ngx-meta/core'

export const makeOpenGraphMetaProperty = (...names: string[]) =>
new ComposableMetaProperty(
{ keyAttr: KEY_ATTRIBUTE_PROPERTY },
...['og', ...names],
)
makeComposedMetaProperty({ keyAttr: KEY_ATTRIBUTE_PROPERTY }, [
'og',
...names,
])
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {
ComposableMetaProperty,
KEY_ATTRIBUTE_PROPERTY,
makeComposedMetaProperty,
} from '@davidlj95/ngx-meta/core'

export const makeTwitterCardMetaProperty = (...names: string[]) =>
new ComposableMetaProperty(
{ keyAttr: KEY_ATTRIBUTE_PROPERTY },
...['twitter', ...names],
)
makeComposedMetaProperty({ keyAttr: KEY_ATTRIBUTE_PROPERTY }, [
'twitter',
...names,
])