Comments (10)
hi @Lowell130,
what do you mean? Do you want to use JSON for your meta data, or do you want to add complete content files containing JSON?
In both cases you would need to add a new flamingo parser. I currently write documentation on how to do it, and could provide you a snippet to start with
from flamingo.
hi @Lowell130,
what do you mean? Do you want to use JSON for your meta data, or do you want to add complete content files containing JSON?
In both cases you would need to add a new flamingo parser. I currently write documentation on how to do it, and could provide you a snippet to start with
i just want generate static HTML pages by JSON data, it's possible?
from flamingo.
Flamingo has no native support for JSON files. You would need to write a plugin with ~10 lines of code i think. But then you can use JSON files. So yes and no.
from flamingo.
@Lowell130 does this answer your question?
from flamingo.
@Lowell130 does this answer your question?
i know how fetch json data by JS for SPA (sigle page application) web site but i don't know how do that to generate static page, can you help me?
from flamingo.
Ah ok! If i understand you correctly, you want to create one HTML page as singe page application and store all contents as JSON files to load them from the HTML page using JS?
In this case you can do something like this:
class SinglePageApplicationPlugin:
def contents_parsed(self, context):
data = []
for content in context.contents:
data.append({
'title': content['content_title'],
'body': content['content_body'],
})
json.dumps(data)
from flamingo.
Ah ok! If i understand you correctly, you want to create one HTML page as singe page application and store all contents as JSON files to load them from the HTML page using JS?
In this case you can do something like this:
class SinglePageApplicationPlugin: def contents_parsed(self, context): data = [] for content in context.contents: data.append({ 'title': content['content_title'], 'body': content['content_body'], }) json.dumps(data)
not exactly i just want generate html pages for each item stored in my json. In my json i have lots of items with their key value infos, there e sample of json file: https://easyupload.io/nqhnc2
from flamingo.
ah ok! Then you could should write a parser
import json
from flamingo.core.parser import ContentParser
class JSONParser(ContentParser):
FILE_EXTENSIONS = ['json']
def parse(self, file_content, content):
for entry in json.loads(file_content):
content['content_title'] = entry['title']
content['content_body'] = entry['body']
class JSON:
def parser_setup(self, context):
context.parser.add_parser(JSONParser(context))
from flamingo.
ah ok! Then you could should write a parser
import json from flamingo.core.parser import ContentParser class JSONParser(ContentParser): FILE_EXTENSIONS = ['json'] def parse(self, file_content, content): for entry in json.loads(file_content): content['content_title'] = entry['title'] content['content_body'] = entry['body'] class JSON: def parser_setup(self, context): context.parser.add_parser(JSONParser(context))
wow please give me time to check your great solution
from flamingo.
Hi @Lowell130,
This issue is still open. Did my example solve your problem?
from flamingo.
Related Issues (16)
- Difference between Flamingo and Pelican HOT 5
- update documentation that it requires python 3. HOT 2
- HTML-Parser altering structure of document HOT 3
- Local environment on Windows HOT 2
- Documentation HOT 1
- Problems with images in markdown HOT 2
- can't generate menu correctly HOT 3
- Suggestion: Change links in the base theme template from absolute to relative paths HOT 1
- sphinx-themes breaks with Flamingo 1.7.1 and Python 3.10 HOT 6
- Can't run single test HOT 1
- Documentation: Add documentation about the sphinx_theme plugin
- template is not parsed in or before rst-plugin
- Image directive scale parameter unsupported. Missing error message.
- Enumerated lists next to images are not indented correctly HOT 1
- Image description extends over image contents HOT 1
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 flamingo.