In my Docusaurus project, I have created a new sidebar in sidebars.json and added some files and it shows up nicely, except it is not ordering the way I have ordered it in the json file.
My new sidebar is a list of dates and the files associated with those dates. So I thought maybe it was due to the categories being numbers. So I tried renaming them to something with letters like "Current Year", but that didn't work. I also tried rearranging them in the Json file, but that also did not work.
"WhatsNew": {
"2019": ["Current Month", "January 2019"],
"2018": ["December 2018", "November 2018", "October 2018", "September
2018", "August 2018", "July 2018", "June 2018", "May 2018",
"April 2018", "March 2018", "February 2018", "January 2018"],
"2017": ["December 2017"]
},
I would expect the side nav to be ordered as I have it in the json file, but instead it is ordered the opposite to how it is ordered in the json file. Instead of starting with 2019, it starts with 2017.
I'm afraid there's no good way to fix this now. This is because keys in JavaScript have no fixed ordering and this is something Docusaurus has to address in v2.
One very ugly hack I can suggest to you is to add a space in front of your keys as such:
"WhatsNew": {
" 2019": ["Current Month", "January 2019"],
" 2018": ["December 2018", "November 2018", "October 2018", "September
2018", "August 2018", "July 2018", "June 2018", "May 2018",
"April 2018", "March 2018", "February 2018", "January 2018"],
" 2017": ["December 2017"]
},
and they will appear in the order you defined it. Hopefully the space isn't noticeable.
Related
is there any way to extract only table data I am trying to extract a table from the specific section "Grade One" from this article https://en.wikipedia.org/wiki/List_of_motor_racing_circuits_by_FIA_grade using Api sandbox but I am getting only the whole content of the page.
this is the URL from the API sandbox which gives me all content.
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=parse&format=json&page=List%20of%20motor%20racing%20circuits%20by%20FIA%20grade&prop=text
I followed the steps I described in my answer in order to get the data you want.
This is the URL:
https://en.wikipedia.org/wiki/Special:ApiSandbox#action=parse&format=json&page=List%20of%20motor%20racing%20circuits%20by%20FIA%20grade&prop=sections%7Ctext§ion=1&disablelimitreport=1&utf8=1
The output contains the table and the text in the "Grade One" section.
This is the API Sandbox example.
Response:
{
"parse": {
"title": "List of motor racing circuits by FIA grade",
"pageid": 57151782,
"text": {
"*": "<div class=\"mw-parser-output\"><h2><span class=\"mw-headline\" id=\"Grade_One\">Grade One</span><span class=\"mw-editsection\"><span class=\"mw-editsection-bracket\">[</span>edit<span class=\"mw-editsection-bracket\">]</span></span></h2>\n<p>There are 40 Grade One circuits for a total of 49 layouts in 27 nations as of December 2021. Circuits holding Grade One certification may host events involving \"Automobiles of Groups D (FIA International Formula) and E (Free Formula) with a weight/power ratio of less than 1 kg/hp.\"<sup id=\"cite_ref-ISC2019_1-0\" class=\"reference\">[1]</sup> As such, a Grade One certification is required to host events involving Formula One cars.<sup id=\"cite_ref-2\" class=\"reference\">[2]</sup><sup id=\"cite_ref-2021_December_list_3-0\" class=\"reference\">[3]</sup>\n</p>\n<table class=\"wikitable sortable\" width=\"75%\" style=\"font-size: 95%;\">\n<tbody><tr>\n<th>Circuit\n</th>\n<th>Location\n</th>\n<th>Country\n</th>\n<th>Layout\n</th>\n<th>Length\n</th>\n<th>Continent\n</th></tr>\n<tr>\n<td>Albert Park Circuit\n</td>\n<td>Melbourne\n</td>\n<td><span class=\"flagicon\"><img alt=\"\" src=\"//upload.wikimedia.org/wikipedia/commons/thumb/8/88/Flag_of_Australia_%28converted%29.svg/23px-Flag_of_Australia_%28converted%29.svg.png\" decoding=\"async\" width=\"23\" height=\"12\" class=\"thumbborder\" srcset=\"//upload.wikimedia.org/wikipedia/commons/thumb/8/88/Flag_of_Australia_%28converted%29.svg/35px-Flag_of_Australia_%28converted%29.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/8/88/Flag_of_Australia_%28converted%29.svg/46px-Flag_of_Australia_%28converted%29.svg.png 2x\" data-file-width=\"1280\" data-file-height=\"640\" /> </span>Australia\n</td>\n<td>Grand Prix\n</td>\n<td>5.279 km (3.280 mi)\n</td>\n<td>Australia\n</td></tr>\n<tr>[...the rest of the table is shown here]"
},
"sections": [
{
"toclevel": 1,
"level": "2",
"line": "Grade One",
"number": "1",
"index": "1",
"fromtitle": "List_of_motor_racing_circuits_by_FIA_grade",
"byteoffset": 0,
"anchor": "Grade_One"
}
]
}
}
I can't see how you can return the table only, so, you have to extract the table from the API response (by using a script).
Assume I am in possession of a SERP API, which given a keyword, returns me the Google results of that keyword in JSON format (for example: https://serpapi.com/):
{
"organic_results": [
{
"position": 1,
"title": "Coffee - Wikipedia",
"link": "https://en.wikipedia.org/wiki/Coffee",
"displayed_link": "https://en.wikipedia.org › wiki › Coffee",
"snippet": "Coffee is a brewed drink prepared from roasted coffee beans, the seeds of berries from certain Coffea species. From the coffee fruit, the seeds are ...",
"sitelinks":{/*snip*/}
,
"rich_snippet":
{
"bottom":
{
"extensions":
[
"Region of origin: Horn of Africa and South Ara...",
"Color: Black, dark brown, light brown, beige",
"Introduced: 15th century"
]
,
"detected_extensions":
{
"introduced_th_century": 15
}
}
}
,
"about_this_result":
{
"source":
{
"description": "Wikipedia is a free content, multilingual online encyclopedia written and maintained by a community of volunteers through a model of open collaboration, using a wiki-based editing system. Individual contributors, also called editors, are known as Wikipedians.",
"source_info_link": "https://en.wikipedia.org/wiki/Wikipedia",
"security": "secure",
"icon": "https://serpapi.com/searches/6165916694c6c7025deef5ab/images/ed8bda76b255c4dc4634911fb134de53068293b1c92f91967eef45285098b61516f2cf8b6f353fb18774013a1039b1fb.png"
}
,
"keywords":
[
"coffee"
]
,
"languages":
[
"English"
]
,
"regions":
[
"the United States"
]
}
,
"cached_page_link": "https://webcache.googleusercontent.com/search?q=cache:U6oJMnF-eeUJ:https://en.wikipedia.org/wiki/Coffee+&cd=4&hl=en&ct=clnk&gl=us",
"related_pages_link": "https://www.google.com/search?q=related:https://en.wikipedia.org/wiki/Coffee+Coffee"
},
/* Results 2,3,4... */
]}
What is a good way to get new results from the past 24h? I added the &tbs=qdr:d query parameter, which only shows the results from the past day. That's a good first step.
The 2nd step is to filter out only relevant results. When there are no relevant results, Google shows this message box:
What is their algorithm to show this box?
Idea 1: "grep -i {exact_keywords}"
For example, if I search a keyword like "Alexander Pope", the 24h Google query might return results about the pope, written by a guy called Alexander. That's not super relevant. My naive idea is to grep (case insensitive) the exact keyword "Alexander Pope".
But that might leave out some good results.
Any other ideas?
If you have an invoice header with several values (invoice #, date, location) and an unknown amount of invoice lines with several values (product, price, tax), is there a way to flatten this data to one row that extends in cases where the quantity of invoice lines varies by invoice?
Input Example-
{"InvoiceRecords": [{
"InvoiceDate": "8/9/2017 12:00:00 AM",
"InvoiceLocation": "002",
"InvoiceNumber": "2004085",
"InvoiceRecordHeaderDetails": [{
"InvNum": "2004085",
"Location": "002",
"InvDate": "8/9/2017 12:00:00 AM"
}],
"InvoiceRecordLineItemDetails": [{
"UniqueID": "3939934",
"InvNum": "2004085",
"LINEITEM": "1",
"CUSTID": "PREAA",
"DEPTID": "320306",
"PRODID": "088856",
"ProdDesc": "STATE UST",
"Unitprice": "0.003",
"QuantShare": "237.5",
"TaxRate": "7.25",
"taxamount": "0.05"
}],
"InvoiceTaxCodeDetails": [{
"InvNum": "2004085",
"LineItem": "1",
"UniqueID": "34",
"taxCode": "SALES TAX",
"taxrate": "7.25",
"maxtax": "0"
}]
}]}
I need all the items on the same row (allowing for there to be more than one line item and/or more than one Tax Code items on a given Invoice Record.
Output Example (note: "_n" below in reference to undetermined amount of invoice lines and tax rows possible):
{"InvoiceRecords": [{
"InvoiceDate": "8/9/2017 12:00:00 AM",
"InvoiceLocation": "002",
"InvoiceNumber": "2004085",
"InvoiceRecordHeaderDetailsInvNum": "2004085",
"InvoiceRecordHeaderDetailsInvNumLocation": "002",
"InvoiceRecordHeaderDetailsInvNumInvDate": "8/9/2017 12:00:00 AM",
"InvoiceRecordLineItemDetailsUniqueID_1": "3939934",
"InvoiceRecordLineItemDetailsInvNum_1": "2004085",
"InvoiceRecordLineItemDetailsLINEITEM_1": "1",
"InvoiceRecordLineItemDetailsCUSTID_1": "PREAA",
"InvoiceRecordLineItemDetailsDEPTID_1": "320306",
"InvoiceRecordLineItemDetailsPRODID_1": "088856",
"InvoiceRecordLineItemDetailsProdDesc_1": "STATE UST",
"InvoiceRecordLineItemDetailsUnitprice_1": "0.003",
"InvoiceRecordLineItemDetailsQuantShare_1": "237.5",
"InvoiceRecordLineItemDetailsTaxRate_1": "7.25",
"InvoiceRecordLineItemDetailstaxamount_1": "0.05",
"InvoiceTaxCodeDetailsInvNum_1": "2004085",
"InvoiceTaxCodeDetailsLineItem_1": "1",
"InvoiceTaxCodeDetailsUniqueID_1": "34",
"InvoiceTaxCodeDetailstaxCode_1": "SALES TAX",
"InvoiceTaxCodeDetailstaxrate_1": "7.25",
"InvoiceTaxCodeDetailsmaxtax_1": "0",
"InvoiceRecordLineItemDetailsUniqueID_n": "3939934",
"InvoiceRecordLineItemDetailsInvNum_n": "2004085",
"InvoiceRecordLineItemDetailsLINEITEM_n": "1",
"InvoiceRecordLineItemDetailsCUSTID_n": "PREAA",
"InvoiceRecordLineItemDetailsDEPTID_n": "320306",
"InvoiceRecordLineItemDetailsPRODID_n": "088856",
"InvoiceRecordLineItemDetailsProdDesc_n": "STATE UST",
"InvoiceRecordLineItemDetailsUnitprice_n": "0.003",
"InvoiceRecordLineItemDetailsQuantShare_n": "237.5",
"InvoiceRecordLineItemDetailsTaxRate_n": "7.25",
"InvoiceRecordLineItemDetailstaxamount_n": "0.05",
"InvoiceTaxCodeDetailsInvNum_n": "2004085",
"InvoiceTaxCodeDetailsLineItem_n": "1",
"InvoiceTaxCodeDetailsUniqueID_n": "34",
"InvoiceTaxCodeDetailstaxCode_n": "SALES TAX",
"InvoiceTaxCodeDetailstaxrate_n": "7.25",
"InvoiceTaxCodeDetailsmaxtax_n": "0"
}]}
Thanks!
You have an example of a similar question in the samples directory which sits nearby you spoon.bat. Have a look at the samples/transformation/XML Add and survive the first choc: they do something much more complex, just to show all what is possible.
In your case, split with a Switch/Case, the input stream in header, items and manage to keep the InvoiceNumber on each (more on this later). Convert the three stream into JSON (with JSON Output or, maybe easier, with a Javascript). Then you Group by the items by InvoiceNumber. Join the three flows by InvoiceNumber, for which I suggest a lookup stream in the header stream then an other lookup stream in the footer stream. With an other javascript and treating the data as string, you can build the JSON row in the format { header, [item], footer}, which you can Group by with a concatenation to have only one row.
Some work, but rather standard, except for the tricky part of the get the InvoiceNumber on the items and footer as they have disappeared from the flow. For that you can use fact that the javascript preserve the values unless redefined. Add a new start script [right click on the Script1 on the tab top, add a copy, right click on the Script1_0 just created, and define it as Start script].
On this start script:
var PrevInvoiceNumber = -1;
On the main script:
if(InvoiceNumber && PrevInvoiceNumber!=InvoiceNumber)
PrevInvoiceNumber = InvoiceNumber
Then you should see the data with on each line the PrevInvoiceNumber which is equal to the expected InvoiceNumber of the invoice.
I'm using the import.io API and have noticed that some field types return several columns in the generated json. For instance a field foo of type Money will return three columns: foo, foo/_currency and foo/_source.
Is there a reference somewhere? I found some documentation here http://blog.import.io/post/11-columns-of-importio through an incomplete example:
{
"whole_number_field": 123,
"whole_number_field/_source": "123",
"language_field": "ben",
"language_field/_source": "bn",
"country_field": "CHN",
"country_field/_source": "China",
"boolean_field": false,
"boolean_field/_source": "false",
"currency_field/_currency": "GBP",
"currency_field/_source": "£123.45",
"link_field": "http://chris-alexander.co.uk",
"link_field/_text": "Blog",
"link_field/_title": "linktitle",
"datetime_field": 611368440000,
"datetime_field/_source": "17/05/89 12:34",
"datetime_field/_utc": "Wed May 17 00:34:00 GMT 1989",
"image_field": "http://io.chris-alexander.co.uk/gif2.gif",
"image_field/_alt": "imgalt",
"image_field/_title": "imgtitle",
"image_field/_source": "gif2.gif"
}
The columns are documented in the API docs:
http://api.docs.import.io/
For example, for currency, the columns are:
myvar <== Extracted value
myvar/_currency <== ISO currency code
myvar/_source <== Original value
The ISO currency code is returned as myvar/_currency, the numeric value in myvar
I established this through several tests, I'd like to know if I'm missing something:
{
'DATE': ['_source', '_utc'],
# please tell me if you have an example of an import.io API with a date!
'BOOLEAN': ['_source'],
'LANG': ['_source'],
'COUNTRY': ['_source'],
'HTML':[],
'STRING':[],
'URL': ['_text', '_source', '_title'],
'IMAGE': ['_alt', '_title', '_source'],
'DOUBLE': ['_source'],
'CURRENCY': ['_currency', '_source'],
}
Is there a sort plugin for the date format
16 Jul 2014, 2:04 p.m.
18 Jul 2014, 11:54 a.m.
27 Jun 2014, 5:56 p.m.
The dates are currently sorted in the default format (16 Jul should be before 18 Jul but after 27 Jun).
This is my table definition:
$(document).ready(function() {
var dt = $("#files_table").dataTable({
"paging": false,
"defaultContent": "No Data",
"order": [[ 0, "desc" ]],
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 7, ]},
{ "sClass": "center", "aTargets": [ 7, ]},
{ "sType": "date-uk", "aTargets": [ 0, ]},
]
});
At the bottom where I specify the date type (current "date-uk"), none of the date formats at
http://datatables.net/plug-ins/sorting/ correspond to day name-of-month year hh:mm.
Is my only alternative to make my own data source sort function? It seems like quite a common format.
You can sort your dates without any additional plugin, only you have to put the timestamp of the date in data-order attribute.
Demo.
Documentation.