Repository navigation
Links and Routes
A community lives at public URLs that members share, and inside your app it needs routes that match the Selldone
Storefront. This page covers the CommunityURLs helper for building share and embed links, and the community route
names exposed as window.$community.routes.
CommunityURLs is a static helper class shipped in the package. Import it by path:
import { CommunityURLs } from "@selldone/sdk-community/url/CommunityURLs";| Method | Returns |
|---|---|
CommunityUrl(shop) |
<shop URL>/community |
CommunityInviteLink(shop) |
<shop URL>/community |
PostUrl(shop, post) |
<shop URL>/POSTS/{post.id} |
CommentUrl(shop, comment) |
<shop URL>/COMMENTS/{comment.id} |
PostEmbedUrl(shop, post) |
<selldone-iframe URL>/POSTS/{post.id}/embed |
TopicShortUrl(community_id, topic_id) |
<service-url>/CROSS/{community_id}/{topic_id} (short link) |
How the base URL is chosen:
-
<shop URL>comes fromShopURLs.MainShopUrl(shop)in Selldone Core: the shop's primary custom domain if it has one, otherwise its subdomain or<service-url>/@{shop name}. - When
shopisnull, the methods fall back to theservice-urlmeta value (the main Selldone community).PostEmbedUrluses theselldone-iframemeta value for shop posts.
const shareUrl = CommunityURLs.PostUrl(shop, post);
await navigator.clipboard.writeText(shareUrl);
const embedUrl = CommunityURLs.PostEmbedUrl(shop, post);
const iframe = `<iframe src="${embedUrl}" width="100%" height="480" frameborder="0"></iframe>`;window.$community.routes is the CommunityRoutesName enum from Selldone Core:
| Key | Route name | Storefront path |
|---|---|---|
COMMUNITY_HOME_PAGE |
CommunityHomePage |
/community |
COMMUNITY_CATEGORY_PAGE |
CommunityCategoryPage |
/community/:category_id-:category_slug? |
COMMUNITY_TOPIC_PAGE |
CommunityTopicPage |
/community/:category_id-:category_slug?/:topic_id-:topic_slug? |
The official Storefront also defines /community/feed
(CommunityFeedPage) and /community/comments (CommunityMyCommentsPage), and renders all of these pages with the
community components from Components.
Use the route names to navigate to community pages with Vue Router:
router.push({
name: window.$community.routes.COMMUNITY_TOPIC_PAGE,
params: {
category_id: category.id,
category_slug: categorySlug,
topic_id: topic.id,
topic_slug: topicSlug,
},
});If you build your own router, keep the same names and parameters so the Components community UI can navigate between pages.