-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break apart CounterLink into IntrasiteLink and CounterDisplay
- Loading branch information
Showing
17 changed files
with
184 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"tags": ["data"], | ||
"exports": ["counters", "items"], | ||
"imports": ["client"], | ||
"imports": ["client", "client-data-components"], | ||
"dependencies": ["react"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,49 @@ | ||
import { isIndexableObject } from "../utils"; | ||
|
||
export const INTRASITE_LINK_HAST_NODE_NAME = "intrasiteLink"; | ||
export const COUNTER_DISPLAY_HAST_NODE_NAME = "counterDisplay"; | ||
export const COUNTER_DISPLAY_PROPS_KEY = "counterDisplay"; | ||
|
||
export interface IntrasiteLinkProperties { | ||
counterId: string; | ||
specificKanji: string | null; | ||
specificReading: string | null; | ||
export interface CounterDisplayProperties { | ||
primaryText: string; | ||
reading: string; | ||
} | ||
|
||
export function isIntrasiteLinkProperties( | ||
export function isCounterDisplayProperties( | ||
obj: unknown | ||
): obj is IntrasiteLinkProperties { | ||
): obj is CounterDisplayProperties { | ||
if (!isIndexableObject(obj)) { | ||
return false; | ||
} | ||
|
||
if (typeof obj.counterId !== "string") { | ||
if (typeof obj.primaryText !== "string") { | ||
return false; | ||
} | ||
|
||
if (typeof obj.reading !== "string") { | ||
return false; | ||
} | ||
|
||
if (obj.specificKanji !== null && typeof obj.specificKanji !== "string") { | ||
return true; | ||
} | ||
|
||
export const INTRASITE_LINK_HAST_NODE_NAME = "intrasiteLink"; | ||
export const INTRASITE_LINK_PROPS_KEY = "intrasiteLink"; | ||
|
||
export interface IntrasiteLinkProperties { | ||
id: string; | ||
type: "counter"; | ||
} | ||
|
||
export function isIntrasiteLinkProperties( | ||
obj: unknown | ||
): obj is IntrasiteLinkProperties { | ||
if (!isIndexableObject(obj)) { | ||
return false; | ||
} | ||
|
||
if (obj.specificReading !== null && typeof obj.specificReading !== "string") { | ||
if (obj.type !== "counter") { | ||
return false; | ||
} | ||
|
||
return true; | ||
return typeof obj.id === "string" && !!obj.id; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.