diff options
| author | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
|---|---|---|
| committer | rxliuli <rxliuli@gmail.com> | 2025-11-04 05:03:50 +0800 |
| commit | bce557cc2dc767628bed6aac87301a1be7c5431b (patch) | |
| tree | b51a051228d01fe3306cd7626d4a96768aadb944 /node_modules/@jet-app/app-store/tmp/src/common/today/routable-article-page-url-utils.js | |
init commit
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/common/today/routable-article-page-url-utils.js')
| -rw-r--r-- | node_modules/@jet-app/app-store/tmp/src/common/today/routable-article-page-url-utils.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/common/today/routable-article-page-url-utils.js b/node_modules/@jet-app/app-store/tmp/src/common/today/routable-article-page-url-utils.js new file mode 100644 index 0000000..5603a86 --- /dev/null +++ b/node_modules/@jet-app/app-store/tmp/src/common/today/routable-article-page-url-utils.js @@ -0,0 +1,32 @@ +import { makeRoutableArticlePageIntent, } from "../../api/intents/routable-article-page-intent"; +import { generateRoutes } from "../util/generate-routes"; +const { routes: routableArticlePageWithPlatformRoutes, makeCanonicalUrl: makeRoutableArticlePageWithPlatformUrl } = generateRoutes(makeRoutableArticlePageIntent, "/{platform}/story/{id}"); +const { routes: routableArticlePageWithoutPlatformRoutes, makeCanonicalUrl: makeRoutableArticlePageWithoutPlatformUrl, } = generateRoutes(makeRoutableArticlePageIntent, "/story/{id}"); +export { routableArticlePageWithPlatformRoutes, routableArticlePageWithoutPlatformRoutes }; +/** + * Generate the URL for an "Article Page" based on the {@linkcode intent} + * + * If the {@linkcode intent} has an explicitly-configured `platform` property, + * then the resulting URL will include the explicitly as the `{platform}` prefix + * segment. If the `platform` property is not provided, the resulting URL will + * not contain an explicit `{platform}` segment at all. + * + * @param objectGraph + * @param intent + * @returns the URL that, when parsed, produces the given `intent` + */ +export function makeRoutableArticlePageCanonicalUrl(objectGraph, intent) { + const intentWithExpectedID = { + ...intent, + // The `{id}` segment of the URL is expected to include the `id` prefix, which is removed + // when parsing the incoming URL into the `Intent` + id: `id${intent.id}`, + }; + if (intent.platform) { + return makeRoutableArticlePageWithPlatformUrl(objectGraph, intentWithExpectedID); + } + else { + return makeRoutableArticlePageWithoutPlatformUrl(objectGraph, intentWithExpectedID); + } +} +//# sourceMappingURL=routable-article-page-url-utils.js.map
\ No newline at end of file |
