Compare commits

...

26 Commits

Author SHA1 Message Date
Peter B f97819c6cf dockerfile and build instructions
add docker registry reference
2022-01-19 20:30:46 -05:00
ColleterVi d5072c8315 fix: new restcountries url (#10043)
Url extension "eu" and path "rest" are no longer available. Replacing them for a working url.
2022-01-13 20:25:58 +09:00
Ines Montani fa39d0e975 Merge pull request #9989 from explosion/docs/update-algolia-search-api [ci skip] 2022-01-05 14:15:30 +01:00
Sofie Van Landeghem 4857e851db Fix references to config file in the docs & UX (#9961)
* doc fixes around config file

* fix typo

* clarify default
2022-01-04 14:32:44 +01:00
Sam Edwardes 074a67a749 Added spacypdfreader to universe.json (#9963) 2022-01-03 16:44:50 +09:00
Paul O'Leary McCann dfa4e1569c Remove denomme from universe (#9952)
Package seems to have been deleted.
2021-12-29 11:42:38 +01:00
Yoav Vollansky 65524ad7b1 Update UNIVERSE.md (#9941)
typo
2021-12-27 13:46:44 +01:00
Peter Baumgartner 7edda6528f MultiHashEmbed vector docs correction (#9918) 2021-12-27 11:22:19 +01:00
Edward 3d7955dd5b Add healthsea to universe (#9838)
* Add healthsea to universe

* Update website/meta/universe.json

* Add thumbnail

* Update website/meta/universe.json

Co-authored-by: Sofie Van Landeghem <svlandeg@users.noreply.github.com>
2021-12-15 17:54:44 +01:00
Ines Montani 4e42a4dc71 Support Google Sheets embeds in docs (#9861) 2021-12-15 09:29:05 +01:00
Adriane Boyd 8064410f22 Merge branch 'master' into spacy.io 2021-12-09 08:34:33 +01:00
Adriane Boyd 27945575df Update Catalan acknowledgements for v3.2 (#9763) 2021-11-29 14:14:46 +01:00
Tuomo Hiippala 22316c428f add entry for Applied Language Technology under "Courses" (#9755)
Added the following entry into `universe.json`:

```
        {
            "type": "education",
            "id": "applt-course",
            "title": "Applied Language Technology",
            "slogan": "NLP for newcomers using spaCy and Stanza",
            "description": "These learning materials provide an introduction to applied language technology for audiences who are unfamiliar with language technology and programming. The learning materials assume no previous knowledge of the Python programming language.",
            "url": "https://applied-language-technology.readthedocs.io/",
            "image": "https://www.mv.helsinki.fi/home/thiippal/images/applt-preview.jpg",
            "thumb": "https://applied-language-technology.readthedocs.io/en/latest/_static/logo.png",
            "author": "Tuomo Hiippala",
            "author_links": {
                "twitter": "tuomo_h",
                "github": "thiippal",
                "website": "https://www.mv.helsinki.fi/home/thiippal/"
            },
            "category": ["courses"]
        },
```
2021-11-28 19:33:49 +09:00
Paul O'Leary McCann 393b766d8a Add note on batch contract for listeners (#9691)
* Add note on batch contract

Using listeners requires batches to be consistent. This is obvious if
you understand how the listener works, but it wasn't clearly stated in
the Docs, and was subtle enough that the EntityLinker missed it.

There is probably a clearer way to explain what the actual requirement
is, but I figure this is a good start.

* Rewrite to clarify role of caching
2021-11-22 11:45:26 +01:00
Paul O'Leary McCann 86f4986ce0 Clarify how to fill in init_tok2vec after pretraining (#9639)
* Clarify how to fill in init_tok2vec after pretraining

* Ignore init_tok2vec arg in pretraining

* Update docs, config setting

* Remove obsolete note about not filling init_tok2vec early

This seems to have also caught some lines that needed cleanup.
2021-11-22 11:45:14 +01:00
Sofie Van Landeghem 2cdc6e5f29 add note that annotating components is new since 3.1 (#9678) 2021-11-22 15:07:30 +09:00
Vishnu Nandakumar 6d70978a77 Update universe.json with new library eng_spacysentiment (#9679)
* Update universe.json

* Update universe.json

* Cleanup fields

Co-authored-by: Paul O'Leary McCann <polm@dampfkraft.com>
2021-11-16 14:06:52 +09:00
Adriane Boyd 39d02ddacd Merge branch 'master' into spacy.io 2021-11-05 16:31:29 +01:00
Paul O'Leary McCann 68906d0aaa Fix typo about receptive field size (#9564) 2021-11-03 15:17:16 +01:00
Adriane Boyd 769ecbda12 Fix tok2vec-less textcat generation in website quickstart (#9610) 2021-11-03 15:11:45 +01:00
Paul O'Leary McCann d2937b5052 Add note about round-trip serializing pipeline to API docs (#9583) 2021-11-03 15:11:37 +01:00
xxyzz cd283ecccd Add WordDumb to spaCy Universe (#9572)
* Add WordDumb to spaCy Universe

* Add standalone category

Co-authored-by: Paul O'Leary McCann <polm@dampfkraft.com>
2021-11-01 18:39:45 +09:00
Bruce W. Lee (이웅성) 9b5c0c9696 Adding LingFeat Software to spaCy Universe. (#9574)
* add lingfeat in universe

* add lingfeat in universe

* Fix JSON

* Minor cleanup

Co-authored-by: Paul O'Leary McCann <polm@dampfkraft.com>
2021-11-01 18:39:29 +09:00
Vasundhara fc8006a84d Fix broken link to mappings-exceptions (#9573) 2021-10-31 13:45:38 +09:00
Sofie Van Landeghem 3f1f1dac63 Merge pull request #9526 from explosion/master
Update docs for 3.1.4
2021-10-29 16:49:04 +02:00
Philip Vollet 1adf6001e6 fixed typo and URL (#9560) 2021-10-29 14:13:15 +09:00
19 changed files with 192 additions and 53 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ def debug_config_cli(
show_vars: bool = Opt(False, "--show-variables", "-V", help="Show an overview of all variables referenced in the config and their values. This will also reflect variables overwritten on the CLI.")
# fmt: on
):
"""Debug a config.cfg file and show validation errors. The command will
"""Debug a config file and show validation errors. The command will
create all objects in the tree and validate them. Note that some config
validation errors are blocking and will prevent the rest of the config from
being resolved. This means that you may not see all validation errors at
+5 -5
View File
@@ -27,7 +27,7 @@ class Optimizations(str, Enum):
@init_cli.command("config")
def init_config_cli(
# fmt: off
output_file: Path = Arg(..., help="File to save config.cfg to or - for stdout (will only output config and no additional logging info)", allow_dash=True),
output_file: Path = Arg(..., help="File to save the config to or - for stdout (will only output config and no additional logging info)", allow_dash=True),
lang: str = Opt("en", "--lang", "-l", help="Two-letter code of the language to use"),
pipeline: str = Opt("tagger,parser,ner", "--pipeline", "-p", help="Comma-separated names of trainable pipeline components to include (without 'tok2vec' or 'transformer')"),
optimize: Optimizations = Opt(Optimizations.efficiency.value, "--optimize", "-o", help="Whether to optimize for efficiency (faster inference, smaller model, lower memory consumption) or higher accuracy (potentially larger and slower model). This will impact the choice of architecture, pretrained weights and related hyperparameters."),
@@ -37,7 +37,7 @@ def init_config_cli(
# fmt: on
):
"""
Generate a starter config.cfg for training. Based on your requirements
Generate a starter config file for training. Based on your requirements
specified via the CLI arguments, this command generates a config with the
optimal settings for your use case. This includes the choice of architecture,
pretrained weights and related hyperparameters.
@@ -66,15 +66,15 @@ def init_config_cli(
@init_cli.command("fill-config")
def init_fill_config_cli(
# fmt: off
base_path: Path = Arg(..., help="Base config to fill", exists=True, dir_okay=False),
output_file: Path = Arg("-", help="File to save config.cfg to (or - for stdout)", allow_dash=True),
base_path: Path = Arg(..., help="Path to base config to fill", exists=True, dir_okay=False),
output_file: Path = Arg("-", help="Path to output .cfg file (or - for stdout)", allow_dash=True),
pretraining: bool = Opt(False, "--pretraining", "-pt", help="Include config for pretraining (with 'spacy pretrain')"),
diff: bool = Opt(False, "--diff", "-D", help="Print a visual diff highlighting the changes"),
code_path: Optional[Path] = Opt(None, "--code-path", "--code", "-c", help="Path to Python file with additional code (registered functions) to be imported"),
# fmt: on
):
"""
Fill partial config.cfg with default values. Will add all missing settings
Fill partial config file with default values. Will add all missing settings
from the default config and will create all objects, check the registered
functions for their default values and update the base config. This command
can be used with a config generated via the training quickstart widget:
+1 -1
View File
@@ -642,7 +642,7 @@ class Errors(metaclass=ErrorsWithCodes):
E912 = ("Failed to initialize lemmatizer. Missing lemmatizer table(s) found "
"for mode '{mode}'. Required tables: {tables}. Found: {found}.")
E913 = ("Corpus path can't be None. Maybe you forgot to define it in your "
"config.cfg or override it on the CLI?")
".cfg file or override it on the CLI?")
E914 = ("Executing {name} callback failed. Expected the function to "
"return the nlp object but got: {value}. Maybe you forgot to return "
"the modified object in your function?")
+1 -1
View File
@@ -123,7 +123,7 @@ def MultiHashEmbed(
attributes are NORM, PREFIX, SUFFIX and SHAPE. This lets the model take into
account some subword information, without constructing a fully character-based
representation. If pretrained vectors are available, they can be included in
the representation as well, with the vectors table will be kept static
the representation as well, with the vectors table kept static
(i.e. it's not updated).
The `width` parameter specifies the output width of the layer and the widths
+4 -4
View File
@@ -63,7 +63,7 @@ OOV_RANK = numpy.iinfo(numpy.uint64).max
DEFAULT_OOV_PROB = -20
LEXEME_NORM_LANGS = ["cs", "da", "de", "el", "en", "id", "lb", "mk", "pt", "ru", "sr", "ta", "th"]
# Default order of sections in the config.cfg. Not all sections needs to exist,
# Default order of sections in the config file. Not all sections needs to exist,
# and additional sections are added at the end, in alphabetical order.
CONFIG_SECTION_ORDER = ["paths", "variables", "system", "nlp", "components", "corpora", "training", "pretraining", "initialize"]
# fmt: on
@@ -465,7 +465,7 @@ def load_model_from_path(
"""Load a model from a data directory path. Creates Language class with
pipeline from config.cfg and then calls from_disk() with path.
model_path (Path): Mmodel path.
model_path (Path): Model path.
meta (Dict[str, Any]): Optional model meta.
vocab (Vocab / True): Optional vocab to pass in on initialization. If True,
a new Vocab object will be created.
@@ -642,8 +642,8 @@ def load_config(
sys.stdin.read(), overrides=overrides, interpolate=interpolate
)
else:
if not config_path or not config_path.exists() or not config_path.is_file():
raise IOError(Errors.E053.format(path=config_path, name="config.cfg"))
if not config_path or not config_path.is_file():
raise IOError(Errors.E053.format(path=config_path, name="config file"))
return config.from_disk(
config_path, overrides=overrides, interpolate=interpolate
)
+16
View File
@@ -0,0 +1,16 @@
FROM node:11.15.0
WORKDIR /spacy-io
RUN npm install -g gatsby-cli@2.7.4
COPY package.json .
COPY package-lock.json .
RUN npm install
# This is so the installed node_modules will be up one directory
# from where a user mounts files, so that they don't accidentally mount
# their own node_modules from a different build
# https://nodejs.org/api/modules.html#modules_loading_from_node_modules_folders
WORKDIR /spacy-io/website/
+34
View File
@@ -554,6 +554,40 @@ extensions for your code editor. The
[`.prettierrc`](https://github.com/explosion/spaCy/tree/master/website/.prettierrc)
file in the root defines the settings used in this codebase.
## Building & Developing the Site with Docker {#docker}
Sometimes it's hard to get a local environment working due to rapid updates to node dependencies,
so it may be easier to use docker for building the docs.
If you'd like to do this,
**be sure you do *not* include your local `node_modules` folder**,
since there are some dependencies that need to be built for the image system.
Rename it before using.
```bash
docker run -it \
-v $(pwd):/spacy-io/website \
-p 8000:8000 \
ghcr.io/explosion/spacy-io \
gatsby develop -H 0.0.0.0
```
This will allow you to access the built website at http://0.0.0.0:8000/
in your browser, and still edit code in your editor while having the site
reflect those changes.
**Note**: On M1 Macs you may need to the image tagged `arm64` (`ghcr.io/explosion/spacy-io:arm64`),
otherwise you'll see `qemu` segfault during the build.
### Building the Docker Image {#docker-build}
If you'd like to build the image locally, you can do so like this:
```bash
docker build -t spacy-io .
```
This will take some time, so if you want to use the prebuilt image you'll save a bit of time.
## Markdown reference {#markdown}
All page content and page meta lives in the `.md` files in the `/docs`
+1 -1
View File
@@ -44,7 +44,7 @@ markup is correct.
"id": "unique-project-id",
"title": "Project title",
"slogan": "A short summary",
"description": "A longer description *Mardown allowed!*",
"description": "A longer description *Markdown allowed!*",
"github": "user/repo",
"pip": "package-name",
"code_example": [
+3 -3
View File
@@ -158,7 +158,7 @@ be configured with the `attrs` argument. The suggested attributes are `NORM`,
`PREFIX`, `SUFFIX` and `SHAPE`. This lets the model take into account some
subword information, without construction a fully character-based
representation. If pretrained vectors are available, they can be included in the
representation as well, with the vectors table will be kept static (i.e. it's
representation as well, with the vectors table kept static (i.e. it's
not updated).
| Name | Description |
@@ -296,7 +296,7 @@ learned linear projection to control the dimensionality. Unknown tokens are
mapped to a zero vector. See the documentation on
[static vectors](/usage/embeddings-transformers#static-vectors) for details.
| Name |  Description |
| Name | Description |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `nO` | The output width of the layer, after the linear projection. ~~Optional[int]~~ |
| `nM` | The width of the static vectors. ~~Optional[int]~~ |
@@ -318,7 +318,7 @@ mapped to a zero vector. See the documentation on
Extract arrays of input features from [`Doc`](/api/doc) objects. Expects a list
of feature names to extract, which should refer to token attributes.
| Name |  Description |
| Name | Description |
| ----------- | ------------------------------------------------------------------------ |
| `columns` | The token attributes to extract. ~~List[Union[int, str]]~~ |
| **CREATES** | The created feature extraction layer. ~~Model[List[Doc], List[Ints2d]]~~ |
+4 -4
View File
@@ -148,8 +148,8 @@ $ python -m spacy init config [output_file] [--lang] [--pipeline] [--optimize] [
### init fill-config {#init-fill-config new="3"}
Auto-fill a partial [`config.cfg` file](/usage/training#config) file with **all
default values**, e.g. a config generated with the
Auto-fill a partial [.cfg file](/usage/training#config) with **all default
values**, e.g. a config generated with the
[quickstart widget](/usage/training#quickstart). Config files used for training
should always be complete and not contain any hidden defaults or missing values,
so this command helps you create your final training config. In order to find
@@ -175,7 +175,7 @@ $ python -m spacy init fill-config [base_path] [output_file] [--diff]
| Name | Description |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `base_path` | Path to base config to fill, e.g. generated by the [quickstart widget](/usage/training#quickstart). ~~Path (positional)~~ |
| `output_file` | Path to output `.cfg` file. If not set, the config is written to stdout so you can pipe it forward to a file. ~~Path (positional)~~ |
| `output_file` | Path to output `.cfg` file or "-" to write to stdout so you can pipe it to a file. Defaults to "-" (stdout). ~~Path (positional)~~ |
| `--code`, `-c` | Path to Python file with additional code to be imported. Allows [registering custom functions](/usage/training#custom-functions) for new architectures. ~~Optional[Path] \(option)~~ |
| `--pretraining`, `-pt` | Include config for pretraining (with [`spacy pretrain`](/api/cli#pretrain)). Defaults to `False`. ~~bool (flag)~~ |
| `--diff`, `-D` | Print a visual diff highlighting the changes. ~~bool (flag)~~ |
@@ -208,7 +208,7 @@ $ python -m spacy init vectors [lang] [vectors_loc] [output_dir] [--prune] [--tr
| `output_dir` | Pipeline output directory. Will be created if it doesn't exist. ~~Path (positional)~~ |
| `--truncate`, `-t` | Number of vectors to truncate to when reading in vectors file. Defaults to `0` for no truncation. ~~int (option)~~ |
| `--prune`, `-p` | Number of vectors to prune the vocabulary to. Defaults to `-1` for no pruning. ~~int (option)~~ |
| `--mode`, `-m` | Vectors mode: `default` or [`floret`](https://github.com/explosion/floret). Defaults to `default`. ~~Optional[str] \(option)~~ |
| `--mode`, `-m` | Vectors mode: `default` or [`floret`](https://github.com/explosion/floret). Defaults to `default`. ~~Optional[str] \(option)~~ |
| `--name`, `-n` | Name to assign to the word vectors in the `meta.json`, e.g. `en_core_web_md.vectors`. ~~Optional[str] \(option)~~ |
| `--verbose`, `-V` | Print additional information and explanations. ~~bool (flag)~~ |
| `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ |
+1 -1
View File
@@ -535,7 +535,7 @@ As of spaCy v3.0, the `meta.json` **isn't** used to construct the language class
and pipeline anymore and only contains meta information for reference and for
creating a Python package with [`spacy package`](/api/cli#package). How to set
up the `nlp` object is now defined in the
[`config.cfg`](/api/data-formats#config), which includes detailed information
[config file](/api/data-formats#config), which includes detailed information
about the pipeline components and their model architectures, and all other
settings and hyperparameters used to train the pipeline. It's the **single
source of truth** used for loading a pipeline.
+2 -2
View File
@@ -1479,7 +1479,7 @@ especially useful it you want to pass in a string instead of calling
### Example: Pipeline component for GPE entities and country meta data via a REST API {#component-example3}
This example shows the implementation of a pipeline component that fetches
country meta data via the [REST Countries API](https://restcountries.eu), sets
country meta data via the [REST Countries API](https://restcountries.com), sets
entity annotations for countries and sets custom attributes on the `Doc` and
`Span` for example, the capital, latitude/longitude coordinates and even the
country flag.
@@ -1495,7 +1495,7 @@ from spacy.tokens import Doc, Span, Token
@Language.factory("rest_countries")
class RESTCountriesComponent:
def __init__(self, nlp, name, label="GPE"):
r = requests.get("https://restcountries.eu/rest/v2/all")
r = requests.get("https://restcountries.com/v2/all")
r.raise_for_status() # make sure requests raises an error if it fails
countries = r.json()
# Convert API response to dict keyed by country name for easy lookup
+2 -1
View File
@@ -22,7 +22,8 @@
"list": "89ad33e698"
},
"docSearch": {
"apiKey": "371e26ed49d29a27bd36273dfdaf89af",
"appId": "Y1LB128RON",
"apiKey": "bb601a1daab73e2dc66faf2b79564807",
"indexName": "spacy"
},
"binderUrl": "explosion/spacy-io-binder",
+86 -26
View File
@@ -1,5 +1,43 @@
{
"resources": [
{
"id": "spacypdfreader",
"title": "spadypdfreader",
"category": ["pipeline"],
"tags": ["PDF"],
"slogan": "Easy PDF to text to spaCy text extraction in Python.",
"description": "*spacypdfreader* is a Python library that allows you to convert PDF files directly into *spaCy* `Doc` objects. The library provides several built in parsers or bring your own parser. `Doc` objects are annotated with several custom attributes including: `token._.page_number`, `doc._.page_range`, `doc._.first_page`, `doc._.last_page`, `doc._.pdf_file_name`, and `doc._.page(int)`.",
"github": "SamEdwardes/spacypdfreader",
"pip": "spacypdfreader",
"url": "https://samedwardes.github.io/spacypdfreader/",
"code_language": "python",
"author": "Sam Edwardes",
"author_links": {
"twitter": "TheReaLSamlam",
"github": "SamEdwardes",
"website": "https://samedwardes.com"
},
"code_example": [
"import spacy",
"from spacypdfreader import pdf_reader",
"",
"nlp = spacy.load('en_core_web_sm')",
"doc = pdf_reader('tests/data/test_pdf_01.pdf', nlp)",
"",
"# Get the page number of any token.",
"print(doc[0]._.page_number) # 1",
"print(doc[-1]._.page_number) # 4",
"",
"# Get page meta data about the PDF document.",
"print(doc._.pdf_file_name) # 'tests/data/test_pdf_01.pdf'",
"print(doc._.page_range) # (1, 4)",
"print(doc._.first_page) # 1",
"print(doc._.last_page) # 4",
"",
"# Get all of the text from a specific PDF page.",
"print(doc._.page(4)) # 'able to display the destination page (unless...'"
]
},
{
"id": "nlpcloud",
"title": "NLPCloud.io",
@@ -26,32 +64,6 @@
"category": ["apis", "nonpython", "standalone"],
"tags": ["api", "deploy", "production"]
},
{
"id": "denomme",
"title": "denomme : Multilingual Name Detector",
"slogan": "Multilingual Name Detection",
"description": "A SpaCy extension for Spans to extract multilingual names out of documents trained on XLM-roberta backbone",
"github": "meghanabhange/denomme",
"pip": "denomme https://denomme.s3.us-east-2.amazonaws.com/xx_denomme-0.3.1/dist/xx_denomme-0.3.1.tar.gz",
"code_example": [
"from spacy.lang.xx import MultiLanguage",
"from denomme.name import person_name_component",
"nlp = MultiLanguage()",
"nlp.add_pipe('denomme')",
"doc = nlp('Hi my name is Meghana S.R Bhange and I want to talk Asha')",
"print(doc._.person_name)",
"# ['Meghana S.R Bhange', 'Asha']"
],
"thumb": "https://i.ibb.co/jwGVWPZ/rainbow-bohemian-logo-removebg-preview.png",
"code_language": "python",
"author": "Meghana Bhange",
"author_links": {
"github": "meghanabhange",
"twitter": "_aspiringcat"
},
"category": ["standalone"],
"tags": ["person-name-detection"]
},
{
"id": "eMFDscore",
"title": "eMFDscore : Extended Moral Foundation Dictionary Scoring for Python",
@@ -2774,6 +2786,54 @@
"website": "https://yanaiela.github.io"
}
},
{
"id": "Healthsea",
"title": "Healthsea",
"slogan": "Healthsea: an end-to-end spaCy pipeline for exploring health supplement effects",
"description": "This spaCy project trains an NER model and a custom Text Classification model with Clause Segmentation and Blinding capabilities to analyze supplement reviews and their potential effects on health.",
"github": "explosion/healthsea",
"thumb": "https://github.com/explosion/healthsea/blob/main/img/Jellyfish.png",
"category": ["pipeline", "research"],
"code_example": [
"import spacy",
"",
"nlp = spacy.load(\"en_healthsea\")",
"doc = nlp(\"This is great for joint pain.\")",
"",
"# Clause Segmentation & Blinding",
"print(doc._.clauses)",
"",
"> {",
"> \"split_indices\": [0, 7],",
"> \"has_ent\": true,",
"> \"ent_indices\": [4, 6],",
"> \"blinder\": \"_CONDITION_\",",
"> \"ent_name\": \"joint pain\",",
"> \"cats\": {",
"> \"POSITIVE\": 0.9824668169021606,",
"> \"NEUTRAL\": 0.017364952713251114,",
"> \"NEGATIVE\": 0.00002889777533710003,",
"> \"ANAMNESIS\": 0.0001394189748680219",
"> \"prediction_text\": [\"This\", \"is\", \"great\", \"for\", \"_CONDITION_\", \"!\"]",
"> }",
"",
"# Aggregated results",
"> {",
"> \"joint_pain\": {",
"> \"effects\": [\"POSITIVE\"],",
"> \"effect\": \"POSITIVE\",",
"> \"label\": \"CONDITION\",",
"> \"text\": \"joint pain\"",
"> }",
"> }"
],
"author": "Edward Schmuhl",
"author_links": {
"github": "thomashacker",
"twitter": "aestheticedwar1",
"website": "https://explosion.ai/"
}
},
{
"id": "presidio",
"title": "Presidio",
+21 -1
View File
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types'
import classNames from 'classnames'
import Link from './link'
import Button from './button'
import { InlineCode } from './code'
import { markdownToReact } from './util'
@@ -104,4 +105,23 @@ const Image = ({ src, alt, title, ...props }) => {
)
}
export { YouTube, SoundCloud, Iframe, Image }
const GoogleSheet = ({ id, link, height, button = 'View full table' }) => {
return (
<figure className={classes.root}>
<iframe
title={id}
scrolling="no"
className={classes.googleSheet}
height={height}
src={`https://docs.google.com/spreadsheets/d/e/${id}/pubhtml?widget=true&amp;headers=false`}
/>
{link && (
<Button href={`https://docs.google.com/spreadsheets/d/${link}/view`}>
{button}
</Button>
)}
</figure>
)
}
export { YouTube, SoundCloud, Iframe, Image, GoogleSheet }
+2 -1
View File
@@ -6,13 +6,14 @@ import Icon from './icon'
import classes from '../styles/search.module.sass'
export default function Search({ id = 'docsearch', placeholder = 'Search docs', settings = {} }) {
const { apiKey, indexName } = settings
const { apiKey, indexName, appId } = settings
if (!apiKey && !indexName) return null
const [initialized, setInitialized] = useState(false)
useEffect(() => {
if (!initialized) {
setInitialized(true)
window.docsearch({
appId,
apiKey,
indexName,
inputSelector: `#${id}`,
+1
View File
@@ -41,6 +41,7 @@ export const pageQuery = graphql`
docSearch {
apiKey
indexName
appId
}
}
}
+4
View File
@@ -32,3 +32,7 @@
.image-link
display: block
.google-sheet
width: 100%
margin-bottom: 1rem
+3 -1
View File
@@ -29,7 +29,7 @@ import Aside from '../components/aside'
import Button from '../components/button'
import Tag from '../components/tag'
import Grid from '../components/grid'
import { YouTube, SoundCloud, Iframe, Image } from '../components/embed'
import { YouTube, SoundCloud, Iframe, Image, GoogleSheet } from '../components/embed'
import Alert from '../components/alert'
import Search from '../components/search'
import Project from '../widgets/project'
@@ -72,6 +72,7 @@ const scopeComponents = {
YouTube,
SoundCloud,
Iframe,
GoogleSheet,
Abbr,
Tag,
Accordion,
@@ -234,6 +235,7 @@ export const pageQuery = graphql`
docSearch {
apiKey
indexName
appId
}
}
}