Comments (5)
The first four in this array have the correct ID to be able to build a link to the post, but the others do not work
This is because of Javascript being unable to handle newer, 64-bit post IDs as numbers. See how the larger IDs always end in 00
; the precision is being lost. Cyle's prototype was made 2 years ago, before the switchover to larger post IDs. To account for it, you'll need to initialise posts
as a regular Object
and stop using {PostId}
as a number:
<script>
- var posts = new Array();
+ var posts = new Object();
</script>
{block:Posts}
<script>
- posts[{PostId}] = {NPF};
+ posts['{PostId}'] = {NPF};
</script>
{/block:Posts}
<div id="post-list"></div>
and to pull more data from the theme engine than content
, layout
, and trail
, I feel like the easiest way would to just set the data in the same breath:
<script>
posts['{PostId}'] = {NPF};
+ posts['{PostId}'].tags = [ {block:Tags}'{Tag}',{/block:Tags} ];
</script>
although personally, i would have posts
still be an Array
of Object
s and use {PostId}
as a property rather than an identifier. Cyle using custom identifiers on an Array
is... questionable.
from docs.
(FWIW, I have a full JSON-powered theme here, but it's designed for just visualising posts as JSON rather than using the JSON to do anything. I do recommend looking at it though, since putting regular theme variables into JavaScript is tricky.)
from docs.
☝️ Everything April said is what I would've told ya, too. 😄
More documentation on the different theme "blocks" available (i.e. {Tag}
) is here.
although personally, i would have posts still be an Array of Objects and use {PostId} as a property rather than an identifier
I would advise this as well. My prototype in the gist you linked was very rough and quickly made to prove a point, not really something ready for actual usage. I'll try to make that clearer in the gist.
from docs.
You need to construct the post object yourself. {NPF}
only contains content
, layout
, and trail
. Everything else needs to be pulled from the theme engine rather than the API to prevent distributing your (or anyone else's) API key.
from docs.
Thank you so much for this. So that I don't keep pestering you, is there documentation somewhere about all the properties the post object will return? If I want likes, reblogs and other meta data?
This does not mention tags for example:
https://github.com/tumblr/docs/blob/master/npf-spec.md
from docs.
Related Issues (20)
- Add avatar image links to the blog.theme object in NPF data HOT 2
- `formatting` and `indent_level` don't seem to work like documented HOT 2
- Localhost redirect URI ignoring port HOT 3
- Endpoints to block (indivual & bulk) & follow blogs do not accept application/json as a payload - Confirmed user error HOT 15
- Reply/Note endpoint not documented? HOT 1
- Avatar URL not returned in /notes endpoint HOT 6
- Unique user identifier HOT 2
- Unable to retrieve information from certain users HOT 4
- Community Labels via API HOT 4
- Audio posts appear wonky on custom themes HOT 2
- API console seems to not work HOT 7
- Can't create access tokens HOT 6
- NPF: `tumblrmart_accessories` only returns the `blue-checkmark` and not other badges HOT 2
- NPF `indent_level` – a no longer supported feature? HOT 3
- V2 API: Blog info call does not return user following information correctly HOT 1
- Tumblr SSO does not work when "Continue with Google" is used HOT 5
- Request to add custom page related APIs #enhancement
- Tumblr seems to have no API for blog pages (pages added during theme editing) HOT 1
- Inconsistent handling/processing of special characters HOT 1
- Oauth2 Authorization redirect_uri_mismatch HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.