create types lib
This commit is contained in:
parent
04418cbfed
commit
ba6b727fd7
20 changed files with 188 additions and 154 deletions
8
libs/types/package.json
Normal file
8
libs/types/package.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "@goldenwere/static-web-templates-types",
|
||||
"private": true,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"types": "src/index.d.ts",
|
||||
"main": "src/index.d.ts"
|
||||
}
|
14
libs/types/src/content/globals.d.ts
vendored
Normal file
14
libs/types/src/content/globals.d.ts
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
import { HeaderEntry } from './navigation'
|
||||
import { SiteThemeList } from './themes'
|
||||
import { WarningModal } from './warnings'
|
||||
|
||||
/**
|
||||
* Defines global values for the site.
|
||||
*/
|
||||
type SiteGlobals = {
|
||||
header: HeaderEntry[]
|
||||
id: string
|
||||
stylesheetUrls: string[]
|
||||
themes: SiteThemeList
|
||||
warning: WarningModal
|
||||
}
|
17
libs/types/src/content/navigation.d.ts
vendored
Normal file
17
libs/types/src/content/navigation.d.ts
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
/**
|
||||
* Defines an entry in the app header.
|
||||
* Optionally recursive by defining children instead of path.
|
||||
*/
|
||||
export type HeaderEntry = {
|
||||
displayName: string
|
||||
} & ({
|
||||
path: string
|
||||
target?:
|
||||
| '_self'
|
||||
| '_blank'
|
||||
| '_parent'
|
||||
| '_top'
|
||||
| '_unfencedTop'
|
||||
} | {
|
||||
children: HeaderEntry[]
|
||||
})
|
77
libs/types/src/content/routing.d.ts
vendored
Normal file
77
libs/types/src/content/routing.d.ts
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
import { WarningModal } from './warnings'
|
||||
|
||||
|
||||
/**
|
||||
* Defines the available `views` that can be used to set up routes.
|
||||
* Each `Template` has different configuration options
|
||||
*/
|
||||
export type Template =
|
||||
| 'markdown'
|
||||
| 'project-list'
|
||||
| 'gallery-list'
|
||||
|
||||
/**
|
||||
* Defines the shared options for a route
|
||||
*/
|
||||
export type SharedRouteDefinition = {
|
||||
id: string
|
||||
scriptUrl?: string
|
||||
stylesheetUrls: string[]
|
||||
template: Template
|
||||
title: string
|
||||
warning: boolean | WarningModal
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a content-based route
|
||||
*/
|
||||
export type ContentfulRouteDefintion = SharedRouteDefinition & {
|
||||
content: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a config-based route
|
||||
*/
|
||||
export type ConfigfulRouteDefinition = SharedRouteDefinition & {
|
||||
config: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the config for a route using the `markdown` {@link Template}
|
||||
*/
|
||||
export type MarkdownDefinition = ContentfulRouteDefintion & {
|
||||
template: 'markdown'
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the config for a route using the `project-list` {@link Template}
|
||||
*/
|
||||
export type ProjectListDefinition = ConfigfulRouteDefinition & {
|
||||
template: 'project-list'
|
||||
view: {
|
||||
stylesheetUrls: string[]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the config for a route using the `gallery-list` {@link Template}
|
||||
*/
|
||||
export type GalleryListDefinition = ConfigfulRouteDefinition & {
|
||||
template: 'gallery-list'
|
||||
view: {
|
||||
stylesheetUrls: string[]
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines all available route definitions
|
||||
*/
|
||||
export type RouteDefinition =
|
||||
| MarkdownDefinition
|
||||
| ProjectListDefinition
|
||||
| GalleryListDefinition
|
||||
|
||||
/**
|
||||
* Defines the collection of routes the app uses
|
||||
*/
|
||||
export type RouteCollection = { [key: string]: RouteDefinition }
|
24
libs/types/src/content/themes.d.ts
vendored
Normal file
24
libs/types/src/content/themes.d.ts
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
/**
|
||||
* Defines a stylesheet the site uses for applying a theme
|
||||
*/
|
||||
export type SiteTheme = {
|
||||
displayName?: string
|
||||
type: SiteThemeType
|
||||
url: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines a list of themes the site uses
|
||||
*/
|
||||
export type SiteThemeList = { [id: string]: SiteTheme }
|
||||
|
||||
/**
|
||||
* Defines what kind of theme a specified theme is
|
||||
* for the purposes of determining a default theme
|
||||
* based on the system/browser setting of the visitor
|
||||
*/
|
||||
export type SiteThemeType =
|
||||
| 'dark'
|
||||
| 'light'
|
||||
| 'dark_hc'
|
||||
| 'light_hc'
|
12
libs/types/src/content/warnings.d.ts
vendored
Normal file
12
libs/types/src/content/warnings.d.ts
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
/**
|
||||
* Defines the structure of the warning modal that shows when a route has a content warning of some sort.
|
||||
*/
|
||||
export type WarningModal = {
|
||||
prompt: string
|
||||
leave: {
|
||||
url: string,
|
||||
text: string,
|
||||
},
|
||||
acknowledge: string,
|
||||
remember: string,
|
||||
}
|
5
libs/types/src/index.d.ts
vendored
Normal file
5
libs/types/src/index.d.ts
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
export * from './content/globals'
|
||||
export * from './content/navigation'
|
||||
export * from './content/routing'
|
||||
export * from './content/themes'
|
||||
export * from './content/warnings'
|
Loading…
Add table
Add a link
Reference in a new issue