Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
37 changes: 34 additions & 3 deletions apps/builder/app/builder/features/topbar/publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
$instances,
$pages,
$project,
$propsIndex,
$publishedOrigin,
$userPlanFeatures,
} from "~/shared/nano-states";
Expand All @@ -69,6 +70,7 @@ import { AddDomain } from "./add-domain";
import { humanizeString } from "~/shared/string-utils";
import { trpcClient, nativeClient } from "~/shared/trpc/trpc-client";
import {
findTreeInstanceIds,
isPathnamePattern,
parseComponentName,
type Templates,
Expand Down Expand Up @@ -217,8 +219,8 @@ const ChangeProjectDomain = ({
};

const $usedProFeatures = computed(
[$pages, $dataSources, $instances],
(pages, dataSources, instances) => {
[$pages, $dataSources, $instances, $propsIndex],
(pages, dataSources, instances, propsIndex) => {
const features = new Map<string, undefined | Awareness>();
if (pages === undefined) {
return features;
Expand Down Expand Up @@ -258,7 +260,8 @@ const $usedProFeatures = computed(
);
}
}
// instances with animations

// Instances with animations.
for (const instance of instances.values()) {
const [namespace] = parseComponentName(instance.component);
if (namespace === "@webstudio-is/sdk-components-animation") {
Expand All @@ -268,6 +271,34 @@ const $usedProFeatures = computed(
);
}
}

const badgeFeature = 'No "Built with Webstudio" badge';
// Badge should be rendered on free sites on every page.
features.set(badgeFeature, undefined);
// We want to check the badge only on the home page
const homePageInstanceIds = findTreeInstanceIds(
instances,
pages.homePage.rootInstanceId
);
// @todo add a check inside the slot that could be on the home page
for (const instanceId of homePageInstanceIds) {
const instance = instances.get(instanceId);
if (instance === undefined) {
continue;
}
// Built with Webstudio badge
if (instance.tag === "a") {
const props = propsIndex.propsByInstanceId.get(instance.id);
for (const prop of props ?? []) {
if (
prop.name === "href" &&
prop.value === "https://webstudio.is?via=badge"
) {
features.delete(badgeFeature);
}
}
}
}
return features;
}
);
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/core-templates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ const builtWithWebstudioMeta: TemplateMeta = {
<ws.element
ws:tag="a"
ws:label="Built with Webstudio"
// If you change this, you need to also update this link in publish checks
href="https://webstudio.is?via=badge"
target="_blank"
ws:style={css`
Expand Down