Compare commits
26 Commits
format
...
docs-docker
| Author | SHA1 | Date | |
|---|---|---|---|
| f97819c6cf | |||
| d5072c8315 | |||
| fa39d0e975 | |||
| 4857e851db | |||
| 074a67a749 | |||
| dfa4e1569c | |||
| 65524ad7b1 | |||
| 7edda6528f | |||
| 3d7955dd5b | |||
| 4e42a4dc71 | |||
| 8064410f22 | |||
| 27945575df | |||
| 22316c428f | |||
| 393b766d8a | |||
| 86f4986ce0 | |||
| 2cdc6e5f29 | |||
| 6d70978a77 | |||
| 39d02ddacd | |||
| 68906d0aaa | |||
| 769ecbda12 | |||
| d2937b5052 | |||
| cd283ecccd | |||
| 9b5c0c9696 | |||
| fc8006a84d | |||
| 3f1f1dac63 | |||
| 1adf6001e6 |
@@ -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
|
||||
|
||||
@@ -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
@@ -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?")
|
||||
|
||||
@@ -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
@@ -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
|
||||
)
|
||||
|
||||
@@ -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/
|
||||
@@ -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
@@ -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": [
|
||||
|
||||
@@ -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]]~~ |
|
||||
|
||||
@@ -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)~~ |
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,7 +22,8 @@
|
||||
"list": "89ad33e698"
|
||||
},
|
||||
"docSearch": {
|
||||
"apiKey": "371e26ed49d29a27bd36273dfdaf89af",
|
||||
"appId": "Y1LB128RON",
|
||||
"apiKey": "bb601a1daab73e2dc66faf2b79564807",
|
||||
"indexName": "spacy"
|
||||
},
|
||||
"binderUrl": "explosion/spacy-io-binder",
|
||||
|
||||
+86
-26
@@ -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",
|
||||
|
||||
@@ -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&headers=false`}
|
||||
/>
|
||||
{link && (
|
||||
<Button href={`https://docs.google.com/spreadsheets/d/${link}/view`}>
|
||||
{button}
|
||||
</Button>
|
||||
)}
|
||||
</figure>
|
||||
)
|
||||
}
|
||||
|
||||
export { YouTube, SoundCloud, Iframe, Image, GoogleSheet }
|
||||
|
||||
@@ -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}`,
|
||||
|
||||
@@ -41,6 +41,7 @@ export const pageQuery = graphql`
|
||||
docSearch {
|
||||
apiKey
|
||||
indexName
|
||||
appId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,3 +32,7 @@
|
||||
|
||||
.image-link
|
||||
display: block
|
||||
|
||||
.google-sheet
|
||||
width: 100%
|
||||
margin-bottom: 1rem
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user