<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://wiki.socialstack.dev/index.php?action=history&amp;feed=atom&amp;title=Content</id>
	<title>Content - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.socialstack.dev/index.php?action=history&amp;feed=atom&amp;title=Content"/>
	<link rel="alternate" type="text/html" href="https://wiki.socialstack.dev/index.php?title=Content&amp;action=history"/>
	<updated>2026-10-16T01:01:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.36.2</generator>
	<entry>
		<id>https://wiki.socialstack.dev/index.php?title=Content&amp;diff=100&amp;oldid=prev</id>
		<title>2A02:C7F:22BE:A500:498:3225:1A16:A72D: Created page with &quot;&lt;Content&gt; is a React component which is closely related to &lt;Loop&gt;. They both are convenience components for obtaining data from your API; unlike Loop, Content is for grabb...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.socialstack.dev/index.php?title=Content&amp;diff=100&amp;oldid=prev"/>
		<updated>2022-07-05T18:21:03Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;Content&amp;gt; is a React component which is closely related to &amp;lt;&lt;a href=&quot;/index.php?title=Loop&quot; title=&quot;Loop&quot;&gt;Loop&lt;/a&gt;&amp;gt;. They both are convenience components for obtaining data from your API; unlike Loop, Content is for grabb...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;Content&amp;gt; is a React component which is closely related to &amp;lt;[[Loop]]&amp;gt;. They both are convenience components for obtaining data from your API; unlike Loop, Content is for grabbing a singular item.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import Content from &amp;#039;UI/Content&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;Content type=&amp;#039;user&amp;#039; id={14}&amp;gt;&lt;br /&gt;
       {&lt;br /&gt;
           (user, loading) =&amp;gt; {&lt;br /&gt;
                  if(loading) {&lt;br /&gt;
                      return &amp;#039;Getting user data..&amp;#039;;&lt;br /&gt;
                  }&lt;br /&gt;
                  &lt;br /&gt;
                  if(!user){&lt;br /&gt;
                      return &amp;#039;User was not found.&amp;#039;;&lt;br /&gt;
                  }&lt;br /&gt;
                  &lt;br /&gt;
                  return &amp;lt;p&amp;gt;{user.username}&amp;lt;/p&amp;gt;;&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
     &amp;lt;/Content&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Primary Content =&lt;br /&gt;
&lt;br /&gt;
On [[Editing_Pages|pages with primary content]], &amp;lt;Content&amp;gt; can be used to directly obtain the primary content object:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
import Content from &amp;#039;UI/Content&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
     &amp;lt;Content primary&amp;gt;&lt;br /&gt;
       {&lt;br /&gt;
           (blogPost, loading) =&amp;gt; {&lt;br /&gt;
                  if(loading) {&lt;br /&gt;
                      return &amp;#039;Getting post..&amp;#039;;&lt;br /&gt;
                  }&lt;br /&gt;
                  &lt;br /&gt;
                  if(!blogPost){&lt;br /&gt;
                      return &amp;#039;Post was not found.&amp;#039;;&lt;br /&gt;
                  }&lt;br /&gt;
                  &lt;br /&gt;
                  return &amp;lt;h1&amp;gt;{blogPost.title}&amp;lt;/h1&amp;gt;;&lt;br /&gt;
           }&lt;br /&gt;
       }&lt;br /&gt;
     &amp;lt;/Content&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Includes =&lt;br /&gt;
&lt;br /&gt;
[[Includes]] are a mechanism in SocialStack for obtaining related data in the same API call. They are a feature of the [[public API]] but are exposed via Content too:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;js&amp;quot;&amp;gt;&lt;br /&gt;
    import Content from &amp;#039;UI/Content&amp;#039;;&lt;br /&gt;
    &lt;br /&gt;
    ...&lt;br /&gt;
    &lt;br /&gt;
    &amp;lt;Content type=&amp;#039;page&amp;#039; id={1} includes={[&amp;#039;creatorUser&amp;#039;]}&amp;gt;&lt;br /&gt;
        {(page, loading) =&amp;gt; {&lt;br /&gt;
            if(loading){&lt;br /&gt;
                // Just an example.&lt;br /&gt;
                return &amp;#039;Loading..&amp;#039;;&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            if(!page){&lt;br /&gt;
                return &amp;#039;Page does not exist&amp;#039;;&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            return &amp;lt;div&amp;gt;&lt;br /&gt;
                The page &amp;quot;{page.title}&amp;quot; was created by {page.creatorUser.username}&lt;br /&gt;
            &amp;lt;/div&amp;gt;;&lt;br /&gt;
        }}&lt;br /&gt;
    &amp;lt;/Content&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>2A02:C7F:22BE:A500:498:3225:1A16:A72D</name></author>
	</entry>
</feed>