Go to file
Evgeny Kuzyakov e4dde5449f
Introduce cloudflare workers to generate static previews (#179)
Use cloudflare's functions to generate and inject static metadata as
well as noscript content for crawlers and previews
2023-08-02 16:36:16 -07:00
config Drop hash router (#177) 2023-07-28 10:06:42 -07:00
functions/[[accountId]]/widget Introduce cloudflare workers to generate static previews (#179) 2023-08-02 16:36:16 -07:00
public Introduce cloudflare workers to generate static previews (#179) 2023-08-02 16:36:16 -07:00
src Add Base web3 endpoints 2023-07-30 17:15:52 -07:00
.babelrc Webpack5 test 2022-10-14 11:38:35 -07:00
.gitignore Introduce cloudflare workers to generate static previews (#179) 2023-08-02 16:36:16 -07:00
LICENSE Initial template based on wiki 2022-08-23 16:21:20 -07:00
package.json Bump VM to #dev branch 2023-07-28 12:51:36 -07:00
README.md Adding calling view methods from widgets 2022-10-11 21:27:09 +02:00
webpack.config.js Drop hash router (#177) 2023-07-28 10:06:42 -07:00
yarn.lock Update VM version to 2.2.3. Add more chains 2023-06-09 12:26:36 -07:00

Browser

A framework for reusable components to render and modify SocialDB by Near Social.

Setup & Development

Initialize repo:

yarn

Start development version:

yarn start

Widget example

Profile view

let accountId = props.accountId || "eugenethedream";
let profile = socialGetr(`${accountId}/profile`);

(
  <div>
    <img src={profile.image.url}/>
    <span>{profile.name}</span> <span>(@{accountId})</span>
  </div>
);

Profile editor

let accountId = context.accountId;

if (!accountId) {
  return "Please sign in with NEAR wallet";
}

const profile = socialGetr(`${accountId}/profile`);

if (profile === null) {
  return "Loading";
}

initState({
  name: profile.name,
  url: profile.image.url,
});

const data = {
  profile: {
    name: state.name,
    image: {
      url: state.url,
    },
  },
};

return (
  <div>
    <div>account = {accountId}</div>
    <div>
      Name:
      <input type="text" value={state.name} />
    </div>
    <div>
      Image URL:
      <input type="text" value={state.url} />
    </div>
    <div>Preview</div>
    <div>
      <img src={state.url} alt="profile image" /> {state.name}
    </div>
    <div>
      <CommitButton data={data}>Save profile</CommitButton>
    </div>
  </div>
);